Render2Texture prob

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

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);
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);

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 on other sites
What's the gfx screen resolution?

Share on other sites
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 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 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 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 on other sites
Are you making a glViewport call before the texure copy? If so, is the viewport being set big enough?

• 22
• 10
• 19
• 15
• 14