Jump to content
  • Advertisement
Sign in to follow this  
flounder

glCopyTexSubImage2D messes up textures

This topic is 4255 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'm using textures as images that can be drawn to like the back buffer. Drawing to textures works fine, but when i draw to a texture in full screen, minimize and then restore the window, the texture is either all black or random colors. This only happens to texture's i've drawn to, and i tracked the problem down to textures that i used glCopyTexSubImage2D on. The rest of the drawing process looks fine, so i don't know what else could be causing this to happen to the textures. Here's an overview of how i draw to a texture, if it helps: set viewport and orthographic view to the texture dimensions copy texture pixels to back buffer draw to back buffer copy back buffer pixels to texture (with glCopyTexSubImage2D) resize viewport and ortho view to back buffer dimensions

Share this post


Link to post
Share on other sites
Advertisement
Since you mention you minimize the window, I have to ask. Is the texture corrupted only when you minimize the window and you update the texture while the window is minimized?

Assuming it is, the content of any pixel in any frame buffer that is not visible on the screen is undefined. That means you cannot be sure to get the correct values from a minimized window. You cannot even be sure the values are correct for parts of a window that is overlapped by another window. The pixels you read must be visible, and your window must be the topmost window.

The solution is to use offscreen buffers. Search for P-buffers or framebuffer objects (FBO) for example.

Share this post


Link to post
Share on other sites
No, i render to the texture when the game starts, while the window is fullscreen. The main loop only consists of drawing the texture to the screen.

I'll look at P-buffers when i get home, i remember not wanting to use them because they required a higher opengl version than i want to use.

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!