Scoobie
Scoobie

Reputation: 1139

How to get GL_VIEWPORT dimensions in Android GL10?

I'd like to accomplish the following in Android using API Level 7:

glGet(GL_VIEWPORT, someBuffer)

Documentation for OpenGL ES 1.1 shows this as part of the C API.

I've tried using the following code:

    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]);
    }

I get output in various phases of the surface like so:

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

How would one do this using Android's kronos GLES?

Upvotes: 0

Views: 5291

Answers (2)

Scoobie
Scoobie

Reputation: 1139

I discovered that Android protects you from yourself. onSurfaceChanged is called before any onDrawFrame calls. It's on us to capture and persist any of this data.

Upvotes: 2

Stefan Hanke
Stefan Hanke

Reputation: 3528

The constant GL_VIEWPORT is not part of interface GL10, but of GL11. Try using GL11.GL_VIEWPORT instead. If you think this does not befit, you can cast the instance to GL11 before, but this does not make any difference.

Upvotes: 0

Related Questions