I feel like your numbers aren't right.  If you want a sixteenth-screen
sized view (which it seems you do) in the upper right corner, Here's
my initial thought:

int left = surfaceWidth * .75f;
int bottom = surfaceHeight * .75f;
int width = surfaceWidth * .25f;
int height  = surfaceHeight * .25f;
gl.glViewport(left, bottom, width, height);
gl.glOrthof(0, width, height, 0, nearZ, farZ);

That should give you an orthographic view with a coordinate system
starting at 0,0 in the upper left, going to the width/height defined
in the lower right, like conventional 2D coordinate systems.  On a
480x320 landscape, it would be (0,0) to (120,80).  If you want 0,0 in
the lower left, you just need to switch around the arguments for
glOrtho.  I haven't tested this but I'm fairly certain this will work.

Now, about your models not displaying smaller.  They won't.  An
orthographic projection will display models with no perspective at
all.  It does not scale.  With this, you'll just see them through a
smaller viewport, but they'll be the same size.  Scaling is easy,
though.  When you start your draw, just glScalef() after gluLookAt to
the desired size.


On Oct 16, 10:17 pm, Gameboy <[email protected]> wrote:
> When I try to set projection matrix in GLSurfaceview.onDrawFrame, but
> seems it does not work fine. The parameters of glOrthof does not
> change size and shape of graphics elements, graph becomes very small.
>
> Part of code as below, does anybody know the reason?
>
> // Display something in second viewport at top-right of screen with
> different projection mode
> gl.glViewport(mWidth*3/4, mHeight*3/4, mWidth/4, mHeight/4);
> gl.glMatrixMode(GL10.GL_PROJECTION);
> gl.glPushMatrix() ;
> gl.glLoadIdentity();
> gl.glOrthof(-mWidth/mHeight/3, mWidth/mHeight/3, -1/3f, 1/3f, 0.8f,
> 2);
> // gl draws something here
> gl.glPopMatrix() ;
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to