## News:

LWJGL 3.3.2 released

## Rotate a textured quad at its center in glorth2d

Started by Soulice, September 28, 2004, 16:20:18

#### Soulice

Yes, I am an LWJGL newbie.
My render code is as follows and I am using the Game.java princec posted on JGO as a skeleton game class

This puts a square in the center of my 800 * 600 screen with my textue on it.  (attempting a 2d game)  Now I want to spin/rotate the quad by its center, thus my ship can rotate.
I used
but this rotates is about the 0,0 location of the screen.  I feel like I am missing a translate somewhere?
S

#### CaptainJester

Instead of using a quad, use triangles (or a triangle strip).  Draw 4 triangles that when put together have one common point, also form a quad.  This will draw your quad with its own centre in the centre, then a rotate will now give you what you want.

It is better to use a triangle strip, but this illustrates the point.  You can see there are 4 triangles drawn and they all have 1 common point.
The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities.  We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)

#### Soulice

Now I have a rotating ship.  It is in the upper left corner, now to translate to where I want it?
S

Cas

#### Soulice

this code starts ship in center and rotates around the 0,0 point (top left corner)

and this code again puts ship in center, but no rotation

phiddlesticks!  I know I can get this... :oops:
S

#### CaptainJester

Here is a modified NeHe tutorial that should explain it.  You can cut and paste it and it should work as is.  Make sure you link in the LWJGL library.
The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities.  We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)

#### Soulice

All is well, I have a centered, rotating ship.  Off to the next hurdle!

Thanks to all!

S