OpenGL applies it's transforms in reverse so maybe swap the two translates. Sounds lame but this is the sort of thing you get right once and don't look at again for sometime. Also make sure your matrix mode is GL_MODELVIEW.

Leigh

On 6/18/2010 11:58 AM, Paolo wrote:
Hi leigh!
I've tried, but it doesn't work... the quad goes in a wrong position :
(

My quad has these coordinates

                 //vertex bottom left
                vertex[0] = 9.5f;
                vertex[1] = 10f;
                vertex[2] = 0.0f;
                //top left
                vertex[3] = 9.5f;
                vertex[4] = 11.0f;
                vertex[5] = 0.0f;
                //bottom right
                vertex[6] = 10.5f;
                vertex[7] = 10f;
                vertex[8] = 0.0f;
                //top right
                vertex[9] = 10.5;
                vertex[10] = 11f;
                vertex[11] = 0.0f;

and this is my draw function...

public void draw(GL10 gl){
                gl.glPushMatrix();
                gl.glTranslatef(-10, -10.5f, 0);  //to the origin

                gl.glRotatef(45, 0, 0, -1);   //rotate

                gl.glTranslatef(10, 10.5f, -2.0f);   //back to previous position

                // Enabled the vertices buffer for writing and to be used during
                // rendering.
                gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
                // Specifies the location and data format of an array of vertex
                // coordinates to use when rendering.
                gl.glVertexPointer(3, GL10.GL_FLOAT, 0, markerBuffer);
                gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, NUMERO_VERTICI);
                // Disable the vertices buffer.
                gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
                gl.glPopMatrix();

        }




On 18 Giu, 17:31, Leigh McRae<[email protected]>  wrote:
Translate the quad to the origin, rotate, translate back.

Leigh

On 6/18/2010 11:12 AM, Paolo wrote:





Hi guys!
I'm a newbie in OpenGL. :D
I'm trying to rotate a quad around its center.
This is my scenario: I've a quad, drawn with TRIANGLE_STRIP, at
specified coordinates. Now I want to rotate of 45 degrees around its
center, without move it from its position, not around the origin of
the aces.
I hope you are able to understand my english... :)
How can I do that?
Thanks
Paolo
--
Leigh McRaewww.lonedwarfgames.com

--
Leigh McRae
www.lonedwarfgames.com

--
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