Opengl ES 2.0 : Get texture size and other info

后端 未结 3 1490
自闭症患者
自闭症患者 2021-01-13 05:49

The context of the question is OpenGL ES 2.0 in the Android environment. I have a texture. No problem to display or use it.

Is there a method to know its width and

3条回答
  •  情书的邮戳
    2021-01-13 06:04

    As @Reto Koradi said there is no way to do it but you can store the width and height of a texture when you are loading it from android context before you bind it in OpenGL.

        AssetManager am = context.getAssets();
        InputStream is = null;
        try {
            is = am.open(name);
        } catch (IOException e) {
            e.printStackTrace();
        }
        final Bitmap bitmap = BitmapFactory.decodeStream(is);
        int width = bitmap.getWidth();
        int height = bitmap.getHeight();
    
        // here is you bind your texture in openGL
    

提交回复
热议问题