[android-developers] Re: OpenGL works incorrectly when projection matrix is set to identity?

2010-06-26 Thread satlan esh
Thanks everybody.

@ Leigh & Indicator: Sorry if I wan't clear enough. There's really not
much to it: nothing is being drawn when projection is set to identity.
All values are fixed point, and there's no mixing with floats.
@ openglguy: The coordinates are already NDC, so there's no need for
any sort of projection, just plain identity.


Here's a simple gl code that reproduces the problem:

glClear(GL_COLOR_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

// Eye coordinates - frustum projection. Ok
{
glViewport(0,0,width,height/3);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustumf(-1,1,-1,1,1,10);

GLfloat v[3*4]={-1, 1,  -2, 1,
-1, -1, -2, 1,
1,  1,  -2, 1};

glVertexPointer(4,GL_FLOAT,0,v);

glDrawArrays(GL_TRIANGLES,0,3);
}

// Normalized device coordinates - identity projection. Draws nothing
{
glViewport(0,height/3,width,height/3);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

GLfloat v[3*4]={-0.5,   0.5,0.11,   1,
-0.5,   -0.5,   0.11,   1,
0.5,0.5,0.11,   1};

glVertexPointer(4,GL_FLOAT,0,v);

glDrawArrays(GL_TRIANGLES,0,3);
}

// Normalized device coordinates - "almost identity" projection. Ok
{
glViewport(0,2*height/3,width,height/3);

glMatrixMode(GL_PROJECTION);
GLfloat id[4*4]={   1.001,  0,  0,  0,
0,  1.001,  0,  0,
0,  0,  1.001,  0,
0,  0,  0,  1.001};
glLoadMatrixf(id);

GLfloat v[3*4]={-0.5,   0.5,0.11,   1,
-0.5,   -0.5,   0.11,   1,
0.5,0.5,0.11,   1};

glVertexPointer(4,GL_FLOAT,0,v);

glDrawArrays(GL_TRIANGLES,0,3);
}

It draws three identical triangles: The first uses eye coordiantes and
a frustum projection matrix. This one works fine.
The second uses the already transformed NDC and an identity projection
matrix. This one draws nothing on Android (but works ok on other
platforms).
The third one passes the same NDC, but uses a projection matrix that's
almost identity. This one draws.

Although the third approach is the closest I got to a solution, my
intentions are that a true identity projection matrix will implicitly
spare the unneeded projection transformation altogehter.

I hope this clarifies the problem.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] OpenGL works incorrectly when projection matrix is set to identity?

2010-06-23 Thread satlan esh
I have an OpenGL app that manipulates it's geometry in screen space to
acheive some effects, and therefore bypasses OpenGL's matrices by
setting modelview and projection to identity. For some reason,
Android's OpenGL implementation seems to be unhappy with this, and
doesn't draw anything.

The same app, compiled from the same code base, works fine on windows
and on iPhone. If I load the app's projection matrix into GL's matrix,
and multiply it's inverse with the final geometry prior to drawing it
(which is effectively a no-op) it displays correctly.

App is native and OpenGL is 1.x if it matters.

Any ideas why is that so?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Frame rate suprisingly low in landscape mode

2010-06-15 Thread satlan esh
I am testing some OpenGL code on the emulator, and I've noticed some
frame rate issues.

There is obviously a 60fps ceiling for portrait, and 30fps ceiling for
landscape, that's clear. However, frame rate in landscape mode seems
to be inherently lower by a factor of almost 1.5 or more. That is, if
I get 30fps in portrait, I'd get around 20fps in landscape. The
application runs full screen, so there's exactly the same screen real
estate.

Is this just an emulator issue, or does real hardware behave alike?

Since the application is full screen, I can get around most of this by
rotating the scene 90 degrees. Is this the recommended setup?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en