Example #1
0
void OpenGLRenderer::bindFrameBufferTexture(Texture *texture) {
	if(!texture)
		return;
	OpenGLTexture *glTexture = (OpenGLTexture*)texture;
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, glTexture->getFrameBufferID());
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	
}
Example #2
0
void OpenGLRenderer::bindFrameBufferTexture(Texture *texture) {
	if(currentFrameBufferTexture) {
		previousFrameBufferTexture = currentFrameBufferTexture;
	}
	OpenGLTexture *glTexture = (OpenGLTexture*)texture;

	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, glTexture->getFrameBufferID());
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	currentFrameBufferTexture = texture;
}
Example #3
0
Image *OpenGLRenderer::renderBufferToImage(Texture *texture) {
    
	OpenGLTexture *glTexture = (OpenGLTexture*)texture;
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, glTexture->getFrameBufferID());
    glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
    
	char *imageBuffer = (char*)malloc(texture->getWidth() * backingResolutionScaleX * texture->getHeight() * backingResolutionScaleY * 4);
	glReadPixels(0, 0, texture->getWidth() * backingResolutionScaleX, texture->getHeight() * backingResolutionScaleY, GL_RGBA, GL_UNSIGNED_BYTE, imageBuffer);
	Image *retImage = new Image(imageBuffer, texture->getWidth() * backingResolutionScaleX, texture->getHeight() * backingResolutionScaleY, Image::IMAGE_RGBA);
	free(imageBuffer);
    
    unbindFramebuffers();
	return retImage;
}