PDA

View Full Version : rendering fbo to texture, doesn't seem to work



samphippen
05-30-2012, 04:02 PM
Hi.

Code here: http://sprunge.us/aGii

expected behaviour: texture attached to fbo is filled with red, red square then renders in bottom left 50x50 pixel square. rest of screen remains black

actual behavior: white square renders in bottom left 50x50 pixel square, rest of screen is red.

At the moment I'm just trying to get the frame buffer to render anything, although my eventual goal is to render some triangles into it.

Any help would be appreciated :)

samphippen
05-30-2012, 04:25 PM
an update: http://sprunge.us/NJCA
the colors from the two FBOs seem to be being combined, but the wrong way around. I'd expect the red square to be at the bottom left, and the green square to be the rest of the screen. However, it's the opposite way around.

tonyo_au
05-30-2012, 10:00 PM
some changes for you

1) you must set the clear colour before you clear


glClearColor(0,1,0,1);
glClear(GL_COLOR_BUFFER_BIT);


2) you must activate a texture before you bind


glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textureId);