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

  • SEARCH
  • Home
  • 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 7855927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:31:49+00:00 2026-06-02T20:31:49+00:00

There have been many tutorials where each suggests using gluPerspective or glFrustum with a

  • 0

There have been many tutorials where each suggests using gluPerspective or glFrustum with a combination of other things, yet I’ve had difficulties setting up the right matrix. What code do I need to set up a 45˚ perspective view looking down the +z axis?

So far I have:

glShadeModel(GL_SMOOTH);
glClearColor(0,0,0,0);
glClearDepth(1);
glDepthFunc(GL_LEQUAL);
glViewport(0,0,width,height);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45,1,0.1,100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

But that doesn’t seem to work. All I get is a black screen when I attempt to draw things.

EDIT: Here’s the minimal drawing code:

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glColor3ub(255,255,255);
glBegin(GL_TRIANGLE_STRIP);
 glVertex3f(20,20,20);
 glVertex3f(20,30,20);
 glVertex3f(30,20,20);
 glVertex3f(30,30,20);
glEnd();
  • 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. Editorial Team
    Editorial Team
    2026-06-02T20:31:53+00:00Added an answer on June 2, 2026 at 8:31 pm

    EDIT: Here’s the minimal drawing code:

    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glColor3ub(255,255,255);
    glBegin(GL_TRIANGLE_STRIP);
     glVertex3f(20,20,20);
     glVertex3f(20,30,20);
     glVertex3f(30,20,20);
     glVertex3f(30,30,20);
    glEnd();
    

    Your vertex coordinates lie way outside the viewing volume. First, OpenGL by default “looks” down the negative Z axis, so your Z coordinates must be -100 < z < -0.1 for your choosen near and far clip plane.

    But even if you flipped the sign on the Z coordinate, your vertices still would lie outside the 45° FOV. (20, 0, 20) is 45° from the viewing axis, and (30, 0, 20) even farther. Try centering your vertex coodinates around (0,0,-5) like (+/-1, +/-1, -5)

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

Sidebar

Related Questions

There have been many debates about this topic already here, but none of them
If there have been commits and many changes since an earlier commit, is there
There have been many JVM languages in the recent few years including Javascript, Python,
There have been several questions posted to SO about floating-point representation. For example, the
There have been several questions over the past few days about the proper use
There have been a number of problems related to IE8 breaking Visual Studio 2005/2008.
There have been questions with answers on how to write rubygems, but what should
There have been some similar questions asked regarding Grid views, but none have been
There have been multiple discussions on this topic in the site but I am
I know there have been some similar questions to this, but they haven't helped

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.