Search code examples
imageopenglgraphicstextures

What is OpenGL maximum texture size with NPOT textures?


I know I can use this code to retreive the maximum texture size of a GPU:

glGetIntegerv(GL_MAX_TEXTURE_SIZE, &size, 0);

I can also get the maximum texture buffer size with:

glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, &size, 0);

The problem is that I want to create an atlas to pack font characters and 2D atlas are more complex and space in the atlas can be lost by filling them without planning where to fit every chararcter. So, I am using a 1 dimensional atlas to store text characters:

https://drive.google.com/open?id=1py9l2hEk3-fJzqyMeF6P2ajrNs3CFDFj

Can I exceed GL_MAX_TEXTURE_SIZE if the texture buffer size is smaller than GL_MAX_TEXTURE_BUFFER_SIZE? The textures are NPOT so that made me ask this question (because maximum texture size is GL_MAX_TEXTURE_SIZE squared and the textures does not reach GL_MAX_TEXTURE_SIZE in the Y axis).

EDIT

To make the question clear, can I create a texture which width > GL_MAX_TEXTURE_SIZE but the height isn't and the texture buffer does not exceed GL_MAX_TEXTURE_BUFFER_SIZE. Ex:

if GL_MAX_TEXTURE_SIZE is 8192, creating a texture with dimensions of 10000 x 40. It doesn't exceed GL_MAX_TEXTURE_BUFFER_SIZE which is 8192 squared but it exceeds the side maximum.


Solution

  • GL_MAX_TEXTURE_SIZE governs the dimensions of 1D and 2D textures of all forms. It does not care about how much storage a texture takes up; it's about the size of its dimensions.

    GL_MAX_TEXTURE_BUFFER_SIZE has nothing to do with the size of a texture's storage either (not directly). It is a limit on the dimension of a buffer texture, which are not 1D or 2D textures. It only matters if your texture is of the GL_TEXTURE_BUFFER type, which is distinct from GL_TEXTURE_1D or GL_TEXTURE_2D.

    And none of these matters has anything to do with NPOT textures. That is merely the removal of the restriction of having texture dimensions being a power of two.