Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

dammit

gluPerspective()?

This topic is 5753 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

gluPerspective() accepts an argument for field-of-view angle... One for the aspect ratio and two for zNear and zFar... I supply the (almost) default arguments of 45.0f and x/y for aspect ratio. The trouble is, i''m far more used to glOrtho and glOrtho2D where I can set exactly my x and y min and max values... With my current set up, (0.0,0.0) isn''t even around the middle of the screen, it''s up and to the left a bit... Should I used glOrtho if I want to be able to set where the origin is exactly? Or is there another way? Thanks, Goo

Share this post


Link to post
Share on other sites
Advertisement
1.) When you want to use gluPerspective(), then you should know about the default values of gluLookAt():
gluLookAt (0.0, 0.0, 0.0, 0.0, 0.0, -100.0, 0.0, 1.0, 0.0);

2.) 0.0,0.0 should be in the center of viev. What are you drawing and how do you do it?

Share this post


Link to post
Share on other sites
I''m sorry, but I still don''t get it...

Previously, I''ve been (wrongly) using glOrtho to set my drawing area. This is find because I can set the width and height myself. Usually this should be set with the correct aspect ratio, otherwise (with my usual call of, eg: glOrtho(0.0f, 10.0f, 0.0f, 10.0f, -1.0f, 1.0f); ) A quad of width 1.0f and height 1.0f is not a square, as I would have thought - because naturally you''re screen hasn''t got an aspect ratio of 1:1 (1024x800, 800x600, etc).

So, the problem is this... If I set up glOrtho or gluPerspective with the correct aspect ratio, how the hell am i supposed to know where 1) the origin is, 2) the measurements left and right and up and down? for all i know the origin could be in the centre of the screen or one of the corners and it could stretch 100.0f in the x direction or perhaps 10.0f!

I''m confused and can''t really go any further without finding out how to do it correctly.

Thanks in advance,
Goo

Share this post


Link to post
Share on other sites
I am still pretty new at this, but I think in order to tell
where 0.0 is and how many units of measurement you have in any
direction has more to do with the call to

glViewport(0,0,(GLsizei)width,(GLsizei)height);

then glPerspective. I am still hazy on what perspective actually
does, but from trial and error I know if i draw a square 50 by
50 and the viewport is 50 by 50 it takes up the whole screen.

here is a code snipper that i play with pretty much from NeHe''s
site here on gamedev.


//----------------------------------------------------------------------
// Resizes the GL Window
//----------------------------------------------------------------------
BOOL GraphicSystem::ReSizeGLScene(int width,int height)
{
// Prevent A Divide By Zero By Making Height Equal To One
if(height==0)
height=1;

// Reset The Current Viewport
glViewport(0,0,(GLsizei)width,(GLsizei)height);

// Select The Projection Matrix
glMatrixMode(GL_PROJECTION);

// Reset The Projection Matrix
glLoadIdentity();
// Calculate The Aspect Ratio Of The Window
glOrtho(-50.0, 50.0, -50.0 , 50.0, -1.0, 1.0);

// Select The Modelview Matrix
glMatrixMode(GL_MODELVIEW);

// Reset The Modelview Matrix
glLoadIdentity();

return TRUE;
}

,
Christopher

Share this post


Link to post
Share on other sites
From reading the redbook a bit I find that
gluLookat() tells the camera where to sit,
where to face, and which way is up.
,
Christopher


Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!