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 8286055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:37:02+00:00 2026-06-08T11:37:02+00:00

Now I initialize my OpenGL view by this code: glLoadIdentity(); glViewport(0, 0, w, h);

  • 0

Now I initialize my OpenGL view by this code:

glLoadIdentity();
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);               
glOrtho(0.0, w, 0.0, h, -1.0, 10.0); 

And I it looks like it should look.
But its Othological view. And I want Perspective view. So I try to initialize that with:

glLoadIdentity();
glViewport(0, 0, w, h);
glMatrixMode(GL_MODELVIEW);
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);               
gluPerspective(60, w/h, 0.1, 100);
glTranslatef(0.0,0.0,-5.0);
  • 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-08T11:37:03+00:00Added an answer on June 8, 2026 at 11:37 am

    What am I doing wrong?

    Your first misconception is thinking in terms of “initialization”. OpenGL is a state machine and you’re expected to set the state as required throughout your program. Those calls you call “initializing” actually belong into the drawing code.

    Second: The projection matrix is sort of the “lens” of OpenGL, hence all sorts of projection belong there, and only there, which also applies to gluPerspective (which is not part of OpenGL but GLU, a third party library, that eventually calls glFrustum).

    In your original code you set the ortho limits to the viewport size, i.e. you’re going to see the world space coordinate rate (0,0) to (width,height). Everything in that worldspace volume will fill the view. In the case of perspective you got a viewing volume symmetrically centered around the Z axis and depending on the near and far planes will usually cover something like about (-near*aspect, -near) to (+near*aspect, near) at the near clipping plane. In your case that would be something like -0.1,-0.1 to 0.1,0.1, which is a very small volume and will just largely magnify your image.

    How to fix this?

    1. Understand how OpenGL works
    2. Stop cargo cult programming, i.e. just copy and pasting code from tutorials into places that might look right, without really understanding what’s going on.

    Now in your case I strongly doubt you actually want perspective for that “Drop your image here” backdrop, but only for whatever is drawn on top of this. Remember that I told you OpenGL is a state machine? Well, here’s why: Because you should switch projections between those two drawing stages:

    1. draw your backdrop using a ortho projection
    2. draw whatever else you want with a perspective projection on top.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've ported 1-1 this code from C++/OpenGL to C# SharpGL: float[] cameraAngle = {
Now.js quotes: Simply pass a connect or express http server in nowjs.initialize and this.user.session
So I used the code here to first initialize the OpenGL in my Live
i'm using intents to initialize the following actions now besides this gallery option i
Why is the jquery selector not working? View Views.Now = Backbone.View.extend({ template:mytemplate, initialize:function ()
What I want to do now is to initialize a private repository on my
I have an object now: class Items attr_accessor :item_id, :name, :description, :rating def initialize(options
So I create a class in ruby: class User def initialize end end Now
Now I'm not sure if this is something I'm doing wrong, or something thats
I am getting this error: ERROR libEGL call to OpenGL ES API with no

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.