PDA

View Full Version : what is wrong with my code?



alexopenglbeginner
09-02-2009, 06:13 AM
I finally got it not to return 1280 or 1282, but it still crashes at the glBlitFramebufferEXT. Can you help, I removed all the error checking code from the code below to make the code more readable:



Engine::glGenFramebuffersEXT(1, &sourceImg.rFBO);
Engine::glBindFramebufferEXT( GL_READ_FRAMEBUFFER_EXT, sourceImg.rFBO );
Engine::glFramebufferTexture2DEXT( GL_READ_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, sourceImg.rTexID, 0 );
glReadBuffer( GL_COLOR_ATTACHMENT0_EXT );

Engine::glGenFramebuffersEXT(1, &this->rFBO);
Engine::glBindFramebufferEXT( GL_DRAW_FRAMEBUFFER_EXT, this->rFBO );
Engine::glFramebufferTexture2DEXT( GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT + this->colorattachment_ord, GL_TEXTURE_2D, this->rTexID, 0 );
glDrawBuffer( GL_COLOR_ATTACHMENT1_EXT );

Engine::glBlitFramebufferEXT(
0, 0, sourceImg.rWidth, sourceImg.rHeight,
x, y, x + sourceImg.rWidth, y + sourceImg.rHeight,
GL_COLOR_BUFFER_BIT,
GL_LINEAR);


I'm trying to draw from sourceImg OpenGL 2D texture to destination OpenGL 2D texture.

Brolingstanz
09-02-2009, 02:09 PM
Try something like

glBindFramebuffer(GL_READ_FRAMEBUFFER, fbSrc);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbDst);
glBlitFramebuffer(...);

Your source and destination formats must be compatible or GL will complain bitterly with an INVALID_OPERATION error (be sure to check glGetError and glCheckFramebufferStatus here and there).