Пример #1
0
/**
 * Deattaches an attachment from the framebuffer
 */
void FBO::Unattach(const GLenum attachment)
{
	GLuint target;
	glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT, attachment,
		GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT,
		(GLint*)&target);

	if (target==GL_RENDERBUFFER_EXT) {
		//! check if the RBO was created via FBO::CreateRenderBuffer()
		GLuint id;
		glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT, attachment,
			GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT,
			(GLint*)&id);

		glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attachment, GL_RENDERBUFFER_EXT, 0);

		for (std::vector<GLuint>::iterator ri=myRBOs.begin(); ri!=myRBOs.end(); ++ri) {
			if (*ri == id) {
				glDeleteRenderbuffersEXT(1, &(*ri));
				myRBOs.erase(ri);
				break;
			}
		}
	} else {
		glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_2D, 0, 0);
	}
}
Пример #2
0
void FrameBuffer::attachRBufDepth()
{
    glGenRenderbuffersEXT(1, (GLuint*)&m_shadowRBuf);
    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_shadowRBuf);
    glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, m_sizeX, m_sizeY);
    glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_shadowRBuf);
}
Пример #3
0
/* Test binding and return error code */
static GLenum
test_binding(GLboolean bindRenderbuffer)
{
   GLuint fb, rb;
   GLenum err;

   glGenFramebuffersEXT(1, &fb);
   glGenRenderbuffersEXT(1, &rb);
   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);

   err = glGetError();
   if (err != GL_NO_ERROR)
      return PIGLIT_FAIL;

   /* enabling this should prevent the GL error */
   if (bindRenderbuffer)
      glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);

   glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
                                GL_RENDERBUFFER_EXT, rb);

   err = glGetError();

   return err;
}
Пример #4
0
void fbo_destroy(FBO *fbo) {
	if (fbo->native_fbo) {
		delete fbo;
		return;
	}

	if (gl_extensions.ARB_framebuffer_object || gl_extensions.IsGLES) {
		glBindFramebuffer(GL_FRAMEBUFFER, fbo->handle);
		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
		glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0);
		glBindFramebuffer(GL_FRAMEBUFFER, 0);
		glDeleteFramebuffers(1, &fbo->handle);
		glDeleteRenderbuffers(1, &fbo->z_stencil_buffer);
		glDeleteRenderbuffers(1, &fbo->z_buffer);
		glDeleteRenderbuffers(1, &fbo->stencil_buffer);
	} else if (gl_extensions.EXT_framebuffer_object) {
#ifndef USING_GLES2
		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo->handle);
		glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
		glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER_EXT, 0);
		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
		glDeleteFramebuffersEXT(1, &fbo->handle);
		glDeleteRenderbuffersEXT(1, &fbo->z_stencil_buffer);
#endif
	}

	currentDrawHandle_ = 0;
	currentReadHandle_ = 0;

	glDeleteTextures(1, &fbo->color_texture);
	delete fbo;
}
Пример #5
0
void initFBO(GLuint& fbo, GLuint& depthBuffer, GLuint& img) {																											
	// Setup our FBO
	width = gw; height = gh;
    glGenFramebuffersEXT(1, &fbo);

	// bind for set up
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);

	// Now setup a texture to render to
	glGenTextures(1, &img);
	glBindTexture(GL_TEXTURE_2D, img);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,  width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);		

	// And attach it to the FBO so we can render to it
	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, img, 0);
	// Create the render buffer for depth	
	glGenRenderbuffersEXT(1, &depthBuffer);
	glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthBuffer);
	glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,GL_DEPTH_COMPONENT, width, height);

	// Attach the depth render buffer to FBO as it's depth attachment
	glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthBuffer);
		
	// Checking 
	GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
	if(status != GL_FRAMEBUFFER_COMPLETE_EXT)
		exit(1);	
	// Unbind the FBO for now
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);	
}
Пример #6
0
void GL_GenerateFBO(GLuint texId, GLuint *fboId, int w, int h) {
	GLuint cRboId;
	Console_Printf("    Generate FBO %dx%d. ", w, h);
	
	glGenFramebuffersEXT(1, fboId);
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, *fboId);
	
	if(vid_multisample.integer && gl_ext_framebuffer_multisample.integer) {
		Console_Printf("(MSAA) ");
		glGenRenderbuffersEXT(1, &cRboId);
		glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, cRboId);
		
		glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, vid_multisample.integer, GL_RGBA, w, h);
		glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, cRboId);
	}

	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texId, 0);

	//glDrawBuffer(GL_FRONT);
	//glReadBuffer(GL_FRONT);

	GL_CheckFBOStatus();
	
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
Пример #7
0
void testApp::initFrameBuffer() {  
	initFrameBufferDepthBuffer(); // Initialize our frame buffer depth buffer  
	
	initFrameBufferTexture(); // Initialize our frame buffer texture  
	
	glGenFramebuffersEXT(1, &mFBOID); // Generate one frame buffer and store the ID in fbo  
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBOID); // Bind our frame buffer  
	
	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, mTextureID, 0); // Attach the texture mFBOID to the color buffer in our frame buffer  
	
	glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, mDepthID); // Attach the depth buffer mDepthID to our frame buffer  
	
	GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); // Check that status of our generated frame buffer  
	
	if (status != GL_FRAMEBUFFER_COMPLETE_EXT) // If the frame buffer does not report back as complete  
	{  
		std::cout << "Couldn't create frame buffer" << std::endl; // Output an error to the console  
		//exit(0); // Exit the application  
	}  else {
		cout << "BITCHIN " <<endl;
	}
	
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); // Unbind our frame buffer  
	
#ifdef SYPHON
	thisWillNeverWork.bAllocated = true;
	thisWillNeverWork.textureID = mTextureID;
	thisWillNeverWork.width = 640;
	thisWillNeverWork.height = 480;
	thisWillNeverWork.bFlipTexture = true;
	thisWillNeverWork.textureTarget = GL_TEXTURE_2D;
#endif
	
}  
Пример #8
0
/*
================
R_CreateFBODepthBuffer
================
*/
void R_CreateFBODepthBuffer( FBO_t *fbo, int format )
{
	qboolean absent;

	if ( format != GL_DEPTH_COMPONENT &&
	     format != GL_DEPTH_COMPONENT16 && format != GL_DEPTH_COMPONENT24 && format != GL_DEPTH_COMPONENT32_ARB )
	{
		ri.Printf( PRINT_WARNING, "R_CreateFBODepthBuffer: format %i is not depth-renderable\n", format );
		return;
	}

	fbo->depthFormat = format;

	absent = fbo->depthBuffer == 0;

	if ( absent )
	{
		glGenRenderbuffersEXT( 1, &fbo->depthBuffer );
	}

	glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, fbo->depthBuffer );
	glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, fbo->depthFormat, fbo->width, fbo->height );

	if ( absent )
	{
		glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, fbo->depthBuffer );
	}

	GL_CheckErrors();
}
Пример #9
0
GLuint* OpenGL::RayCaster::CreateRenderBuffer(const int WINDOW_SIZE_X,
                                             const int WINDOW_SIZE_Y)
{

    INFO("Creating the rendering buffer");

    GLuint* renderBuffer_ID = MEM_ALLOC_1D_GENERIC(GLuint, 1);

    // Generate the render buffer ID
    glGenRenderbuffersEXT(1, renderBuffer_ID);

    // Bnd the render buffer
    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, *renderBuffer_ID);

    // Setup the parameters of the render buffer
    glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
                             WINDOW_SIZE_X, WINDOW_SIZE_Y);

    // Attche the render buffer to the frame buffer
    glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
                                 GL_RENDERBUFFER_EXT, *renderBuffer_ID);

    // Unbind the render buffer
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

    INFO("1")
    return renderBuffer_ID;
}
Пример #10
0
void testApp::generateFrameBuffers(){
	
	// create a framebuffer object, you need to delete them when program exits.
	glGenFramebuffersEXT(1, &fboId);
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboId);

	// create a renderbuffer object to store depth info
	// NOTE: A depth renderable image should be attached the FBO for depth test.
	// If we don't attach a depth renderable image to the FBO, then
	// the rendering output will be corrupted because of missing depth test.
	// If you also need stencil test for your rendering, then you must
	// attach additional image to the stencil attachement point, too.
	glGenRenderbuffersEXT(1, &rboId);
	glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rboId);
	glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, ofGetWidth(), ofGetHeight());
	glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);

	// attach a texture to FBO color attachement point
	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, colourTextureId, 0);

	// attach a renderbuffer to depth attachment point
	glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, rboId);

	//@ disable color buffer if you don't attach any color buffer image,
	//@ for example, rendering depth buffer only to a texture.
	//@ Otherwise, glCheckFramebufferStatusEXT will not be complete.
	//glDrawBuffer(GL_NONE);
	//glReadBuffer(GL_NONE);

	// check FBO status
	printFramebufferInfo();
	bool status = checkFramebufferStatus();
	if(!status)
		fboUsed = false;
}
Пример #11
0
/*
================
R_CreateFBOStencilBuffer
================
*/
void R_CreateFBOStencilBuffer(FBO_t * fbo, int format)
{
#if defined(USE_D3D10)
	// TODO
#else
	qboolean        absent;

	if(format != GL_STENCIL_INDEX &&
	   //format != GL_STENCIL_INDEX_EXT &&
	   format != GL_STENCIL_INDEX1_EXT &&
	   format != GL_STENCIL_INDEX4_EXT && format != GL_STENCIL_INDEX8_EXT && format != GL_STENCIL_INDEX16_EXT)
	{
		ri.Printf(PRINT_WARNING, "R_CreateFBOStencilBuffer: format %i is not stencil-renderable\n", format);
		return;
	}

	fbo->stencilFormat = format;

	absent = fbo->stencilBuffer == 0;
	if(absent)
		glGenRenderbuffersEXT(1, &fbo->stencilBuffer);

	glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fbo->stencilBuffer);
	glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, fbo->stencilFormat, fbo->width, fbo->height);
	GL_CheckErrors();

	if(absent)
		glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, fbo->stencilBuffer);

	GL_CheckErrors();
#endif
}
Пример #12
0
static void Init(void)
{
   fprintf(stderr, "GL_RENDERER   = %s\n", (char *) glGetString(GL_RENDERER));
   fprintf(stderr, "GL_VERSION    = %s\n", (char *) glGetString(GL_VERSION));
   fprintf(stderr, "GL_VENDOR     = %s\n", (char *) glGetString(GL_VENDOR));
   fflush(stderr);


   if (!glutExtensionSupported("GL_EXT_framebuffer_object")) {
      printf("GL_EXT_framebuffer_object not found!\n");
      exit(0);
   }


   glGenFramebuffersEXT(1, &MyFB);
   glGenRenderbuffersEXT(1, &MyRB);

   {
      glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);

      glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, MyRB);

      glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT,
				   GL_RENDERBUFFER_EXT, MyRB);

      glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);

      glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
   }

   glClearColor(0.0, 0.0, 1.0, 0.0);
}
Пример #13
0
void fbo::initDepthBuffer(void){
	glGenRenderbuffersEXT(1, &depth_id); // Generate one render buffer and store the ID in fbo_depth
	glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_id); // Bind the fbo_depth render buffer
	glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, width, height); // Set the render buffer storage to be a depth component, with a width and height of the window
	glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_id); // Set the render buffer of this buffer to the depth buffer
	glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); // Unbind the render buffer
}
Пример #14
0
GLuint RenderTarget::initRenderToTexture()
{
#ifdef USE_FBO

  if (this->useFBO==1)
    {
      this->renderToTexture=1;
      
      GLuint   fb2, depth_rb2;
      glGenFramebuffersEXT(1, &fb2);
      glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fb2 );
      glGenRenderbuffersEXT(1, &depth_rb2);
      glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, depth_rb2 );
      
      glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, this->texsize,this->texsize  );
      glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb2 );         
      this->fbuffer[1] = fb2;
      this->depthb[1]=  depth_rb2;
      glGenTextures(1, &this->textureID[2]);
      glBindTexture(GL_TEXTURE_2D, this->textureID[2]); 
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
      glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, texsize, texsize, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
      glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, this->textureID[2], 0 );
      return this->textureID[2];
    }
#endif 
return -1;
      
}
Пример #15
0
void StimulusDisplay::allocateBufferStorage(int contextIndex) {
    if (!(glewIsSupported("GL_EXT_framebuffer_object") && glewIsSupported("GL_EXT_framebuffer_blit"))) {
        throw SimpleException("renderer does not support required OpenGL framebuffer extensions");
    }
    
    glGenFramebuffersEXT(1, &framebuffers[contextIndex]);
    glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, framebuffers[contextIndex]);
    
    glGenRenderbuffersEXT(1, &renderbuffers[contextIndex]);
    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, renderbuffers[contextIndex]);
    
    getCurrentViewportSize(bufferWidths[contextIndex], bufferHeights[contextIndex]);
    glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA8, bufferWidths[contextIndex], bufferHeights[contextIndex]);
    
    glFramebufferRenderbufferEXT(GL_DRAW_FRAMEBUFFER_EXT,
                                 GL_COLOR_ATTACHMENT0_EXT,
                                 GL_RENDERBUFFER_EXT,
                                 renderbuffers[contextIndex]);
    
    GLenum status = glCheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT);
    if (GL_FRAMEBUFFER_COMPLETE_EXT != status) {
        throw SimpleException("OpenGL framebuffer setup failed");
    }
    
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
}
Пример #16
0
static void
create_fbo(void)
{
	GLuint rb[32];
	int i;

	glGenFramebuffersEXT(1, &fbo);
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);

	glGenRenderbuffersEXT(max_ds_buffers, rb);
	check_error(__LINE__);

	for (i = 0; i < max_ds_buffers; i++) {
		glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb[i]);
		check_error(__LINE__);

		glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
					     GL_COLOR_ATTACHMENT0 + i,
					     GL_RENDERBUFFER_EXT,
					     rb[i]);
		check_error(__LINE__);

		glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA,
					 piglit_width, piglit_height);
		check_error(__LINE__);
	}
}
Пример #17
0
void PCSSShadowMap::reInit(DrawEnv *pEnv)
{
#ifdef USE_FBO_FOR_COLOR_AND_FACTOR_MAP
    Int32   width = _shadowVP->getPixelWidth();
    Int32   height = _shadowVP->getPixelHeight();

    Window *win = pEnv->getWindow();

    win->validateGLObject(_colorMap->getGLId(), pEnv);
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fb);
    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
                              GL_TEXTURE_2D,
                              win->getGLObjectId(_colorMap->getGLId()), 0);
    win->validateGLObject(_shadowFactorMap->getGLId(), pEnv);
    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT,
                              GL_TEXTURE_2D,
                              win->getGLObjectId(_shadowFactorMap->getGLId()),
                              0);

    //Initialize Depth Renderbuffer
    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, _rb_depth);
    if(_useNPOTTextures)
        glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24_ARB,
                                 _shadowVP->getPixelWidth(),
                                 _shadowVP->getPixelHeight());
    else
        glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24_ARB,
                                 _widthHeightPOT, _widthHeightPOT);
    //Attach Renderbuffer to Framebuffer depth Buffer
    glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT
                                 , _rb_depth);
#endif
}
void LLRenderTarget::release()
{
	if (mDepth)
	{
		if (mStencil)
		{
			glDeleteRenderbuffersEXT(1, (GLuint*) &mDepth);
			stop_glerror();
		}
		else
		{
			LLImageGL::deleteTextures(1, &mDepth);
			stop_glerror();
		}
		mDepth = 0;
	}
	else if (mUseDepth && mFBO)
	{ //detach shared depth buffer
		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO);
		if (mStencil)
		{ //attached as a renderbuffer
			glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
			glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
			mStencil = false;
		}
		else
		{ //attached as a texture
			glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, LLTexUnit::getInternalType(mUsage), 0, 0);
		}
		mUseDepth = false;
	}

	if (mFBO)
	{
		glDeleteFramebuffersEXT(1, (GLuint *) &mFBO);
		mFBO = 0;
	}

	if (mTex.size() > 0)
	{
		LLImageGL::deleteTextures(mTex.size(), &mTex[0]);
		mTex.clear();
	}

	mSampleBuffer = NULL;
	sBoundTarget = NULL;
}
void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage, bool use_fbo)
{
	stop_glerror();
	mResX = resx;
	mResY = resy;

	mStencil = stencil;
	mUsage = usage;
	mUseDepth = depth;

	release();

	if ((sUseFBO || use_fbo) && gGLManager.mHasFramebufferObject)
	{
		if (depth)
		{
			stop_glerror();
			allocateDepth();
			stop_glerror();
		}

		glGenFramebuffersEXT(1, (GLuint *) &mFBO);

		if (mDepth)
		{
			glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO);
			if (mStencil)
			{
				glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, mDepth);
				stop_glerror();
				glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, mDepth);
				stop_glerror();
			}
			else
			{
				glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, LLTexUnit::getInternalType(mUsage), mDepth, 0);
				stop_glerror();
			}
			glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
		}
		
		stop_glerror();
	}

	addColorAttachment(color_fmt);
}
Пример #20
0
void framebuffer_obj_t::detach_renderbuffer(GLenum attachment_point)
{
    glFramebufferRenderbufferEXT( GL_FRAMEBUFFER,
                                  attachment_point,
                                  GL_RENDERBUFFER,
                                  0);
    check_error();
}
Пример #21
0
void FBO::generateColorOnly(bool tex16f)
{
    destroy();

	//Generate the texture
	glGenTextures(1, &m_iTexId);
	glBindTexture(m_eTextureType, m_iTexId);

    glTexParameteri (m_eTextureType, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri (m_eTextureType, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(m_eTextureType, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(m_eTextureType, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	glTexParameteri(m_eTextureType, GL_GENERATE_MIPMAP, GL_TRUE);

	///We need six Face for cube, or one for 2D
	if (m_eTextureType == GL_TEXTURE_CUBE_MAP)
	{
		glTexImage2D( GL_TEXTURE_CUBE_MAP_POSITIVE_X , 0, GL_RGBA8, m_iWidth, m_iHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
		glTexImage2D( GL_TEXTURE_CUBE_MAP_POSITIVE_Y , 0, GL_RGBA8, m_iWidth, m_iHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
		glTexImage2D( GL_TEXTURE_CUBE_MAP_POSITIVE_Z , 0, GL_RGBA8, m_iWidth, m_iHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
		glTexImage2D( GL_TEXTURE_CUBE_MAP_NEGATIVE_X , 0, GL_RGBA8, m_iWidth, m_iHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
		glTexImage2D( GL_TEXTURE_CUBE_MAP_NEGATIVE_Y , 0, GL_RGBA8, m_iWidth, m_iHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
		glTexImage2D( GL_TEXTURE_CUBE_MAP_NEGATIVE_Z , 0, GL_RGBA8, m_iWidth, m_iHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
	}
	else{
		if(!tex16f)
			glTexImage2D(m_eTextureType, 0, GL_RGBA8, m_iWidth, m_iHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
		else
			glTexImage2D(m_eTextureType, 0, GL_RGB16F_ARB, m_iWidth, m_iHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
	}
	
	glBindTexture(m_eTextureType, 0);

	//Generate renderbuffer
	glGenRenderbuffersEXT(1, &m_iRenderId);
    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_iRenderId);
    glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, m_iWidth, m_iHeight);
    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);

	//Generating ID
	glGenFramebuffersEXT(1, &m_iId);
	activate();

    // attach a texture to FBO color attachement point
    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, m_eTextureType, m_iTexId, 0);

	// attach a renderbuffer to depth attachment point
    glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_iRenderId);

	desactivate();

	//Check FBO status
	if(!checkFramebufferStatus())
		std::cerr<<"ERROR : FBO creation Fail "<<std::endl;
	
	//Color Only
	m_iType = 0;
}
Пример #22
0
void initDisplay() {

	for(int i=0;i<10;i++) {
		flag_dessin[i] = false;
	}
	flag_dessin[0] = true;

	instantPrec = glutGet(GLUT_ELAPSED_TIME);

	sepiaColor[0] = 0.2;
	sepiaColor[1] = 0.1;
	sepiaColor[2] = 0;

	/// INITIALISATION DES TEXTURES ...
	initTexture();

	/// INITIALISATION DES SHADERS ...
	if(!RTShaders::areShadersSupported(true)) {
		std::cerr<<"[In initDisplay] : Shaders are not supported..."<<std::endl;
		exit(5);
	}
	testShader = RTShaders::loadShader("./shaders/tstshader.vert","./shaders/tstshader.frag",true);

	/// INITIALISATION DES FBOS ...
	if (USE_FBO) {
		if(initFBO()==false){
			cerr<<"FBO not supported ! Exiting"<<endl;
			exit(5);
		}

		glGenFramebuffersEXT(1, &fbo_handler);
		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fbo_handler);
		GLuint depth_rb;
		glGenRenderbuffersEXT(1, &depth_rb);
		glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_rb);
		glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,GL_DEPTH_COMPONENT,image_base->tailu,image_base->tailv);
		glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb);
		glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, image_base->indbind , 0);
		checkFramebufferStatus();
		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0);
	}

	/// INITIALISATION CLASSIQUE OPENGL ...
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);
	glMatrixMode(GL_TEXTURE);
		glLoadIdentity();
	glMatrixMode(GL_MODELVIEW);

	glShadeModel( GL_SMOOTH );
	glEnable(GL_TEXTURE_2D);
	glDisable(GL_BLEND);
	glDisable(GL_FOG);
	CHECK_GL;


	glUseProgramObjectARB(0);
}
Пример #23
0
static enum piglit_result
test(void)
{
   GLuint fbo, rb;
   int i;
   GLboolean pass = GL_TRUE;
   GLenum err;

   glGenFramebuffersEXT(1, &fbo);
   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
   check_error(__LINE__);

   glGenRenderbuffersEXT(1, &rb);
   check_error(__LINE__);
   glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);

   glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
                                GL_COLOR_ATTACHMENT0,
                                GL_RENDERBUFFER_EXT,
                                rb);
   check_error(__LINE__);

   /* clear out any errors */
   while (glGetError())
      ;

   /* test formats that should be accepted */
   for (i = 0; i < ARRAY_SIZE(Formats); i++) {
      if (!HaveExtension[Formats[i].extension])
          continue;

      glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, Formats[i].format,
                               piglit_width, piglit_height);
      err = glGetError();
      if (err) {
         printf("%s: glRenderbufferStorage failed for format 0x%x\n",
                TestName, Formats[i].format);
         pass = GL_FALSE;
      }
      printf("0x%04X: %s\n", Formats[i].format,
             glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) == GL_FRAMEBUFFER_COMPLETE_EXT ?
             "complete" : "incomplete");
   }

   /* test formats that should fail */
   for (i = 0; i < ARRAY_SIZE(InvalidFormats); i++) {
      glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, InvalidFormats[i],
                               piglit_width, piglit_height);
      err = glGetError();
      if (err != GL_INVALID_ENUM) {
         printf("%s: glRenderbufferStorage erroneously accepted format 0x%x\n",
                TestName, InvalidFormats[i]);
         pass = GL_FALSE;
      }
   }

   return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Пример #24
0
void framebuffer_obj_t::attach_renderbuffer( const renderbuffer_obj_t& obj,
        GLenum attachment_point)
{
    glFramebufferRenderbufferEXT( GL_FRAMEBUFFER,
                                  attachment_point,
                                  GL_RENDERBUFFER,
                                  obj.id());
    check_error();
}
Пример #25
0
/*-------------------------------------------------------------------------

  -------------------------------------------------------------------------*/
bool FilterBox::Initialize(int w, int h)
{
  bufw = w;
  bufh = h;
  //
  // FBO
  //
  glGenFramebuffersEXT(2, fb);
  glGenTextures(2, textureID);
  glGenRenderbuffersEXT(1, &depth_rb);
  initRT(0, w, h);
  initRT(1, w, h);
  //
  // initialize depth renderbuffer
  //
  glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_rb);
  glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, w, h);
  glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, 
                                GL_RENDERBUFFER_EXT, depth_rb);
  CheckFramebufferStatus();

  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
  //
  // CGFX things
  //
  cgContext = cgCreateContext();
  cgGLRegisterStates(cgContext);
  std::string resolved_path;

        cgEffect = cgCreateEffectFromFile(cgContext, "data/shaders/FilterBox.cgfx", NULL);
        if(!cgEffect)
        {
			exit(0);
            const char * pszErrors = NULL;
            fprintf(stderr, "CgFx Parse error : %s", pszErrors);
            const char *listing = cgGetLastListing(cgContext);
            bValid = false;
            return false;
        }
  cgTechnique = cgGetNamedTechnique(cgEffect, "Filter");
  cgPassFilterH = cgGetNamedPass(cgTechnique, "verticalPass");
  cgPassFilterV = cgGetNamedPass(cgTechnique, "horizontalPass");
  cgPassBlend   = cgGetNamedPass(cgTechnique, "drawFinal");
  cgBlendFactor = cgGetNamedEffectParameter(cgEffect, "blendFactor");
  cgGlowFactor  = cgGetNamedEffectParameter(cgEffect, "glowFactor");
  srcSampler    = cgGetNamedEffectParameter(cgEffect, "srcSampler");
  tempSampler   = cgGetNamedEffectParameter(cgEffect, "tempSampler");
  finalSampler  = cgGetNamedEffectParameter(cgEffect, "finalSampler");
  verticalDir   = cgGetNamedEffectParameter(cgEffect, "verticalDir");
  horizontalDir = cgGetNamedEffectParameter(cgEffect, "horizontalDir");

  cgGLSetParameter2f(verticalDir, 0,1.0f/(float)h);
  cgGLSetParameter2f(horizontalDir, 1.0f/(float)w, 0);

  bValid = true;
  return true;
}
Пример #26
0
/**
 * Creates and attaches a RBO
 */
void FBO::CreateRenderBuffer(const GLenum attachment, const GLenum format, const GLsizei width, const GLsizei height)
{
	GLuint rbo;
	glGenRenderbuffersEXT(1, &rbo);
	glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rbo);
	glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, format, width, height);
	glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attachment, GL_RENDERBUFFER_EXT, rbo);
	myRBOs.push_back(rbo);
}
Пример #27
0
void Canvas::Impl::setup(int w, int h)
{
    if (width != 0 || height != 0 || w <= 0 || h <= 0)
        return;

    width = w;
    height = h;

    // Setup texture
    glGenTextures(1, &texture);
    glBindTexture(GL_TEXTURE_2D, texture);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);

    if (GLEW_ARB_framebuffer_object) {
        // Setup renderBuffer
        glGenRenderbuffers(1, &renderBuffer);
        glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer);
        glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, width, height);

        // Setup frameBuffer
        glGenFramebuffers(1, &frameBuffer);
        glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer);
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, renderBuffer);
        glBindFramebuffer(GL_FRAMEBUFFER, 0);
    } else {
        // Setup renderBuffer
        glGenRenderbuffersEXT(1, &renderBuffer);
        glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, renderBuffer);
        glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_STENCIL_EXT, width, height);

        // Setup frameBuffer
        glGenFramebuffersEXT(1, &frameBuffer);
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frameBuffer);
        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texture, 0);
        glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, renderBuffer);
        glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, renderBuffer);
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    }
}
Пример #28
0
int FrameBufferObject::CreateImageObject(unsigned int width, unsigned int height, 
										 int depthbuffer_enabled, int stencilbuffer_enabled)
{	

	//Create the Image object
	ImageObject new_object;
	new_object.width		= width;
	new_object.height		= height;
	new_object.texture_type	= NULL;
	new_object.texture_id	= NULL;
	new_object.depth_id		= NULL;
	new_object.stencil_id	= NULL;

	//First determine if the requested dimensions are power of two
	if (ispoweroftwo(width) && ispoweroftwo(height))
	{
		new_object.texture_type = GL_TEXTURE_2D;	//Power of two enum
		LogSystem()->ReportMessage("Using GL_TEXTURE_2D");
	}
	else
	{
		new_object.texture_type = 0x84F5;			//Non power of two enum
	}

	glGenTextures(1, &new_object.texture_id);
	new_object.texture_id;
	glBindTexture(GL_TEXTURE_RECTANGLE_ARB, new_object.texture_id);
	new_object.texture_type = GL_TEXTURE_RECTANGLE_ARB;
	glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
	glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);//GL_CLAMP
    glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);//GL_CLAMP
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

	//Create the depth RenderBuffer if requested
	if (depthbuffer_enabled != 0)
	{
		glGenRenderbuffersEXT(1, &new_object.depth_id);
		glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, new_object.depth_id);
		glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, new_object.width, new_object.height);
		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer_id);
		glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, new_object.depth_id);
	}

	//glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);

	//Push this new image object onto the list
	image_objects.push_back(new_object);

	

	//Return the 'index' for the id of this texture
	return (int)image_objects.size() - 1;
			
}
Пример #29
0
////////////////////////////////////////////////////////
// renderGL
//
/////////////////////////////////////////////////////////
void gemcubeframebuffer :: render(GemState *state)
{
  gem::GLStack*stacks=NULL;
  if(state) {
    state->get(GemState::_GL_STACKS, stacks);
  }

  if(!m_width || !m_height) {
    error("width and height must be present!");
  }

  glActiveTexture(GL_TEXTURE0_ARB + m_texunit);

  if (m_wantinit) {
    initFBO();
  }

  // store the window viewport dimensions so we can reset them,
  // and set the viewport to the dimensions of our texture
  glGetIntegerv(GL_VIEWPORT, m_vp);
  glGetFloatv( GL_COLOR_CLEAR_VALUE, m_color );

  glBindTexture( m_texTarget, 0 );
  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_frameBufferIndex);
  // Bind the texture to the frame buffer.
  glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
                            /*m_texTarget*/ GL_TEXTURE_CUBE_MAP_POSITIVE_X + m_face, m_offScreenID, 0);
  glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
                               GL_RENDERBUFFER_EXT, m_depthBufferIndex);

  // debug yellow color
  // glClearColor( 1,1,0,0);
  glClearColor( m_FBOcolor[0], m_FBOcolor[1], m_FBOcolor[2], m_FBOcolor[3] );

  // Clear the buffers and reset the model view matrix.
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  // We need a one-to-one mapping of pixels to texels in order to
  // ensure every element of our texture is processed. By setting our
  // viewport to the dimensions of our destination texture and drawing
  // a screen-sized quad (see below), we ensure that every pixel of our
  // texel is generated and processed in the fragment program.
  glViewport(0,0, m_width, m_height);

  if(stacks) {
    stacks->push(gem::GLStack::PROJECTION);
  }
  glLoadIdentity();
  glFrustum( m_perspect[0],  m_perspect[1],  m_perspect[2],  m_perspect[3],
             m_perspect[4], m_perspect[5]);

  if(stacks) {
    stacks->push(gem::GLStack::MODELVIEW);
  }
  glLoadIdentity();
}
Пример #30
0
Map::Map()
{
  mMutex = CreateMutex(NULL, FALSE, "LeftMapMutex");
  mCollidableMutex = CreateMutex(NULL, FALSE, "LeftMapCollidableMutex");
  mSpot = new GLParticle(1280, 1280, 1.0f, 1.0f, 1.0f, 1.0f, glpLight);
  
  mMinimap.clear();
  mMinimapZoom = 20.0f;
  mMinimapParticle = new GLParticle(5, 5, 0.0f, 1.0f, 0.0f, 1.0f, glpSolid);
  mMinimapMask.resize(1);
  genCirclePolygon(GLvector2f(0.0f, 0.0f), 2000.0f, mMinimapMask[0], false, 64);
  
  mGaussShader = new GLGaussShader();
  assert(mGaussShader->initialized());

  glGenTextures(1, &mFramebufferTexture);
  glBindTexture(GL_TEXTURE_2D, mFramebufferTexture);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, GL_SCREEN_IWIDTH, GL_SCREEN_IHEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  glGenFramebuffersEXT(1, &mFramebuffer);
  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFramebuffer);
  glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, mFramebufferTexture, 0);
  glGenRenderbuffersEXT(1, &mRenderbuffer);
  glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, mRenderbuffer);
  glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, GL_SCREEN_IWIDTH, GL_SCREEN_IHEIGHT);
  glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, mRenderbuffer);
  
  GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
  assert(status == GL_FRAMEBUFFER_COMPLETE_EXT);
  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
  glBindTexture(GL_TEXTURE_2D, 0);

  mFramebufferList = glGenLists(1);
  glNewList(mFramebufferList, GL_COMPILE);
  glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
  glBindTexture(GL_TEXTURE_2D, mFramebufferTexture);
  glBegin(GL_QUADS);
    glTexCoord2f(0.0f, 0.0f); 
    glVertex3f(0.0f, 0.0f,  0.0f);
    glTexCoord2f(1.0f, 0.0f);
    glVertex3f(GL_SCREEN_FWIDTH, 0.0f,  0.0f);
    glTexCoord2f(1.0f, 1.0f); 
    glVertex3f(GL_SCREEN_FWIDTH, GL_SCREEN_FHEIGHT,  0.0f);
    glTexCoord2f(0.0f, 1.0f); 
    glVertex3f(0.0f, GL_SCREEN_FHEIGHT,  0.0f);
  glEnd();
  glBindTexture(GL_TEXTURE_2D, 0);
  glEndList();

  mCallback = 0;
  mUpdate = true;
  generate();
}