我正在创造游戏引擎。 在Windows上,我有两个线程共享两个上下文(使用wglShareLists)。 它工作正常。 当一个线程加载资源时,其他的只是渲染简单的加载屏幕。 在Linux上没有WGL,只有glX。 我不知道如何正确使用它。 目前我的线程代码如下所示: LinuxThread::LinuxThread() : handle_(0), running_(false), task_(0), useGraphicsContext_(0), threadContext_(0), threadDrawable_(0), dsp_(0) { } LinuxThread::~LinuxThread() { finishTask(); running_ = false; glXDestroyContext(dsp_, threadContext_); } ULONG LinuxThread::getId() { return static_cast<ULONG>(handle_); } void LinuxThread::start() { running_ = true; pthread_create(&handle_, 0, &LinuxThread::staticRun, (void*) this); } bool LinuxThread::isRunning() { return running_; } void LinuxThread::setGraphicsContext(bool state) { […]
我正在编写Wavefront .OBJ网格分析器。 虽然我一直在研究这个问题已经有三个星期了,但是我决定重写它的大部分内容,因为我正在逐个字符地parsing它(我觉得最后引入了太多的复杂性,无论如何都不能正常工作)。 现在我一直在逐行parsing,我觉得我的结果越来越差。 以下是我的输出示例: ( STREAM ):# cube.obj } (LINE 2){ ( STREAM ):# } (LINE 3){ ( STREAM ): } (LINE 4){ ( STREAM ):g cube } (LINE 5){ ( STREAM ): } (LINE 6){ ( VERTEX: 1 )'-597028128851671121920.000000 0.000000 -597118763794171953152.000000' ( STREAM ):v 0.0 0.0 0.0 } (LINE 7){ ( VERTEX: 2 […]
我正试图在SDL_Window上初始化一个OpenGL上下文。 问题是,当我尝试执行glewInit() ,它无法初始化并给出错误信息“Missing OpenGL version”。 我在Google上search了一下,看来这个错误要么在OpenGL上下文没有初始化的时候出现,要么当SDL_GL_MakeCurrent没有上下文的时候,更确切的说是SDL。 值得一提的是这里使用的SDL / OpenGL对象(gi_window,gi_glcontext)是GameInstance类中的公共variables。 我的OpenGL版本是3.0,我的SDL版本是2.0.3,而我的GLEW版本是1.10-2。 正在使用的系统是64位Arch Linux(因此安装了上述库的64位版本)。 初始化代码 #include "../headers/init.h" GameInstance::GameInstance(int p_fps, int p_height, int p_width, const char* p_wtitle) { gi_fps = p_fps; if(SDL_Init(SDL_INIT_EVERYTHING) < 0) { std::cerr << "SDL Error(something about the init):" << SDL_GetError() << std::endl; } gi_window = SDL_CreateWindow(p_wtitle, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, p_width, p_height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN); if(gi_window […]
我一直在削减这段错误,这是我的机器上一个非常简单的重现的例子(下面)。 我觉得这是一个驱动程序错误,但是我对OpenGL非常不熟悉,所以我更可能只是做错了事情。 这是正确的OpenGL 3.3代码? 无论平台和编译器都应该没问题? 这是用gcc -ggdb -lGL -lSDL2编译的代码 #include <stdio.h> #include "GL/gl.h" #include "GL/glext.h" #include "SDL2/SDL.h" // this section is for loading OpenGL things from later versions. typedef void (APIENTRY *GLGenVertexArrays) (GLsizei n, GLuint *arrays); typedef void (APIENTRY *GLGenBuffers) (GLsizei n, GLuint *buffers); typedef void (APIENTRY *GLBindVertexArray) (GLuint array); typedef void (APIENTRY *GLBindBuffer) (GLenum […]
我想运行一个不需要窗口的OpenGL程序,这个程序创build一个文件。 这是在debian xfce上完成的,到目前为止还不错。 然后我尝试从另一台使用ssh的计算机上运行该程序,如果xfce在显示器上,我可以使用DISPLAY =:0编译并运行该程序(因此打开的时间就像是毫秒并closures)。 问题是当我重新启动,我断开显示器,xfce将不会启动GUI,并且glut不会启动。 VirtualGL不是我想要的,隐藏的窗口不是我想要的,我想从没有X GUI的terminal运行OpenGL程序。 或者为了能够强制xfce启动GUI并使其在GUI中login,所以我可以启动过剩。 一个小例子会很好。
我试图跟踪按下的按键。 我有glutIgnoreKeyRepeat(1) ,我注册的关键事件(向下/向上为正常和特殊)在一个对象,跟踪按键(从现在开始被称为按键列表),以便我只是检查我的显示如果通过查看该列表来按下某个键,则该函数将被调用 问题出在SHIFT上 : 不同的按键注册为同一个物理键盘按键(例如a和A , 1和! , [和{等等))的向上和向下(取决于SHIFT是否被按下) 考虑这个(用{ key1 key2 }代表事件之后我按下的按键列表): 初始状态:{}没有按键列出按键 向下移动:{ SHIFT } 一个 DOWN:{ SHIFT A }(因为SHIFT仍然closures,大写“A”注册为关键字。 转移 :{ A } 一个 UP:{ A }(因为没有按下SHIFT键,下面的'a'作为键注册,所以a被从按下的键列表中删除(实际上不存在),并且A仍然存在) 最终状态:{ A }即使键盘上仍然没有按键。 对于阿尔法按键,我可以通过添加/删除小写键(而不是A )来解决这个问题。 但是, 1和! 或[和{ 。 glutGetModifiers在这里没有帮助。 或者如果一个按键被按下,窗口失去焦点,键被释放,窗口再次获得焦点(当窗口失去焦点时没有事件告诉键被释放)? 有没有一个通用的解决scheme来检查一个键是否被按下? (依赖于平台的解决scheme是可以的,另一个库不适合我,但是对于需要解决这个问题的其他人也是如此)
我正在尝试使用Python库pyglet加载图片的精灵。 最初的目的是与游戏有关,但我相信我已经将问题简化为一行代码。 在Python shell中,我导入pyglet,然后运行下面这行代码(或者其他的东西): pyglet.image.load("image.png") Python退出,terminal输出: Segmentation fault (core dumped) 有时它不会这样做,而是抛出 Traceback (most recent call last): File "/usr/lib/python3.4/site-packages/pyglet/__init__.py", line 351, in __getattr__ return getattr(self._module, name) AttributeError: 'NoneType' object has no attribute 'load' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.4/site-packages/pyglet/__init__.py", line […]
使用Yocto,我试图用Open GL和相应的SDK构build一个Linux映像来为这个映像构build一个应用程序。 构build应用程序时出现错误。 无法在SDK目录(/opt/poky/1.7.3)中findGL / gl.h文件。 我只有以下文件: ./sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/gstreamer-1.0/gst/gl/gl.h ./sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/GLES/gl.h ./sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/src/debug/mesa/2_10.1.3-r0/Mesa-10.1.3/include/GL/gl.h 所以GL / gl.h不在/ usr / include目录中 在Yocto构build目录中,有GL / gl.h文件: ./tmp/work/cortexa9hf-vfp-neon-mx6qdl-poky-linux-gnueabi/mesa/2_10.1.3-r0/sysroot-destdir/usr/include/GL/gl.h ./tmp/work/cortexa9hf-vfp-neon-mx6qdl-poky-linux-gnueabi/mesa/2_10.1.3-r0/packages-split/mesa-dbg/usr/src/debug/mesa/2_10.1.3-r0/梅萨-10.1.3 /包括/ GL / gl.h ./tmp/work/cortexa9hf-vfp-neon-mx6qdl-poky-linux-gnueabi/mesa/2_10.1.3-r0/packages-split/libgl-mesa-dev/usr/include/GL/gl.h ./tmp/work/cortexa9hf-vfp-neon-mx6qdl-poky-linux-gnueabi/mesa/2_10.1.3-r0/package/usr/src/debug/mesa/2_10.1.3-r0/Mesa-10.1.3/包括/ GL / gl.h ./tmp/work/cortexa9hf-vfp-neon-mx6qdl-poky-linux-gnueabi/mesa/2_10.1.3-r0/package/usr/include/GL/gl.h ./tmp/work/imx6dlgpr-poky-linux-gnueabi/gpr3/1.0-r0/sdk/image/opt/poky/1.7.3/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/src/debugging/台面/ 2_10.1.3-R0 /梅萨-10.1.3 /包括/ GL / gl.h 我使用以下命令构buildsdk: bitbake fsl-image-multimedia-full -c populate_sdk 在SDK包含目录中创buildGL / gl.h文件需要做些什么? 在我的local.conf文件中,我添加了: DISTRO_FEATURES_remove = "x11 wayland" DISTRO_FEATURES_append = " mesa-gl […]
我们有一个应用程序与多个窗口在不同的屏幕上使用3个graphics卡。 每个窗口使用opengl来渲染字体,图像等…迄今为止工作得很好,除了共享资源。 我们试图实现这样的东西(fenster是一个自定义类来存储上下文等信息): //a list of display names vector<string> displays; displays.push_back(":0.0"); displays.push_back(":0.1"); displays.push_back(":0.2"); displays.push_back(":0.3"); displays.push_back(":0.4"); //and then we loop them FOREACH(string dispName in displays): //dummy code static int dblBuf[] = {GLX_RGBA, GLX_DEPTH_SIZE, 16, GLX_DOUBLEBUFFER, None}; Display* disp; if(dispName != "default") disp = XOpenDisplay(dispName.c_str()); else disp = XOpenDisplay(NULL); if(disp == NULL) { cout << "ERROR GETING […]
我想问一下如何用mingw编译opengl。 (在Linux中)对于c ++文件我知道我可以这样做: i586-mingw32msvc-g ++ main.cpp -o main.exe 好吧。 如果我尝试用opengl项目,它给了我错误,如:glutInit'没有在这个范围内声明等.. 我复制了/ usr / i586-mingw32msvc / include / GL中的glut.h,glx.h,freeglut.h,但没有任何结果。