Results 1 to 3 of 3

Thread: How to draw a screen aligned QUAD?

  1. #1
    Member Contributor
    Join Date
    Mar 2011
    Posts
    86

    How to draw a screen aligned QUAD?

    if i initialize the Viewport like this:
    glViewport(0, 0, screenWidth, screenHeight);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(60.0f, (float)(screenWidth)/screenHeight, 1.0f, 100.0f);
    glMatrixMode(GL_MODELVIEW);

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Mar 2009
    Location
    Karachi, Pakistan
    Posts
    810

    Re: How to draw a screen aligned QUAD?

    Hi,
    You will need to use the orthographic projection for this. Something along these lines should work.
    Code :
    void OnResize(int nw, int nh) {
       glViewport(0,0,nw,nh);
       glMatrixMode(GL_PROJECTION);
       glLoadIdentity();
       glOrtho(0,1,0,1,0,1);
       glMatrixMode(GL_MODELVIEW);
    }
    Then use this code to draw the quad
    Code :
    void DrawFullScreen() {
       glBegin(GL_QUADS);
          glVertex2f(0,0);
          glVertex2f(1,0);
          glVertex2f(1,1);
          glVertex2f(0,1);
       glEnd();
    }
    See if this helps.
    Regards,
    Mobeen

  3. #3
    V-man
    Guest

    Re: How to draw a screen aligned QUAD?

    Here's another one

    Code :
    void OnResize(int nw, int nh) {
       glViewport(0,0,nw,nh);
       glMatrixMode(GL_PROJECTION);
       glLoadIdentity();
       glMatrixMode(GL_MODELVIEW);
    }

    Code :
    void DrawFullScreen() {
       glBegin(GL_QUADS);
          glVertex2f(-1,-1);
          glVertex2f(1,-1);
          glVertex2f(1,1);
          glVertex2f(-1,1);
       glEnd();
    }

Similar Threads

  1. perfect screen quad aligned and GL_NEAREST
    By qnext in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 09-06-2013, 09:31 AM
  2. How can I draw a quad that covers the whole screen
    By ei05tbe in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 07-14-2010, 10:19 AM
  3. draw fullscreen quad...
    By lobbel in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-20-2010, 09:03 AM
  4. screen aligned quad
    By Pswin in forum OpenGL: GLSL
    Replies: 6
    Last Post: 08-26-2008, 05:42 AM
  5. How to draw more than one quad (connect together) on the screen?
    By beachboy1976 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-27-2002, 01:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean