Thread: OpenGL, quads not displaying

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    55

    OpenGL, quads not displaying

    sorry i wasnt using glMatrixMode(...); problem fixed now,

    on another note, can someone explain to me whether using glOrtho means i should remove glMatrixMode or if setting the orthographic view is entirely separate from the matrix mode? and which matrix mode should i use if this is the case? I'm making a 2d game and want the view to look like that of super smash bros on a platform

    thanks
    Last edited by Astra; 07-03-2011 at 07:38 AM.

  2. #2
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    glMatrixMode just makes a selection, it doesn't do anything in of itself.
    glOrtho will "multiply the current matrix with an orthographic matrix"
    glOrtho's counterpart is glFrustum, which will "multiply the current matrix by a perspective matrix".
    In a fully 2D game, and orthographic view would probably be best.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    You probably shouldn't edit away an existing post, it makes the thread hard to read and it's just disconcerting. Also if you have a new question, placing it in a new post will enable others to see that the thread has changed. I'd say that editing should be reserved for fixing typos and adding clarifications.

    glOrtho() "[multiplies] the current matrix with an orthographic matrix" according to the docs. So in order to have it affect your viewport you need to apply it to the GL_PROJECTION matrix. (Essentially it's just like a glMultMatrix() call, which of course applies to the matrix corresponding to the current matrix mode.) And most other operations use GL_MODELVIEW so you should switch back after you call glOrtho(). So generally you'd use something like
    Code:
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(...);
    glMatrixMode(GL_MODELVIEW);
    You could have found that out in about forty-six seconds by googling "glortho example", by the way.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL Again, Loading Textures onto Quads
    By Shamino in forum Game Programming
    Replies: 7
    Last Post: 05-07-2005, 08:14 PM
  2. Best way to draw several quads?
    By VirtualAce in forum Game Programming
    Replies: 2
    Last Post: 04-26-2004, 04:50 PM
  3. Please review algorithm for filling in quads
    By Shadow12345 in forum Game Programming
    Replies: 1
    Last Post: 10-17-2002, 07:45 AM
  4. Displaying FPS in openGL...
    By Jackmar in forum Game Programming
    Replies: 1
    Last Post: 05-22-2002, 07:40 PM
  5. Collision with quads?
    By SyntaxBubble in forum Game Programming
    Replies: 6
    Last Post: 01-18-2002, 06:17 PM