no-render with OpenGL --> contexts
i have a program that does some GPU computing with Optional OpenGL rendering. The use dynamic is as follow:
- init function (init GLEW being the most relevant).
- load mesh from file to GPU (use glGenBuffers are related functions to make VBO).
- process this mesh in parallel (GPU Computing API).
- save mesh into file.
my problem is that when mesh is loading i use opengl calls and wihout context created i just get segmentation fault.
Edit: Evolution of the problem:
- I was missing GL/glx.h I thought that GL/glxew.h inclu开发者_如何学编程ded it, thanks to the answers that got fixed.
- I was missing glXMakeCurrent; and therefore it was having zero contexts.
- After this fixes, it works :).
also thanks for the tools suggestions, i would gladly use them it is just that i needed the low level code for this particular case.
i tried making a context with this code ( i am using glew, so i change the header to GL/glxew.h but the rest of this code remains the same)
Don'd do it. glxew
is used for loading glx functions. You probably don't need it.
If you want to use GLEW, replace GL/gl.h
with GL/glew.h
leave GL/glx.h
as it is.
X11 and GLX are quite complex, consider using sdl of glfw instead.
Just wildly guessing here, but could it be that GLEW redefined glXChooseFBConfig with something custom? Something in the call of glXChooseFBConfig dereferences an invalid pointer. So either glXChooseFBConfig itself is invalid, or fbcount to so small, or visual_attribs not properly terminated.
GLEW has nothing to do with context creation. It is an OpenGL loading library; it loads OpenGL functions. It needs you to have an OpenGL context in order for it to function.
Since you're not really using this context for drawing stuff, I would suggest using an off-the-shelf tool for context creation. GLFW or FreeGLUT would be the most light-weight alternatives. Just use them to create a context, do what you need to do, then destroy the windows they create.
精彩评论