void exit_display() { int i; glXMakeContextCurrent(display, None, None, NULL); glXDestroyContext(display, gl_context); glXDestroyWindow(display, gl_window); glXDestroyPbuffer(display, gl_pbuffer); #ifdef USE_NV_FENCE glDeleteFencesNV(1, &nvFence); #endif XDestroyWindow(display, window); for(i = 0; i < numsurfaces; i++) { XvMCDestroySurface(display, &surfaces[i]); } XvMCDestroyBlocks(display, &blocks); XvMCDestroyMacroBlocks(display, ¯o_blocks); XvMCDestroyContext(display, &context); XvUngrabPort(display, portNum, CurrentTime); XCloseDisplay(display); }
void Window::configExit( ) { if( !_xDisplay ) return; leaveNVSwapBarrier(); configExitFBO(); exitGLEW(); glXMakeCurrent( _xDisplay, None, 0 ); GLXContext context = getGLXContext(); XID drawable = getXDrawable(); setGLXContext( 0 ); setXDrawable( 0 ); XSync( _xDisplay, False ); // WAR assert in glXDestroyContext/xcb_io.c:183 if( context ) glXDestroyContext( _xDisplay, context ); if( drawable ) { if( getIAttribute( eq::Window::IATTR_HINT_DRAWABLE ) == PBUFFER ) glXDestroyPbuffer( _xDisplay, drawable ); else XDestroyWindow( _xDisplay, drawable ); } EQINFO << "Destroyed GLX context and X drawable " << std::endl; }
~GlxDrawable() { if (pbuffer) { glXDestroyPbuffer(display, window); } else { XDestroyWindow(display, window); } }
bool QGLPixelBuffer::hasOpenGLPbuffers() { bool ret = qt_resolve_pbuffer_extensions(); if (!ret) return false; int attribs[40]; int num_configs = 0; qt_format_to_attrib_list(QGLFormat::defaultFormat(), attribs); GLXFBConfig *configs = glXChooseFBConfig(X11->display, X11->defaultScreen, attribs, &num_configs); GLXPbuffer pbuf = 0; GLXContext ctx = 0; if (configs && num_configs) { int pb_attribs[] = {GLX_PBUFFER_WIDTH, 128, GLX_PBUFFER_HEIGHT, 128, XNone}; pbuf = glXCreatePbuffer(X11->display, configs[0], pb_attribs); ctx = glXCreateNewContext(X11->display, configs[0], GLX_RGBA_TYPE, 0, true); XFree(configs); glXDestroyContext(X11->display, ctx); glXDestroyPbuffer(X11->display, pbuf); } return pbuf && ctx; }
GlxContext::~GlxContext() { // Destroy the context if (m_context) { #if defined(GLX_DEBUGGING) GlxErrorHandler handler(m_display); #endif if (glXGetCurrentContext() == m_context) glXMakeCurrent(m_display, None, NULL); glXDestroyContext(m_display, m_context); #if defined(GLX_DEBUGGING) if (glxErrorOccurred) err() << "GLX error in GlxContext::~GlxContext()" << std::endl; #endif } if (m_pbuffer) { glXDestroyPbuffer(m_display, m_pbuffer); } // Destroy the window if we own it if (m_window && m_ownsWindow) { xcb_destroy_window(m_connection, m_window); xcb_flush(m_connection); } // Close the connection with the X server CloseDisplay(m_display); }
//----------------------------------------------------------------------------// void OpenGLGLXPBTextureTarget::initialisePBuffer() { int creation_attrs[] = { GLX_PBUFFER_WIDTH, d_area.getWidth(), GLX_PBUFFER_HEIGHT, d_area.getHeight(), GLX_LARGEST_PBUFFER, True, GLX_PRESERVED_CONTENTS, True, None }; // release any existing pbuffer if (d_pbuffer) glXDestroyPbuffer(d_dpy, d_pbuffer); d_pbuffer = glXCreatePbuffer(d_dpy, d_fbconfig, creation_attrs); if (!d_pbuffer) throw RendererException("OpenGLGLXPBTextureTarget::initialisePBuffer - " "pbuffer creation error: glXCreatePbuffer() failed"); // get the real size of the buffer that was created GLuint actual_width, actual_height; glXQueryDrawable(d_dpy, d_pbuffer, GLX_WIDTH, &actual_width); glXQueryDrawable(d_dpy, d_pbuffer, GLX_HEIGHT, &actual_height); d_area.setSize(Size(actual_width, actual_height)); // ensure CEGUI::Texture is wrapping real GL texture and has correct size d_CEGUITexture->setOpenGLTexture(d_texture, d_area.getSize()); }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLX13_nglXDestroyPbuffer(JNIEnv *__env, jclass clazz, jlong displayAddress, jlong pbufAddress, jlong __functionAddress) { Display *display = (Display *)(intptr_t)displayAddress; GLXPbuffer pbuf = (GLXPbuffer)(intptr_t)pbufAddress; glXDestroyPbufferPROC glXDestroyPbuffer = (glXDestroyPbufferPROC)(intptr_t)__functionAddress; UNUSED_PARAMS(__env, clazz) glXDestroyPbuffer(display, pbuf); }
//-------------------------------------------------------------------------------------------------// GLXPBuffer::~GLXPBuffer() { glXDestroyPbuffer(mGLSupport->getGLDisplay(), mContext->mDrawable); delete mContext; LogManager::getSingleton().logMessage(LML_NORMAL, "GLXPBuffer::PBuffer destroyed"); }
void HeadlessView::destroyContext() { if (glxPbuffer) { glXDestroyPbuffer(xDisplay, glxPbuffer); glxPbuffer = 0; } glXDestroyContext(xDisplay, glContext); }
GLOffscreenBuffer::~GLOffscreenBuffer() { if (!m_context) return; glXMakeCurrent(m_display, None, None); glXDestroyContext(m_display, m_context); glXDestroyPbuffer(m_display, m_pbuffer); XCloseDisplay(m_display); }
//----------------------------------------------------------------------------// void OpenGLGLXPBTextureTarget::grabTexture() { if (d_pbuffer) { glXDestroyPbuffer(d_dpy, d_pbuffer); d_pbuffer = 0; } OpenGLTextureTarget::grabTexture(); }
void glx_context_free (GLXState * c) { glXDestroyContext (c->dpy, c->context); if (c->pbuffer) glXDestroyPbuffer (c->dpy, c->pbuffer); if (c->fbconfig) XFree (c->fbconfig); free (c); }
GLXState * glx_context_new_pbuffer (Display * dpy, int width, int height, GLXState * shared) { GLXState * c; GLXFBConfig * fbconfig; int count; GLXContext context; GLXPbuffer pbdraw; GLXContext sh_context = NULL; if (shared) sh_context = shared->context; int pb_attr[] = { GLX_PBUFFER_WIDTH, width, GLX_PBUFFER_HEIGHT, height, None }; fbconfig = glXChooseFBConfig (dpy, DefaultScreen (dpy), attr_list_pb, &count); if (fbconfig == NULL || count == 0) { fprintf (stderr, "GLX Context Error: No FBConfigs found\n"); return NULL; } pbdraw = glXCreatePbuffer (dpy, fbconfig[0], pb_attr); if (!pbdraw) { fprintf (stderr, "GLX Context Error: Failed to create Pbuffer\n"); XFree (fbconfig); return NULL; } context = glXCreateNewContext (dpy, fbconfig[0], GLX_RGBA_TYPE, sh_context, GL_TRUE); if (!context) { fprintf (stderr, "GLX Context Error: Failed to get GLX PB context\n"); glXDestroyPbuffer (dpy, pbdraw); XFree (fbconfig); return NULL; } c = malloc (sizeof (GLXState)); memset (c, 0, sizeof (GLXState)); c->width = width; c->height = height; c->dpy = dpy; c->fbconfig = fbconfig; c->pbuffer = pbdraw; c->context = context; return c; }
GlXOffscreenContext::~GlXOffscreenContext() { clearActive(); _ready = false; glXDestroyContext(_display, _context); glXDestroyPbuffer(_display, _pBuffer); XCloseDisplay(_display); }
PBuffer::~PBuffer() { /// Release resources mBoundTextures.clear(); mBoundVertexStream.release(); /// Finally, destroy the buffer Display *dpy = GLEngine::getInstance().getDisplay(); if(mContext) glXDestroyContext(dpy, mContext); if(mPBuffer) glXDestroyPbuffer(dpy, mPBuffer); }
GLOffscreenBuffer::GLOffscreenBuffer(unsigned width, unsigned height) : m_width(width) , m_height(height) , m_display(XOpenDisplay(0)) , m_pbuffer(0) , m_context(0) { if (!m_display) { std::cerr << "Error: XOpenDisplay()\n"; return; } static const int configAttributes[] = { GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT, GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_RED_SIZE, 8, GLX_GREEN_SIZE, 8, GLX_BLUE_SIZE, 8, GLX_ALPHA_SIZE, 8, GLX_DOUBLEBUFFER, GL_FALSE, 0 }; int configCount; GLXFBConfig* config = glXChooseFBConfig(m_display, 0, configAttributes, &configCount); if (!configCount) { std::cerr << "Error: glXChooseFBConfig()\n"; XFree(config); XCloseDisplay(m_display); return; } static const int pbufferAttributes[] = { GLX_PBUFFER_WIDTH, static_cast<int>(width), GLX_PBUFFER_HEIGHT, static_cast<int>(height), 0 }; m_pbuffer = glXCreatePbuffer(m_display, config[0], pbufferAttributes); if (!m_pbuffer) { std::cerr << "Error: glXCreatePbuffer()\n"; XFree(config); XCloseDisplay(m_display); return; } m_context = glXCreateNewContext(m_display, config[0], GLX_RGBA_TYPE, 0, GL_TRUE); XFree(config); if (!m_context) { std::cerr << "Error: glXCreateNewContext()\n"; glXDestroyPbuffer(m_display, m_pbuffer); XCloseDisplay(m_display); return; } }
void GraphicsContext::releaseGLSystem() { glXMakeContextCurrent(m_display, None, None, NULL); if (m_context) glXDestroyContext(m_display, m_context); if (m_pbuffer) glXDestroyPbuffer(m_display, m_pbuffer); if (m_window) glXDestroyWindow(m_display, m_window); }
void DestroyPbuffer(Display *dpy, int screen, PBUFFER pbuffer) { int pbSupport = QueryPbuffers(dpy, screen); #if defined(GLX_VERSION_1_3) if (pbSupport == 1) { glXDestroyPbuffer(dpy, pbuffer); return; } #endif #if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer) if (pbSupport == 2) { glXDestroyGLXPbufferSGIX(dpy, pbuffer); return; } #endif }
P3DGLMemoryContextPBuffer::~P3DGLMemoryContextPBuffer () { if (Ok) { glXDestroyContext(Connection,OffScreenGLXContext); glXDestroyPbuffer(Connection,PBuffer); } if (OwnConnection) { if (Connection != NULL) { XCloseDisplay(Connection); } } }
void XvMCTextures::DeInit(void) { VERBOSE(VB_IMPORTANT, LOC + "DeInit"); if (!XJ_disp) return; // already called X11L; glXMakeContextCurrent(XJ_disp, None, None, NULL); glXDestroyContext(XJ_disp, glx_context); glx_context = 0; glXDestroyWindow( XJ_disp, glx_window); glx_window = 0; glXDestroyPbuffer(XJ_disp, glx_pbuffer); glx_pbuffer = 0; XDestroyWindow( XJ_disp, gl_window); gl_window = 0; gl_vid_textures.clear(); gl_osd_textures.clear(); XJ_disp = NULL; X11U; }
void SnapshotTaker::cleanupContext(void) { if (pbuffer != 0) { glXDestroyPbuffer(display, pbuffer); pbuffer = 0; } if (context != NULL) { glXDestroyContext(display, context); context = NULL; } if (display != NULL) { XCloseDisplay(display); display = NULL; } }
HeadlessView::~HeadlessView() { activate(); clearBuffers(); deactivate(); #if MBGL_USE_CGL CGLDestroyContext(glContext); #endif #if MBGL_USE_GLX if (glxPbuffer) { glXDestroyPbuffer(xDisplay, glxPbuffer); glxPbuffer = 0; } glXDestroyContext(xDisplay, glContext); #endif }
static int cleanup(void) { #if USE_OSMESA OSMesaDestroyContext(context); free(pbuffer); #elif USE_CGL (void)CGLDestroyContext(context); (void)CGLDestroyPBuffer(pbuffer); #elif USE_GLX display = XOpenDisplay(NULL); glXDestroyPbuffer(display, pbuffer); XCloseDisplay(display); #else /* TODO: cleanup pbuffer and OpenGL context */ #endif return 0; }
DECLEXPORT(EGLBoolean) eglDestroySurface(EGLDisplay hDisplay, EGLSurface hSurface) { Display *pDisplay = (Display *)hDisplay; if (!VALID_PTR(hDisplay)) return setEGLError(EGL_NOT_INITIALIZED); switch ((GLXDrawable)hSurface & VBEGL_ANY_SURFACE) { case VBEGL_WINDOW_SURFACE: glXDestroyWindow(pDisplay, (GLXWindow)hSurface & ~VBEGL_WINDOW_SURFACE); return clearEGLError(); case VBEGL_PBUFFER_SURFACE: glXDestroyPbuffer(pDisplay, (GLXPbuffer)hSurface & ~VBEGL_PBUFFER_SURFACE); return clearEGLError(); case VBEGL_PIXMAP_SURFACE: glXDestroyPixmap(pDisplay, (GLXPixmap)hSurface & ~VBEGL_PIXMAP_SURFACE); return clearEGLError(); default: return setEGLError(EGL_BAD_SURFACE); } }
void CPBO::Destroy (void) { if (m_info.hBuf) { #ifdef _WIN32 Release (); if (m_info.hRC) wglDeleteContext (m_info.hRC); if (m_info.hDC) wglReleasePbufferDCARB (m_info.hBuf, m_info.hDC); wglDestroyPbufferARB (m_info.hBuf); #else //!_WIN32 if (m_info.hRC) glXDestroyContext (m_info.hDC, m_info.hRC); if (m_info.hBuf) glXDestroyPbuffer (m_info.hDC, m_info.hBuf); #endif //!_WIN32 glDeleteTextures (1, &m_info.texId); m_info.hRC = NULL; m_info.hDC = NULL; m_info.hBuf = NULL; } }
void OglDestroyPBuffer (tPixelBuffer *pb) { if (pb->hBuf) { #ifdef _WIN32 wglReleaseTexImageARB (pb->hBuf, WGL_FRONT_LEFT_ARB); if (pb->hRC) wglDeleteContext (pb->hRC); if (pb->hDC) wglReleasePbufferDCARB (pb->hBuf, pb->hDC); wglDestroyPbufferARB (pb->hBuf); #else //!_WIN32 if (pb->hRC) glXDestroyContext (pb->hDC, pb->hRC); if (pb->hBuf) glXDestroyPbuffer (pb->hDC, pb->hBuf); #endif //!_WIN32 OglDeleteTextures (1, &pb->texId); pb->hRC = NULL; pb->hDC = NULL; pb->hBuf = NULL; } }
bool P3DGLMemoryContextPBuffer::Create (unsigned int Width, unsigned int Height, bool NeedAlpha) { bool Result; GLXFBConfig *FBConfigList; int FBConfigCount; Result = true; if (Connection == NULL) { OwnConnection = true; Connection = XOpenDisplay(NULL); if (Connection == NULL) { return(false); } } else { OwnConnection = false; } Result = true; FBConfigList = glXChooseFBConfig( Connection, DefaultScreen(Connection), NeedAlpha ? FBAttrsAlphaArray : FBAttrsArray, &FBConfigCount); if (FBConfigList != NULL) { int AttrList[8]; AttrList[0] = GLX_PBUFFER_WIDTH; AttrList[1] = Width; AttrList[2] = GLX_PBUFFER_HEIGHT; AttrList[3] = Height; AttrList[4] = GLX_PRESERVED_CONTENTS; AttrList[5] = True; AttrList[6] = None; AttrList[7] = None; PBuffer = glXCreatePbuffer(Connection,FBConfigList[0],AttrList); /*FIXME: check for errors here */ OffScreenGLXContext = glXCreateNewContext(Connection,FBConfigList[0],GLX_RGBA_TYPE,NULL,True); if (OffScreenGLXContext != NULL) { Ok = true; Result = MakeCurrent(); if (Result) { Result = P3DGLExtInit(); } Ok = Result; } else { Result = false; } if (!Result) { glXDestroyPbuffer(Connection,PBuffer); } XFree(FBConfigList); } else { Result = false; } if (!Result) { if (OwnConnection) { XCloseDisplay(Connection); } Connection = NULL; } Ok = Result; return(Result); }
//----------------------------------------------------------------------------// OpenGLGLXPBTextureTarget::~OpenGLGLXPBTextureTarget() { if (d_pbuffer) glXDestroyPbuffer(d_dpy, d_pbuffer); }
int main() { #ifdef USE_EGL EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY); if( d ) printf("eglGetDisplay success!\n"); else printf("eglGetDisplay failed!\n"); int maj, min; if( eglInitialize(d, &maj, &min) ) printf("eglInitialize success!\n"); else printf("eglInitialize failed!\n"); printf("EGL version = %d.%d\n", maj, min); printf("EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR)); EGLConfig first_config; EGLint numConfigs; eglGetConfigs(d, &first_config, 1, &numConfigs); if( eglBindAPI(EGL_OPENGL_API) ) printf("eglBindAPI success!\n"); else printf("eglBindAPI failed!\n"); EGLContext ctx = eglCreateContext(d, first_config, EGL_NO_CONTEXT, NULL); if (ctx != EGL_NO_CONTEXT) printf("create context success!\n"); else printf("create context failed!\n"); const EGLint pbufAttribs[] = { EGL_WIDTH, width, EGL_HEIGHT, height, EGL_NONE }; EGLSurface pbuffer = eglCreatePbufferSurface(d, first_config, pbufAttribs); if (pbuffer == EGL_NO_SURFACE) { printf("failed to create pbuffer!\n"); return 0; } EGLBoolean b = eglMakeCurrent(d, pbuffer, pbuffer, ctx); if (b) printf("make current success!\n"); else printf("make current failed!\n"); #else typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*); typedef Bool (*glXMakeContextCurrentARBProc)(Display*, GLXDrawable, GLXDrawable, GLXContext); static glXCreateContextAttribsARBProc glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc) glXGetProcAddressARB( (const GLubyte *)"glXCreateContextAttribsARB"); static glXMakeContextCurrentARBProc glXMakeContextCurrentARB = (glXMakeContextCurrentARBProc) glXGetProcAddressARB( (const GLubyte *)"glXMakeContextCurrent"); if(!glXCreateContextAttribsARB) std::cout << "glXGetProcAddressARB \"glXCreateContextAttribsARB\" failed!\n"; if(!glXMakeContextCurrentARB) std::cout << "glXGetProcAddressARB \"glXMakeContextCurrentARB\" failed!\n"; const char *displayName = NULL; Display* display = XOpenDisplay( displayName ); if(!display) std::cout << "XOpenDisplay failed!\n"; static int visualAttribs[] = { None }; int numberOfFramebufferConfigurations = 0; GLXFBConfig* fbConfigs = glXChooseFBConfig( display, DefaultScreen(display), visualAttribs, &numberOfFramebufferConfigurations ); if(!fbConfigs) std::cout << "glXChooseFBConfig failed!\n"; int context_attribs[] = { None }; GLXContext openGLContext = glXCreateContextAttribsARB( display, fbConfigs[0], 0, True, context_attribs); if(!openGLContext) std::cout << "glXCreateContextAttribsARB failed!\n"; int pbufferAttribs[] = { GLX_PBUFFER_WIDTH, width, GLX_PBUFFER_HEIGHT, height, None }; GLXPbuffer pbuffer = glXCreatePbuffer( display, fbConfigs[0], pbufferAttribs ); // clean up: XFree( fbConfigs ); XSync( display, False ); if ( !glXMakeContextCurrent( display, pbuffer, pbuffer, openGLContext ) ){ std::cout << "glXMakeContextCurrent failed!\n"; } #endif std::cout << "OpenGL Version: " << glGetString(GL_VERSION) << ".\n"; draw_and_save(); #ifdef USE_EGL eglDestroySurface(d, pbuffer); eglDestroyContext(d, ctx); eglTerminate(d); #else glXDestroyPbuffer( display, pbuffer ); glXDestroyContext( display, openGLContext ); #endif return 0; }
WindowLessGLContext::~WindowLessGLContext() { glXDestroyPbuffer(dpy, pbuf); glXDestroyContext(dpy, ctx); XCloseDisplay(dpy); }