Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Get maximum texture size

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2012
    Posts
    10

    Get maximum texture size

    I am trying to get the maximum texture size limit in Android for OpenGL ES 2.0. But I've found that the next instruction only works if I'm currently within the OpenGL context, in other words I must have a GL Surface and a GL Renderer created, and then ask for the texture size within the GLRenderer thread, all of which I don't need.

    Code :
    int[] maxTextureSize = new int[1];
    GLES20.glGetIntegerv(GLES20.GL_MAX_TEXTURE_SIZE, maxTextureSize, 0);

    So I came with the next algorithm, which gives me the maximum texture size without having to create any surface or renderer, or having to be in a different thread. It works correctly so far, so my questions are:

    1) Area PBuffers always the same size as texture sizes
    2) Can anyone spot any problem or anything I might have missed, just in case.


    Code :
    public int getMaximumTextureSize()
    {
        EGL10 egl = (EGL10)EGLContext.getEGL();
        EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
     
        // Initialise
        int[] version = new int[2];
        egl.eglInitialize(display, version);
     
        // Query total number of configurations
        int[] totalConfigurations = new int[1];
        egl.eglGetConfigs(display, null, 0, totalConfigurations);
     
        // Query actual list configurations
        EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]];
        egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations);
     
        int[] textureSize = new int[1];
        int maximumTextureSize = 0;
     
        // Iterate through all the configurations to located the maximum texture size
        for (int i = 0; i < totalConfigurations[0]; i++)
        {
            // Only need to check for width since opengl textures are always squared
            egl.eglGetConfigAttrib(display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize);
     
            // Keep track of the maximum texture size
            if (maximumTextureSize < textureSize[0])
            {
                maximumTextureSize = textureSize[0];
            }
     
            Log.i("GLHelper", Integer.toString(textureSize[0]));
        }
     
        // Release
        egl.eglTerminate(display);
        Log.i("GLHelper", "Maximum GL texture size: " + Integer.toString(maximumTextureSize));
     
        return maximumTextureSize;
    }

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    985
    Quote Originally Posted by sanchiski View Post
    1) Area PBuffers always the same size as texture sizes
    There is no such guarantee, they can have completely different size limits

    Further, what's the problem with creating a GL surface? You'll have to create a surface anyway if you want to call any of the GL functions.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2012
    Posts
    10
    Quote Originally Posted by aqnuep View Post
    There is no such guarantee, they can have completely different size limits

    Further, what's the problem with creating a GL surface? You'll have to create a surface anyway if you want to call any of the GL functions.
    I don't need to use the GL surface at all, I only require to get the texture maximum size for informational purposes. And creating the sirface and renderer puts too much overlead.
    So i guess there is no way around? I thought EGL is the API under the OpenGL layer, and such should give an option to get this information, but so far no luck.

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    985
    Quote Originally Posted by sanchiski View Post
    I don't need to use the GL surface at all, I only require to get the texture maximum size for informational purposes.
    Well, I'd rather say invalid informational purposes then.

    Quote Originally Posted by sanchiski View Post
    And creating the sirface and renderer puts too much overlead.
    Does it? All applications, including the OpenGL Extensions Viewer or the GPU Caps Viewer figures out those hardware limitations, size limits, etc. by creating a context.
    While I'm not aware of what is your application's purpose, I have to say that your approach won't be a generic one.

    Quote Originally Posted by sanchiski View Post
    I thought EGL is the API under the OpenGL layer, and such should give an option to get this information, but so far no luck.
    No, EGL is an API above the OpenGL layer, not under it. EGL is more or less like WGL or GLX, a way to access the "OpenGL layer" by creating a GL surface.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  5. #5
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,264
    It is pretty much the same issue with OpenGL as well --- you need a context to do anything
    http://www.opengl.org/wiki/FAQ#What_...nGL_context.3F
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •