Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 112187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:30:19+00:00 2026-05-11T02:30:19+00:00

Let’s say I want to draw a simple quad like this: glBegin(GL_QUADS); glVertex2f(-1.0,-1.0); glVertex2f(1.0,-1.0);

  • 0

Let’s say I want to draw a simple quad like this:

glBegin(GL_QUADS); glVertex2f(-1.0,-1.0); glVertex2f(1.0,-1.0); glVertex2f(1.0, 1.0); glVertex2f(-1.0, 1.0); glEnd(); 

Is there a way to draw this such that it appears behind all 3D objects and fills up the whole screen? My camera moves with the mouse, so this quad also has to appear stationary with camera movement. The purpose is to make a simple background.

Do I have to do some crazy transformations based on eye position/rotation, or is there a simpler way using glMatrixMode()?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T02:30:19+00:00Added an answer on May 11, 2026 at 2:30 am

    It sounds like what you want to do is similar to what you would when drawing a 2D HUD in a simple game, or just a background that is persistent. I’m no expert, but I did just that relatively recently. What you want to do is change the projection matrix to an orthographic projection, render your quad, and then switch back to whatever projection you had before. You can do this with the matrix stack, and it is completely independent of any camera.

    So, first:

    glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); int w = glutGet(GLUT_WINDOW_WIDTH); int h = glutGet(GLUT_WINDOW_HEIGHT); gluOrtho2D(0, w, h, 0); 

    This pushes a new projection matrix onto the projection stack (I was using glut for this project, but it should translate to just normal OpenGL). Then, I get the window width and height, and use gluOrtho2D to set up my orthographic projection.

    Next:

    glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); // Draw your quad here in screen coordinates 

    Here I just push a new, clean matrix onto the modelview. You may not need to do this.

    Lastly:

    glPopMatrix() // Pops the matrix that we used to draw the quad glMatrixMode(GL_PROJECTION); glPopMatrix(); // Pops our orthographic projection matrix, which restores the old one glMatrixMode(GL_MODELVIEW); // Puts us back into GL_MODELVIEW since this is probably what you want 

    I hope this helps. As you can tell, it requires no use of the eye position. This is mainly because when we use a new orthographic projection that perfectly fits our window, this is irrelevant. This may not put your quad in the back however, if this is executed after the other draw calls.

    EDIT: Turning off depth testing and clearing the depth buffer could help as well, as Boojum suggests.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 52k
  • Answers 52k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer My response does not directly answer your question, but I… May 11, 2026 at 6:45 am
  • added an answer There is currently no way to do this with standard… May 11, 2026 at 6:45 am
  • added an answer Update Also see my answer about how to add a… May 11, 2026 at 6:45 am

Top Members

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.