rendering fbo to texture, doesn't seem to work

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 :slight_smile:

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.

some changes for you

  1. you must set the clear colour before you clear

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

  1. you must activate a texture before you bind

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