PDA

View Full Version : problem with glCopyTexSubImage2D



HanWu
08-26-2004, 12:00 AM
1) If i want to save the background to a texture and restore it everytime instead of drawing the whole object, What should i do? Someone told me that glCopyTexSubImage2D may help but I would like to know isn't it the width and Height for sub-image must be a (X^2) pixel when using glCopyTexSubImage2D function. The problem is my background won't be exactly the (X^2) pixel.

can someone help me. Thanks a lot.

Bob
08-26-2004, 12:13 AM
The texture have to be a power of two, but you don't have to use the entire texture. Create an empty texture (I think you can pass a null pointer to glTexImage to get an empty image) with a size large enough to hold the background. That is, round up to neares power of two and use that size for the texture. Subimages can be of any size, so copy the window to the texture, and then use proper texture coordinates to get the subimage from the large texture.

-NiCo-
08-26-2004, 01:24 AM
If you're willing to experiment with opengl extansions and you're using windows, you can take a look at

http://oss.sgi.com/projects/ogl-sample/registry/ARB/wgl_buffer_region.txt

This extension is ideal for what you're trying to accomplish, and will most likely give you the best performance.

If you still want to go with the copytexsubimage solution and don't want to be contrained by the power of 2 sizes, you can use the following extension

http://oss.sgi.com/projects/ogl-sample/registry/NV/texture_rectangle.txt

This extension is also available under linux.

Greetz,

Nico

HanWu
04-11-2006, 09:14 AM
Originally posted by Bob:
The texture have to be a power of two, but you don't have to use the entire texture. Create an empty texture (I think you can pass a null pointer to glTexImage to get an empty image) with a size large enough to hold the background. That is, round up to neares power of two and use that size for the texture. Subimages can be of any size, so copy the window to the texture, and then use proper texture coordinates to get the subimage from the large texture. If the size of the window is larger than 1024 and say we use 2048(height)*2048(width) texture. Will you think the texture is too big? I have try with your method and it works fine for 256*256, 512*512, and 1024*1024. But it fail if i use 2048*2048. Please help!!

jide
04-11-2006, 11:33 AM
Don't use rectangle textures, use NPOT ones if your system supports it.

http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_non_power_of_two.txt

HanWu
04-12-2006, 04:40 AM
Originally posted by jide:
Don't use rectangle textures, use NPOT ones if your system supports it.

http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_non_power_of_two.txt I know thats a good idea, but if the graphic card don't support the extension what will be the altenative way?

jide
04-12-2006, 10:55 AM
You can then use texture rectangle. If this is not even supported, then use a viewport that suits your texture capabilities then render to it.

HanWu
04-13-2006, 09:42 AM
Originally posted by jide:
You can then use texture rectangle. If this is not even supported, then use a viewport that suits your texture capabilities then render to it. As I have mention earlier, the texture rectangle fail at the screen size larger than 1024*1024. I hope that someone could tell me the reason. Thanks a lot.

Bob
04-14-2006, 03:49 AM
Maybe your implementation just doesn't support larger textures than 1024x1024. Check glGetInteger with GL_MAX_TEXTURE_SIZE.

And by the way, start a new topic with a link to the old topic, or at least mention that the original thread is nearly 2 years old. Can result in some wierd discussion if some people notice some outdated information, which was correct at the time of the post, and starts arguing without knowing the age of the information. It have happened in the past.

HanWu
04-14-2006, 05:03 AM
Originally posted by Bob:
Maybe your implementation just doesn't support larger textures than 1024x1024. Check glGetInteger with GL_MAX_TEXTURE_SIZE.

And by the way, start a new topic with a link to the old topic, or at least mention that the original thread is nearly 2 years old. Can result in some wierd discussion if some people notice some outdated information, which was correct at the time of the post, and starts arguing without knowing the age of the information. It have happened in the past. I am sorry for that. I have
check the GL_MAX_TEXTURE_SIZE with glGetInteger and it return a 2048. Doesn't it means that the implementation support texture with the size of 2048?