Ejemplo n.º 1
0
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);
	}
}
Ejemplo n.º 2
0
    void Win32PBuffer::destroyPBuffer() 
    {
        wglDeleteContext(mGlrc);
        // FIXME lookup procaddress
#if 0
        wglReleasePbufferDCARB(mPBuffer,mHDC);
        wglDestroyPbufferARB(mPBuffer);
#endif
    }
Ejemplo n.º 3
0
//----------------------------------------------------------------------------//
void OpenGLWGLPBTextureTarget::releasePBuffer()
{
    if (d_pbuffer)
    {
        wglDeleteContext(d_context);
        wglReleasePbufferDCARB(d_pbuffer, d_hdc);
        wglDestroyPbufferARB(d_pbuffer);
    }
}
Ejemplo n.º 4
0
	cPBuffer::~cPBuffer()
	{
		#ifdef WIN32
		//This should not be deleted if it is shared.
		wglDeleteContext(mGLContext);				
		wglReleasePbufferDCARB(mPBuffer, mDeviceContext);
		wglDestroyPbufferARB(mPBuffer);
		#elif defined(__linux__)
		#endif
	}
Ejemplo n.º 5
0
void pbf_destroy(pbf p)
{
	if (p) {
		if (p->isValid) {
			wglDeleteContext(p->rc);
			wglReleasePbufferDCARB(p->pBuffer, p->dc);
			wglDestroyPbufferARB(p->pBuffer);
		}
		free(p);
	}
}
Ejemplo n.º 6
0
static void
tear_down_pbuffer(void)
{
#ifdef WIN32
	wglDeleteContext(pbuffer_wgl_context);

	wglReleasePbufferDCARB(pbuffer, pbuffer_hdc);

	wglDestroyPbufferARB(pbuffer);
#else
	assert(0);
#endif
}
Ejemplo n.º 7
0
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;
    }
}
Ejemplo n.º 8
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);
		}
	}
}
Ejemplo n.º 9
0
                   P3DGLMemoryContextPBuffer::~P3DGLMemoryContextPBuffer
                                      ()
 {
  if (GLContext != NULL)
   {
    wglDeleteContext(GLContext);
   }

  if (PBufferDC != NULL)
   {
    wglReleasePbufferDCARB(PBufferHandle,PBufferDC);
   }

  if (PBufferHandle != NULL)
   {
    wglDestroyPbufferARB(PBufferHandle);
   }
 }
Ejemplo n.º 10
0
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");
  }
}
Ejemplo n.º 11
0
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 );
}
Ejemplo n.º 13
0
	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;
	}
Ejemplo n.º 14
0
	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 );
}
Ejemplo n.º 16
0
RenderTarget::~RenderTarget(void)
{
    wglReleasePbufferDCARB(pb, dc);
    wglDestroyPbufferARB(pb);
}
Ejemplo n.º 17
0
		void PixelBuffer::destroy(void)
		{
			wglReleaseTexImageARB(pb, WGL_FRONT_LEFT_ARB);
		    wglReleasePbufferDCARB(pb, dc);
			wglDestroyPbufferARB(pb);
		}
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WGLARBPbuffer_nwglDestroyPbufferARB(JNIEnv *__env, jclass clazz, jlong pbufferAddress, jlong __functionAddress) {
	HPBUFFERARB pbuffer = (HPBUFFERARB)(intptr_t)pbufferAddress;
	wglDestroyPbufferARBPROC wglDestroyPbufferARB = (wglDestroyPbufferARBPROC)(intptr_t)__functionAddress;
	UNUSED_PARAMS(__env, clazz)
	return (jint)wglDestroyPbufferARB(pbuffer);
}
Ejemplo n.º 19
0
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;
	}
}