Jump to content
  • Advertisement
Sign in to follow this  
Woltan

Render2Texture prob

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

Dear Forum, I currently working on a project, where I need to render to a texture. I do that using glCopyTexImage2D in glOtho mode.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-0.5f, 0.5f, -0.5f, 0.5f, 0.1f, 50);

glMatrixMode(GL_MODELVIEW);
glViewport(0, 0, w, h);    //w, h are the width and heigt of my texture

glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

gluLookAt(0, 0, 6, 0, 0, 0, 0, 1, 0);

ObjectPaint();       //Paints the object 

glBindTexture(GL_TEXTURE_2D, uiTex);
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, w, h, 0);


Everything seemed to be workin just fine, until I got to a rather larger object. I chose it to have a size of 1024x256. However, when I tried to map (i dont know if that is the right term) it to my mesh, some of the right hand area was missing. It looked like the texture got cut off at some point. Do you know, dear forum, what I am doing wrong? If so, please help me out, cause my boss is in a grumpy mood today. ;) Thx in advance Best regards Woltan Edit: The strange thing is, if I change to size of the texture to 512x256 or 512x128 it works just fine. Anyhow I really need the higher resolution texture!

Share this post


Link to post
Share on other sites
Advertisement
The gfx screen resolution is 1280x800. Does that matter? I am only rendering to a texture. Or do you think it got cut off, because it reached the end of the screen?
Mmmh but then again i am only rendering to a texture.

Share this post


Link to post
Share on other sites
I just cranked up the resolution of my window, and the whole texture got mapped correctly.
Next question:
What can you do if you have a small window, but want to render into a larger texture?
There must be a better solution than, to just resize the window every time you render to that texture!!

Share this post


Link to post
Share on other sites
Well, that's the problem with the way you render-to-texture. If you understood what glCopyTexImage2D does, you wouldn't be asking this question: this function copies (part of) the contents of the framebuffer to a texture. The logical framebuffer however, gets clipped to the size of the window you're currently rendering to (under Windows). If you really want to RTT, you should look at the pbuffers (WGL_ARB_pbuffer) extension, or (imo) the FBO extension (GL_EXT_framebuffer_object). Bear in mind that both are extensions and may not be supported on any particular graphics card. FBO's are even more recent (but better).

NOTE: under Windows, you could also have access to the WGL_ARB_render_texture extension.

http://www.opengl.org/registry/

Share this post


Link to post
Share on other sites
Thx Todo, for the information. And unfortunatly my main problem is, that I actually dont really know what I am doing when it comes to OpenGL. But I am trying to learn it little by little.
I'll have a look into your suggestion
thx again
cherio Woltan

Share this post


Link to post
Share on other sites
Are you making a glViewport call before the texure copy? If so, is the viewport being set big enough?

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!