Adding 2D graphics in OpenGL

This is a discussion on Adding 2D graphics in OpenGL within the Game Programming forums, part of the General Programming Boards category; I have a rectangular OpenGL window. I want to display a black screen with small blocks falling down(tetris). Then i ...

  1. #1
    Politics&Cpp geek Da-Nuka's Avatar
    Join Date
    Oct 2004
    Posts
    104

    Adding 2D graphics in OpenGL

    I have a rectangular OpenGL window.
    I want to display a black screen with small blocks falling down(tetris). Then i need 2D.

    I have made the OpenGL window, but my questions are:

    1.How do I ready for 2D? (Including how to use the glOrtho function)

    2.How do I make a custom coordinatesystem which I can actually understand?

  2. #2
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    something like this
    Code:
    void init(GLint w,GLint h){
       glViewport (0, 0, (GLsizei) w, (GLsizei) h);
       glMatrixMode (GL_PROJECTION);
       glLoadIdentity ();
       gluOrtho2D (0.0, (GLdouble) w, 0.0, (GLdouble) h);
    }
    I don't really understand your custome coordinates question. I think you mean how do I know where the points are. Well, if you look at the GLortho2D function you will notice that the w axis goes from 0 to w(usually 640, 800, 1024), the same for h. Then you just pick points from there. Is that what you mean?

  3. #3
    Politics&Cpp geek Da-Nuka's Avatar
    Join Date
    Oct 2004
    Posts
    104
    exactly d:
    I didnt understand a I am sillyI am sillyI am sillyI am silly of the OpenGL coordinate system..


    I am silly? Somehow, i get the feeling a moderator has seen my post ...or isnt it allowed to write words like
    TIHS?
    Last edited by Da-Nuka; 12-25-2004 at 02:28 PM.

  4. #4
    ---
    Join Date
    May 2004
    Posts
    1,379
    It's filtered

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >i get the feeling a moderator has seen my post
    We ruthlessly filter bad grammar. Even if the word weren't censored, it wouldn't make sense for that use anyway.
    My best code is written with the delete key.

  6. #6
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    It causes problems when talking about the << >> operators (in the binary sense).

  7. #7
    Politics&Cpp geek Da-Nuka's Avatar
    Join Date
    Oct 2004
    Posts
    104
    ...but why use roundabouts like glu when i can use pure API?

  8. #8
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    Closed. If anybody wants it reopened, PM me.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL and 2D Masking
    By dxfoo in forum Game Programming
    Replies: 7
    Last Post: 03-08-2008, 01:00 PM
  2. OpenGL graphics
    By Zishaan in forum Game Programming
    Replies: 6
    Last Post: 04-05-2007, 11:59 AM
  3. OpenGL: Switching between 2D and 3D
    By Eber Kain in forum Game Programming
    Replies: 11
    Last Post: 06-15-2004, 10:12 PM
  4. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 11:14 PM
  5. Adding bitmap as a resource for texture mapping in OpenGL
    By Unregistered in forum Game Programming
    Replies: 2
    Last Post: 03-03-2002, 02:03 PM

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