views:

60

answers:

2

I am beginning with OpenGL, and I want to make a very simple game with airplanes. Now I have a PNG of an airplane seen from above, and I want to draw this on the screen. Currently I only know how to draw triangles that rotate:

float angle = 0.0f;
void renderScene(void) {
  glClear(GL_COLOR_BUFFER_BIT);
  glPushMatrix();
  glRotatef(angle, 0.0f, 0.0f, 1.0f);
  glBegin(GL_TRIANGLES);
  glVertex2f(-0.5,-0.5);
  glVertex2f(0.5,0.0);
  glVertex2f(0.0,0.5);
  glEnd();
  glPopMatrix();
  glutSwapBuffers();
  angle += 0.1;
}

Can anyone help me? Thanks.

+2  A: 

This is your stash of secrets: http://nehe.gamedev.net/

By the way you will end up drawing a quad (or a triangle strip) and applying the texture onto the polygon, nothing so complicated.. but start in a precise way by looking at tutorials and understanding how OpenGL works, it would be better.

This book will be better than Nehe (since it's tailored exactly for OpenGL ES): http://opengles-book.com/

Jack
I'm using just OpenGL, not OpenGL ES. NeHe is quite cool. I'll check it out.
Time Machine
Oh sorry, my assumption derived from the objective-c tag. I supposed you were working on the iPhone :)
Jack
+1  A: 

Instead of using libpng directly, you might want to consider using DevIL. It's intended specifically for the kind of job you seem to be trying to do so it'll generally make it quite a bit easier to do (and next month, when somebody decides you should display a JPEG or maybe a TIFF instead of a PNG, it'll handle that without any major rewrite either).

Jerry Coffin