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.
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.
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 256256, 512512, and 10241024. But it fail if i use 2048*2048. Please help!!
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.
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.
Originally posted by Bob:
[b] 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. [/b]
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?