Jump to content
  • Advertisement
Sign in to follow this  
deavik

New to glCopyTexImage2D ... problems

This topic is 4751 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);
          
    render_my_object();

    glEnable(GL_TEXTURE_2D);
    glBindTexture (GL_TEXTURE_2D, blurtex);

    glCopyTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE, 0, 0, 128, 128, 0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    glViewport (0, 0, XRES, YRES);
}

And then, to see the texture I just made:
	
	glBindTexture (GL_TEXTURE_2D, blurtex);
	glEnable2D();
	
	glBegin(GL_QUADS);
        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
	glEnd();
	glDisable2D();
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
Advertisement
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?

thx

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!