Wednesday, August 29, 2012

Re: [android-developers] using pixel coordinates in opengl es 2

You could do that and set the matrix via glLoadMatrix(), however a
more usual way would be to call

glOrthof (0, w, h, 0, ...);

Check glOrhtof() docs and note I'm passing height for bottom and zero
for top which achieves the swap.

(Also note that GLES can't render quads directly. Your square has to
be rendered as two triangles.)


On Wed, Aug 29, 2012 at 7:53 PM, Harri Smått <harism@gmail.com> wrote:
> Hi,
>
> I might be wrong but I think you can create an orthographic projection matrix for this purpose using Matrix.orthoM. Just provide it with top=0, bottom=height, left=0, right=width.
>
> --
> H
>
> On Aug 29, 2012, at 8:50 PM, guich <guihazan@gmail.com> wrote:
>
>> Hi,
>>
>> I downloaded and played with the opengl sample at
>> http://developer.android.com/training/graphics/opengl/draw.html
>>
>> However, it uses the standard coordinate system for opengl, where 0,0
>> is at the center of the screen and -1,-1 at top-left and 1,1 at bottom-
>> right.
>>
>> I want to use the screen's coordinate, where 0,0 is at top-left and
>> width,height is at bottom-right.
>>
>> I already tried a dozen things, read about 30 articles, but since i'm
>> a newbie at opengl, i'm still stumped.
>>
>> Can someone tell what it has to be done to change the coordinate so
>> that the given rectangle
>>
>> static float squareCoords[] = { 10f, 10f, 0.0f, // top left
>> 10f, 20f, 0.0f, // bottom left
>> 20f, 20f, 0.0f, // bottom right
>> 20f, 10f, 0.0f }; // top right
>>
>> ... is shown at screen?
>>
>> thanks
>>
>> guich
>>
>> --
>> 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+unsubscribe@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>
> --
> 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+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment