Jump to content
  • Advertisement
Sign in to follow this  

New to glCopyTexImage2D ... problems

This topic is 4830 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was trying (for the first time!) to render my backbuffer to a texture and I couldn't quite get it to work. I was working with NeHe tutorial #36 as a guideline. What I am doing is:
void render_to_texture ()
    glViewport (0, 0, 128, 128);

    glBindTexture (GL_TEXTURE_2D, blurtex);

    glCopyTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE, 0, 0, 128, 128, 0);
    glViewport (0, 0, XRES, YRES);

And then, to see the texture I just made:
	glBindTexture (GL_TEXTURE_2D, blurtex);
        glColor3f (1.0f, 0.0f, 0.0f);
		glTexCoord2f(0.0f, 1.0f); glVertex3f(0.0f, 0.0f,  0.0f);	// bot left
		glTexCoord2f(1.0f, 1.0f); glVertex3f((float) XRES, 0.0f,  0.0f);  // bot right
		glTexCoord2f(1.0f, 0.0f); glVertex3f((float) XRES,  (float) YRES,  0.0f);  // top right
		glTexCoord2f(0.0f, 0.0f); glVertex3f(0.0f,  (float) YRES,  0.0f);  // top left
I get nothing with this. Yet, if I comment out glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); in the render_to_texture () function, I can see that my viewport does actually have my object in it. But, again, the texture doesn't. I am totally new to this, so the solution could be really simple - hasn't occured to me yet. Thanks for any help!

Share this post

Link to post
Share on other sites
I think im on a similar case... but im trying to see the depth buffer... if its the case... my guess is the depth buffer is not giving any black and white instant result as we will expected it to do...! anyone?


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!