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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:19:05+00:00 2026-06-14T14:19:05+00:00

I don’t know how to setup distance where I should stand to look at

  • 0

I don’t know how to setup distance

where I should stand to look at my 2d stuff(which at center there is a ball pos:1024/2,768/2)

I use gluLookAt and glPerspective to give my 2d rotated object more 3d feel

anyway here is the code I use with glOrtho:

    glMatrixMode ( GL_PROJECTION );
    glLoadIdentity(); 
    glOrthof ( 0, 1024, 768, 0, 0, 1000.0f );
    glMatrixMode ( GL_MODELVIEW );
    glLoadIdentity();

and this is when I try to setup with glPerspective and gluLookAt:

  glMatrixMode ( GL_PROJECTION );
    glLoadIdentity();
    gluPerspective(90,1024/768,0,300);
    gluLookAt(1024 * 0.5,768 * 0.5f,-????,   1024 * 0.5,768 * 0.5,0,   0,-1,0);
    glMatrixMode ( GL_MODELVIEW );
    glLoadIdentity();

Basically I just want those codes that works the same,I am not sure how to setup the fovy value of gluPerspective,and the ??? from gluLookAt,how to project the full size with width 1024,and height 768?

  • 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-14T14:19:06+00:00Added an answer on June 14, 2026 at 2:19 pm

    Well glOrtho is supposed to yield a parallel projection, so essentially using gluPerspective is going exactly the other way. If you’re hoping to find a special case of gluPerspective that acts like glOrtho, the problem is that the matrices they generate are different in some ways you can’t reach – note the bottom right corner, in particular, in what they generate:

    glOrtho

       |     2                               |
       |----------      0          0      t  |
       |right-left                         x |
       |                                     |
       |                 2                   |
       |    0       ----------     0      t  |
       |            top-bottom             y |
       |                                     |
       |                                     |
       |    0           0          -2        |
       |                        --------  t  |
       |                        far-near   z |
       |                                     |
       |    0           0          0      1  |
    
    
    gluPerspective
    
       |    f                                   |
       |  ------  0      0            0         |
       |  aspect                                |
       |                                        |
       |    0     f      0            0         |
       |                                        |
       |             zFar+zNear  2*zFar*zNear   |
       |    0     0  ----------  ------------   |
       |             zNear-zFar   zNear-zFar    |
       |                                        |
       |    0     0      -1           0         |
    

    So it’s going to be hard to set the 2/(top-bottom) and the bottom row correctly, for starters.

    If this line is the core of your issue:

    gluLookAt(1024 * 0.5,768 * 0.5f,-????,   1024 * 0.5,768 * 0.5,0,   0,-1,0);
    

    …then just set thee -???? to a positive value indicating the distance to your eye from the center of the scene (OpenGL’s positive Z points towards the viewer).

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

Sidebar

Related Questions

Don't really know how to formulate the title, but it should be pretty obvious
Don't know how to google for such, but is there a way to query
Don't know if it's I'm doing it wrong or if there's a bug (I
Don't know if there is a better way to do this, so that is
Don't know if it's stupid or reasonable question. I have methods which returns float/int
don't know if the title describes anything about what I'm trying to say but
don't know what happened in my jcrop selection. I think I pressed some keys
Don't know why but font is not displaying.Please help. CSS(in css folder): style.css: @font-face
I don't know why, but this code worked for me a month ago... maybe
Don't know if anyone can help me with this or if it's even possible.

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.