Display huge texture

1

Greetings,

I am working on a program developed in C ++, using QT and GDAL. The program now is able to show textures but if these are larger than 16384x16384 pixels I get the following error:

  

GLI | GL ERROR - Function glTextureStorage2DEXT generated error GL_INVALID_VALUE

The image I use as a texture is an image in TIFF format.

I think this problem is because OpenGl can not create such large textures. The main problem I have is that I can not change the resolution of the image since I need all the details of it, so I would like if someone knows a method to be able to have in memory only the piece of texture that is being seen by the viewer (a QSurface of 800x800) and that at the same time can dynamically modify said piece.

    
asked by Zharios 29.09.2017 в 11:33
source

1 answer

3

Method to use very large textures:

Divide and win, Take care that the texture you use if it is larger than > 8192 cuts it into 4 square segments and multiples of 2. So on, you can deal with the size you want.

Then instead of instantiating 1 drawing object, instances 4 and organize them so that they stay together and ordered, and assign each one a different texture but in reality it is the 4 that you generated when making the cut.

Example

textureGrand_00 - > TopLeft instance

texturaGrande_01 - > TopRight instance

texturaGrande_02 - > BottomLeft instance

texturaGrande_03 - > BottomRight instance

Method to use only one segment

What you are looking for here is to use an area of your huge image, the strategy to follow is that you create a textured object, but reading only the corresponding bound (region).

In such a way having an example matrix: 10x10 We want only an area of 4x4, we read the bits of the giant image whose (center + half of our rago - left side) is where it starts, imagining that it is the center 5 - (4/2) = row 3, 5 - (4/2) = col 3 we start reading in 3x3 up to 3 + bound and 3 + bound bone 7x7 and that small matrix will make up our new image.

Now we simply command a swap to the visualization object that uses our new texture.

To edit it

Simply, edit the small matrix at your whim and then overwrite the region of the giant's buffer (original) to the buffer or file, as needed. The rest is to repeat the process each time you move the image.

    
answered by 13.05.2018 / 00:00
source