uploading a very large texture in smaller blocks ?

Started by
5 comments, last by rldivide 14 years, 5 months ago
Hello, I have a very large (let's say 8192x8192), dynamically generated texture array on the CPU side. Part of the data is updated each time the user does an action. Is there a simple way to upload it to the GPU in blocks of 2048x2048 (for compatibility with older GPUs) ? The problem is that i can't directly map glTexture2D onto my array for uploading because my array is a continuous set of data, so if I glTexture2D(2048,2048) with a pointer to my array it will actually take the first 8192x512 from the array and map it to 2048x2048 on the GPU side, which is obviously wrong. Any tip ?
Advertisement
Use glTexSubImage to update a part of a texture, and play with the unpack parameters to glPixelStore if your source image is a part of a larger image also. Look at the skip row, skip line and line width unpack parameters.
Ah, glTexSubImage2D+glPixelStore sounds to be what I need !

However I'm not familiar at all with glPixelStore and hardly find tutorials about it.
If I understand correctly, I should set GL_UNPACK_ROW_LENGTH to 8192
and GL_UNPACK_SKIP_ROWS/GL_UNPACK_SKIP_PIXELS to the top left coordinate in my array ?
The skip-parameters should be the offset, in rows and pixels, where the subrectangle starts. Whether it is the top left, or any other corner, depends on where you have the origin. So assuming you have the origin in the top left corner, then you are correct.
In my opinion even the texture with 2048x2048 is the good choice to rendering with meshes.
??? CPU & other processors doesn't like to enter to the memory so often.
Quote:Original post by FXACE
In my opinion even the texture with 2048x2048 is the good choice to rendering with meshes.

That totally depends on the magnification of the texels.

Quote:??? CPU & other processors doesn't like to enter to the memory so often.

It depends on how you schedule it. Though I am unsure about the meaning of the triple-question-mark you invoked.

Well I'm using OpenGL to display/edit scientific datas so I have to deal with very large arrays, I cannot do otherwise.

This topic is closed to new replies.

Advertisement