OpenGL Primitive Drawing

This is a discussion on OpenGL Primitive Drawing within the Game Programming forums, part of the General Programming Boards category; Hello. I'm making a 2d Battleship game, and everything is going well, except for the graphics. I made 2 grids ...

  1. #1
    Hi ay_okay's Avatar
    Join Date
    Dec 2004
    Location
    Here
    Posts
    69

    OpenGL Primitive Drawing

    Hello. I'm making a 2d Battleship game, and everything is going well, except for the graphics. I made 2 grids for attack and defense. To position them, I used
    Code:
    glTranslatef(x, y, 0.0);
    But now the plane changed. When I want to position the markers that show where you hit, I position them with glTranslatef as well, and this makes the plane change again, and I don't know where to put my markers now because they run off the grid. Is there a way to reset the plane, so 0,0 is in the middle again, or is there a better way to position the markers. Any help would be appreciated!

  2. #2
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,904
    Either use glLoadIdentity(); or use the matrices:

    Code:
    glPushMatrix();  // Saves the current translations
    
       do all your glTranslates here...
    
    glPopMatrix();   // Resets the old translations

  3. #3
    Hi ay_okay's Avatar
    Join Date
    Dec 2004
    Location
    Here
    Posts
    69
    Thanks jverkoey, that did it!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you make games without drawing in OpenGL?
    By Jake.c in forum Game Programming
    Replies: 9
    Last Post: 02-11-2009, 10:00 AM
  2. drawing my ui (openGL)
    By hannibar in forum Game Programming
    Replies: 1
    Last Post: 04-12-2006, 08:24 AM
  3. Why only 32x32? (OpenGL) [Please help]
    By Queatrix in forum Game Programming
    Replies: 2
    Last Post: 01-23-2006, 02:39 PM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 01:34 PM
  5. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 07:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21