0

我想在 Android 中使用 API Level 7 完成以下任务:

glGet(GL_VIEWPORT, someBuffer)

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 如何做到这一点?

4

2 回答 2

2

我发现 Android 可以保护您免受自己的伤害。onSurfaceChanged在任何调用之前onDrawFrame调用。我们有责任捕获和保存这些数据。

于 2012-04-16T22:03:07.277 回答
0

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

于 2012-04-16T06:44:29.443 回答