FBO's and ES 2

Thanks Xmas for you feedback. I will in the future put SDK specific questions to the correct address.

When working with OpenGL | ES 2.0 I want to render to a texture but get’s framebuffer incomplete, incomplete attachment.



// Setup FBO texture
glGenTextures(1, &settings->fboTexture);
glBindTexture(GL_TEXTURE_2D, settings->fboTexture);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

// Generate FBO
glGenFramebuffers(1, &settings->fbo);

// bind the framebuffer
glBindFramebuffer(GL_FRAMEBUFFER, settings->fbo);

glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, settings->fboTexture, 0);
checkFramebufferStatus();
	
// run shader program
drawQuad(512, 512, 512, 512, program1);

glBindFramebuffer(GL_FRAMEBUFFER, 0);

Must I have a render buffer attached? Can’t i render direct to a texture?

best regards,
Fredrik

Forgot a line of code…

	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, settings->width, settings->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);

best regards,
Fredrik

What graphics card and drivers are you using? What’s the size of the texture?

Note that the texture should be unbound/not used in the shader while you render to it, otherwise the results are undefined.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.