如何在Android GL10中获得GL_VIEWPORT维度?

时间:2012-04-16 06:01:42

标签: android opengl-es

我想使用API​​ Level 7在Android中完成以下操作:

glGet(GL_VIEWPORT, someBuffer)

Documentation for OpenGL ES 1.1将此视为C API的一部分。

我尝试使用以下代码:

    int[] results = new int[4];
    gl.glGetIntegerv(GL10.GL_MAX_VIEWPORT_DIMS, results, 0);
    for (int i = 0; i < results.length; i++) {
        Log.e(TAG, "results[" + i + "]: " + results[i]);
    }

我在表面的各个阶段输出如下:

onSurfaceCreated called
    results[0]: 4096
    results[1]: 4096
    results[2]: 0
    results[3]: 0
onSurfaceChanged called with height: 800 and width: 480
  //NOTE: gl.glViewport(0, 0, width, height); is called here
    results[0]: 4096
    results[1]: 4096
    results[2]: 0
    results[3]: 0
onDrawFrame called
    results[0]: 4096
    results[1]: 4096
    results[2]: 0
    results[3]: 0

如何使用Android的kronos GLES做到这一点?

2 个答案:

答案 0 :(得分:2)

我发现Android会保护您自己。在onSurfaceChanged次调用之前调用onDrawFrame。我们可以捕获并保留任何这些数据。

答案 1 :(得分:0)

常量GL_VIEWPORT不是GL10接口的一部分,而是GL11的一部分。请尝试使用GL11.GL_VIEWPORT。如果您认为这不适合,您可以在之前将实例强制转换为GL11,但这没有任何区别。