Question

I have Android project using old OpenGL ES 1. I am using this kind of nested calls:

...
gl.glPushMatrix();
...
gl.glPushMatrix();
...
gl.glPopMatrix();
...
gl.glPopMatrix();
...

It is working fine in emulator and on my phone but it is not working on my tab and on my brother's tab (positions of objects are wrong). According to my tests it seems that nested glPushMatrix is not supported, like if stack size is only 1, so the first POP does not return to the previous PUSH state but to the first of the PUSH states. I tried workaround without using nested calls and it works fine, but such solution complicates my next work. Is that known thing? Is the stack size on some devices only 1? I thought it should be at least 32 or something like that. Is it somehow detectable and/or configurable? Can I export the matrix somehow into some array or different structure to make my own stack and load it from it manually? Thanks.

Was it helpful?

Solution

You can read the depth of the stack using:

glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &result);

It should indeed be at least 32.

That's assuming you're actually using the GL_MODELVIEW matrix stack, and you're not accidentally pushing all your transforms into GL_PROJECTION or something.

Ideally though you should be computing the matrices yourself, as this functionality is deprecated.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top