Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void createWindowlessOpenGLContext()
- {
- static glXCreateContextAttribsARBProc glXCreateContextAttribsARB = NULL;
- static glXMakeContextCurrentARBProc glXMakeContextCurrentARB = NULL;
- glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc) glXGetProcAddressARB( (const GLubyte *) "glXCreateContextAttribsARB" );
- glXMakeContextCurrentARB = (glXMakeContextCurrentARBProc) glXGetProcAddressARB( (const GLubyte *) "glXMakeContextCurrent" );
- CV_Assert(glXCreateContextAttribsARB != 0);
- CV_Assert(glXMakeContextCurrentARB != 0);
- const char *displayName = NULL;
- Display* display = XOpenDisplay( displayName );
- CV_Assert(display != 0);
- static int visualAttribs[] = { None };
- int numberOfFramebufferConfigurations = 0;
- GLXFBConfig* fbConfigs = glXChooseFBConfig( display, DefaultScreen(display), visualAttribs, &numberOfFramebufferConfigurations );
- CV_Assert(fbConfigs != 0);
- int context_attribs[] = {
- GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
- GLX_CONTEXT_MINOR_VERSION_ARB, 3,
- GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
- // GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB,
- // GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
- None
- };
- GLXContext openGLContext = glXCreateContextAttribsARB( display, fbConfigs[0], 0, True, context_attribs);
- int pbufferAttribs[] = {
- GLX_PBUFFER_WIDTH, 32,
- GLX_PBUFFER_HEIGHT, 32,
- None
- };
- GLXPbuffer pbuffer = glXCreatePbuffer( display, fbConfigs[0], pbufferAttribs );
- XFree( fbConfigs );
- XSync( display, False );
- if ( !glXMakeContextCurrent( display, pbuffer, pbuffer, openGLContext ) )
- {
- CV_Assert(false);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement