JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WGLARBPbuffer_nwglReleasePbufferDCARB(JNIEnv *__env, jclass clazz, jlong pbufferAddress, jlong hdcAddress, jlong __functionAddress) { HPBUFFERARB pbuffer = (HPBUFFERARB)(intptr_t)pbufferAddress; HDC hdc = (HDC)(intptr_t)hdcAddress; wglReleasePbufferDCARBPROC wglReleasePbufferDCARB = (wglReleasePbufferDCARBPROC)(intptr_t)__functionAddress; UNUSED_PARAMS(__env, clazz) return (jint)wglReleasePbufferDCARB(pbuffer, hdc); }
void RenderTexture::Shutdown() { if (m_texID) { glDeleteTextures( 1, &m_texID ); m_texID = 0; } if (m_FBO) { glDeleteFramebuffersEXT(1, &m_frameBuffer); glDeleteRenderbuffersEXT(1, &m_depthRenderBuffer); } else { wglMakeCurrent(m_hDC, m_hRC); // Don't forget to clean up after our pixelbuffer... wglReleasePbufferDCARB(m_hPBuffer, m_hDC); wglDestroyPbufferARB(m_hPBuffer); if(m_hRC) { wglDeleteContext(m_hRC); m_hRC = NULL; } wglMakeCurrent(canvas_hDC, canvas_hRC); } }
void Win32PBuffer::destroyPBuffer() { wglDeleteContext(mGlrc); // FIXME lookup procaddress #if 0 wglReleasePbufferDCARB(mPBuffer,mHDC); wglDestroyPbufferARB(mPBuffer); #endif }
//----------------------------------------------------------------------------// void OpenGLWGLPBTextureTarget::releasePBuffer() { if (d_pbuffer) { wglDeleteContext(d_context); wglReleasePbufferDCARB(d_pbuffer, d_hdc); wglDestroyPbufferARB(d_pbuffer); } }
cPBuffer::~cPBuffer() { #ifdef WIN32 //This should not be deleted if it is shared. wglDeleteContext(mGLContext); wglReleasePbufferDCARB(mPBuffer, mDeviceContext); wglDestroyPbufferARB(mPBuffer); #elif defined(__linux__) #endif }
void pbf_destroy(pbf p) { if (p) { if (p->isValid) { wglDeleteContext(p->rc); wglReleasePbufferDCARB(p->pBuffer, p->dc); wglDestroyPbufferARB(p->pBuffer); } free(p); } }
static void tear_down_pbuffer(void) { #ifdef WIN32 wglDeleteContext(pbuffer_wgl_context); wglReleasePbufferDCARB(pbuffer, pbuffer_hdc); wglDestroyPbufferARB(pbuffer); #else assert(0); #endif }
void PBuffer::free() { if ( m_hpbuffer ) { // Check if we are currently rendering in the pbuffer if (wglGetCurrentContext() == m_hglrc ) wglMakeCurrent(0,0); // delete the pbuffer context wglDeleteContext( m_hglrc ); wglReleasePbufferDCARB( m_hpbuffer, m_hdc ); wglDestroyPbufferARB( m_hpbuffer ); m_hpbuffer = 0; } }
void pbf_restore(pbf p) { int lost = 0; if (p->isValid) { /* * Check to see if pbuffer memory was lost due to a display * mode change. */ wglQueryPbufferARB(p->pBuffer, WGL_PBUFFER_LOST_ARB, &lost); if (lost) { wglDeleteContext(p->rc); wglReleasePbufferDCARB(p->pBuffer, p->dc); wglDestroyPbufferARB(p->pBuffer); pbf_init(p, p->width, p->height, p->mode, p->share); } } }
P3DGLMemoryContextPBuffer::~P3DGLMemoryContextPBuffer () { if (GLContext != NULL) { wglDeleteContext(GLContext); } if (PBufferDC != NULL) { wglReleasePbufferDCARB(PBufferHandle,PBufferDC); } if (PBufferHandle != NULL) { wglDestroyPbufferARB(PBufferHandle); } }
void GLPBuffer::destroy() { Logger::writeInfoLog("Destroying pixel buffer"); if (renderingContext) { if (!wglDeleteContext(renderingContext)) { Logger::writeErrorLog("Release of Pbuffer Rendering Context Failed"); } renderingContext =NULL; } if (deviceContext && !wglReleasePbufferDCARB(pBufferHandle , deviceContext)) { Logger::writeErrorLog("Release of Pbuffer Device Context Failed"); deviceContext =NULL; } if (!wglDestroyPbufferARB(pBufferHandle)) { Logger::writeErrorLog("Unable to destroy pbuffer"); } }
void PBUFFER::Shutdown(void) { if(hRC) //have a rendering context? { if(!wglDeleteContext(hRC)) //try to delete RC { LOG::Instance()->OutputError("Release of Pbuffer Rendering Context Failed."); } hRC=NULL; } if(hDC && !wglReleasePbufferDCARB(hBuffer, hDC)) //Are we able to release DC? { LOG::Instance()->OutputError("Release of Pbuffer Device Context Failed."); hDC=NULL; } if(!wglDestroyPbufferARB(hBuffer)) { LOG::Instance()->OutputError("Unable to destroy pbuffer"); } }
OGLRenderTexture2D_ARB::~OGLRenderTexture2D_ARB() { wglDeleteContext( mPixelBuffer.mRC ); wglReleasePbufferDCARB( mPixelBuffer.mPBuffer, mPixelBuffer.mDC ); wglDestroyPbufferARB( mPixelBuffer.mPBuffer ); }
static void pbuffer_releasedc(windowsDrawable *d, HDC dc) { wglReleasePbufferDCARB(d->hPbuffer, dc); }
void Win32PBuffer::createPBuffer() { // Process format int bits=0; bool isFloat=false; #if 0 bool hasAlpha=true; #endif switch(mFormat) { case PCT_BYTE: bits=8; isFloat=false; break; case PCT_SHORT: bits=16; isFloat=false; break; case PCT_FLOAT16: bits=16; isFloat=true; break; case PCT_FLOAT32: bits=32; isFloat=true; break; default: break; }; LogManager::getSingleton().logMessage( " Win32PBuffer::Creating PBuffer of format bits="+ StringConverter::toString(bits)+ " float="+StringConverter::toString(isFloat) ); HDC old_hdc = wglGetCurrentDC(); HGLRC old_context = wglGetCurrentContext(); // Bind to RGB or RGBA texture int bttype = 0; #if 0 if(mUseBind) { // Only provide bind type when actually binding bttype = PixelUtil::hasAlpha(mInternalFormat)? WGL_BIND_TO_TEXTURE_RGBA_ARB : WGL_BIND_TO_TEXTURE_RGB_ARB; } int texformat = hasAlpha? WGL_TEXTURE_RGBA_ARB : WGL_TEXTURE_RGB_ARB; #endif // Make a float buffer? int pixeltype = isFloat? WGL_TYPE_RGBA_FLOAT_ARB: WGL_TYPE_RGBA_ARB; int attrib[] = { WGL_RED_BITS_ARB,bits, WGL_GREEN_BITS_ARB,bits, WGL_BLUE_BITS_ARB,bits, WGL_ALPHA_BITS_ARB,bits, WGL_STENCIL_BITS_ARB,1, WGL_DEPTH_BITS_ARB,15, WGL_DRAW_TO_PBUFFER_ARB,true, WGL_SUPPORT_OPENGL_ARB,true, WGL_PIXEL_TYPE_ARB,pixeltype, //WGL_DOUBLE_BUFFER_ARB,true, //WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB, // Make sure it is accelerated bttype,true, // must be last, as bttype can be zero 0 }; int pattrib_default[] = { 0 }; #if 0 int pattrib_bind[] = { WGL_TEXTURE_FORMAT_ARB, texformat, WGL_TEXTURE_TARGET_ARB, WGL_TEXTURE_2D_ARB, WGL_PBUFFER_LARGEST_ARB, true, 0 }; #endif int format; unsigned int count; // Choose suitable pixel format wglChoosePixelFormatARB(old_hdc,attrib,NULL,1,&format,&count); if(count == 0) OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "wglChoosePixelFormatARB() failed", " Win32PBuffer::createPBuffer"); // Analyse pixel format const int piAttributes[]={ WGL_RED_BITS_ARB,WGL_GREEN_BITS_ARB,WGL_BLUE_BITS_ARB,WGL_ALPHA_BITS_ARB, WGL_DEPTH_BITS_ARB,WGL_STENCIL_BITS_ARB }; int piValues[sizeof(piAttributes)/sizeof(const int)]; wglGetPixelFormatAttribivARB(old_hdc,format,0,sizeof(piAttributes)/sizeof(const int),piAttributes,piValues); LogManager::getSingleton().stream() << " Win32PBuffer::PBuffer -- Chosen pixel format rgba=" << piValues[0] << "," << piValues[1] << "," << piValues[2] << "," << piValues[3] << " depth=" << piValues[4] << " stencil=" << piValues[5]; mPBuffer = wglCreatePbufferARB(old_hdc,format,mWidth,mHeight,pattrib_default); if(!mPBuffer) OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "wglCreatePbufferARB() failed", " Win32PBuffer::createPBuffer"); mHDC = wglGetPbufferDCARB(mPBuffer); if(!mHDC) { wglDestroyPbufferARB(mPBuffer); OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "wglGetPbufferDCARB() failed", " Win32PBuffer::createPBuffer"); } mGlrc = wglCreateContext(mHDC); if(!mGlrc) { wglReleasePbufferDCARB(mPBuffer,mHDC); wglDestroyPbufferARB(mPBuffer); OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "wglCreateContext() failed", " Win32PBuffer::createPBuffer"); } if(!wglShareLists(old_context,mGlrc)) { wglDeleteContext(mGlrc); wglReleasePbufferDCARB(mPBuffer,mHDC); wglDestroyPbufferARB(mPBuffer); OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "wglShareLists() failed", " Win32PBuffer::createPBuffer"); } // Query real width and height int iWidth, iHeight; wglQueryPbufferARB(mPBuffer, WGL_PBUFFER_WIDTH_ARB, &iWidth); wglQueryPbufferARB(mPBuffer, WGL_PBUFFER_HEIGHT_ARB, &iHeight); mWidth = iWidth; mHeight = iHeight; LogManager::getSingleton().stream() << "Win32RenderTexture::PBuffer created -- Real dimensions " << mWidth << "x" << mHeight; }
void Win32PBuffer::destroyPBuffer() { wglDeleteContext(mGlrc); wglReleasePbufferDCARB(mPBuffer,mHDC); wglDestroyPbufferARB(mPBuffer); }
void ObjMeshGPUDeformer_uUq_pbuffer::DeleteRTT() { wglDeleteContext(pbuffer.hRC); wglReleasePbufferDCARB( pbuffer.hPBuffer, pbuffer.hDC ); wglDestroyPbufferARB( pbuffer.hPBuffer ); }
RenderTarget::~RenderTarget(void) { wglReleasePbufferDCARB(pb, dc); wglDestroyPbufferARB(pb); }
BOOL WINAPI wglBindTexImageARB(HPBUFFERARB hPbuffer, int iBuffer) { HDC prevDrawable = stw_get_current_dc(); HDC prevReadable = stw_get_current_read_dc(); HDC dc; struct stw_context *curctx = stw_current_context(); struct stw_framebuffer *fb; GLenum texFormat, srcBuffer, target; boolean retVal; int pixelFormatSave; /* * Implementation notes: * Ideally, we'd implement this function with the * st_context_iface::teximage() function which replaces a specific * texture image with a different resource (the pbuffer). * The main problem however, is the pbuffer image is upside down relative * to the texture image. * Window system drawing surfaces (windows & pbuffers) are "top to bottom" * while OpenGL texture images are "bottom to top". One possible solution * to this is to invert rendering to pbuffers (as we do for renderbuffers) * but that could lead to other issues (and would require extensive * testing). * * The simple alternative is to use a copy-based approach which copies the * pbuffer image into the texture via glCopyTex[Sub]Image. That's what * we do here. */ if (!curctx) { debug_printf("No rendering context in wglBindTexImageARB()\n"); SetLastError(ERROR_INVALID_OPERATION); return FALSE; } fb = stw_framebuffer_from_HPBUFFERARB(hPbuffer); if (!fb) { debug_printf("Invalid pbuffer handle in wglBindTexImageARB()\n"); SetLastError(ERROR_INVALID_HANDLE); return FALSE; } srcBuffer = translate_ibuffer(iBuffer); if (srcBuffer == GL_NONE) { debug_printf("Invalid buffer 0x%x in wglBindTexImageARB()\n", iBuffer); SetLastError(ERROR_INVALID_DATA); return FALSE; } target = translate_target(fb->textureTarget); if (target == GL_NONE) { debug_printf("no texture target in wglBindTexImageARB()\n"); return FALSE; } texFormat = translate_texture_format(fb->textureFormat); if (texFormat == GL_NONE) { debug_printf("no texture format in wglBindTexImageARB()\n"); return FALSE; } /* * Bind the pbuffer surface so we can read/copy from it. * * Before we can call stw_make_current() we have to temporarily * change the pbuffer's pixel format to match the context to avoid * an error condition. After the stw_make_current() we restore the * buffer's pixel format. */ pixelFormatSave = fb->iPixelFormat; fb->iPixelFormat = curctx->iPixelFormat; dc = wglGetPbufferDCARB(hPbuffer); retVal = stw_make_current(dc, dc, curctx->dhglrc); fb->iPixelFormat = pixelFormatSave; if (!retVal) { debug_printf("stw_make_current(#1) failed in wglBindTexImageARB()\n"); wglReleasePbufferDCARB(hPbuffer, dc); return FALSE; } st_copy_framebuffer_to_texture(srcBuffer, fb->width, fb->height, target, fb->textureLevel, fb->textureFace, texFormat); /* rebind previous drawing surface */ retVal = stw_make_current(prevDrawable, prevReadable, curctx->dhglrc); if (!retVal) { debug_printf("stw_make_current(#2) failed in wglBindTexImageARB()\n"); } wglReleasePbufferDCARB(hPbuffer, dc); return retVal; }
void PixelBuffer::destroy(void) { wglReleaseTexImageARB(pb, WGL_FRONT_LEFT_ARB); wglReleasePbufferDCARB(pb, dc); wglDestroyPbufferARB(pb); }
void pbf_init(pbf p, int w, int h, int mode, bool share) { int iattribs[2*MAX_ATTRIBS]; float fattribs[2*MAX_ATTRIBS]; int pformat[MAX_PFORMATS]; int nfattribs = 0; int niattribs = 0; unsigned int nformats; int format; HDC dc = wglGetCurrentDC(); HGLRC rc = wglGetCurrentContext(); if (p) { memset(p, 0, sizeof(struct pbf_str)); memset(iattribs, 0, sizeof(iattribs)); memset(fattribs, 0, sizeof(fattribs)); p->width = w; p->height = h; p->mode = mode; p->share = share; p->glutWin = glutGetWindow(); p->glutWinDc = dc; p->glutWinRc = rc; p->isValid = false; /* pBuffer pixel format must be "p-buffer capable" */ iattribs[2*niattribs ] = WGL_DRAW_TO_PBUFFER_ARB; iattribs[2*niattribs + 1] = true; niattribs++; if (mode & GLUT_INDEX) { iattribs[2*niattribs ] = WGL_PIXEL_TYPE_ARB; iattribs[2*niattribs + 1] = WGL_TYPE_COLORINDEX_ARB; niattribs++; } else { iattribs[2*niattribs ] = WGL_PIXEL_TYPE_ARB; iattribs[2*niattribs + 1] = WGL_TYPE_RGBA_ARB; niattribs++; } if (mode & GLUT_DOUBLE) { iattribs[2*niattribs ] = WGL_DOUBLE_BUFFER_ARB; iattribs[2*niattribs + 1] = true; niattribs++; } if (mode & GLUT_DEPTH) { iattribs[2*niattribs ] = WGL_DEPTH_BITS_ARB; iattribs[2*niattribs + 1] = true; niattribs++; } if (mode & GLUT_STENCIL) { iattribs[2*niattribs ] = WGL_STENCIL_BITS_ARB; iattribs[2*niattribs + 1] = true; niattribs++; } if (mode & GLUT_ACCUM) { iattribs[2*niattribs ] = WGL_ACCUM_BITS_ARB; iattribs[2*niattribs + 1] = true; niattribs++; } iattribs[2*niattribs ] = WGL_SUPPORT_OPENGL_ARB; iattribs[2*niattribs + 1] = true; niattribs++; if (!wglChoosePixelFormatARB( dc, iattribs, fattribs, MAX_PFORMATS, pformat, &nformats)) return; format = pformat[0]; iattribs[0] = 0; p->pBuffer = wglCreatePbufferARB( dc, format, w, h, iattribs); if (!p->pBuffer) return; p->dc = wglGetPbufferDCARB(p->pBuffer); if (!p->dc) { wglDestroyPbufferARB(p->pBuffer); return; } p->rc = wglCreateContext(p->dc); if (!p->rc) { wglReleasePbufferDCARB(p->pBuffer, p->dc); wglDestroyPbufferARB(p->pBuffer); return; } if (share) { if(!wglShareLists(rc, p->rc)) p->share = false; } /* Determine actual width and height */ wglQueryPbufferARB(p->pBuffer, WGL_PBUFFER_WIDTH_ARB, &p->width); wglQueryPbufferARB(p->pBuffer, WGL_PBUFFER_HEIGHT_ARB, &p->height); p->isValid = true; } }