Jump to content
  • Advertisement
Sign in to follow this  

Render to texture seems to depend on the window size / glCopyTexImage2D

This topic is 3774 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

Im trying to do some simple rendering to texture. I know there are better ways, but for now I want to render the scene as usual and then use glCopyTexImage2D. I want to draw a simple scene and render it to a texture. Then I put that texture on a quad. My code looks something like: glViewport(0,0, 256, 256); gluPerspective(45.0f, 1.0, 0.1f, 200.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); draw_scene(); glBindTexture(GL_TEXTURE_2D, theTexture); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 256, 256, 0); glViewport(0 , 0, width, height); gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,20000.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); // render the quad with 'theTexture' The problem is that the texture that is rendered seems to depend on the width/height of the window. I want the scene to be rendered as a square (aspect ratio = 1), and then render the quad with the normal aspect ratio. But when I put the texture on a quad with the sides 1, it gets "squeezed". If a change the size of the window (decrease the width) it looks normal.. but if I decrease the width to much, some parts of the scene cant be seen in the texture. EDIT: Solved the problem. Gah, stupid me, forgot to et the matrix mode to GL_PROJECTION [Edited by - zurekx on February 20, 2008 12:02:23 PM]

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!