Jump to content
  • Advertisement


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


perspective question

This topic is 6185 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

alright in my program it started out using an ortho view but when i try to convert it to a perspective view, my scene doesnt show up where it should be on screen. here is my function

void ChangeSize(int w, int h)

	GLfloat FAspect,
			nRange= 150.0f;

	// Prevent a divide by zero

	if(h == 0)
		h = 1;

	// Set Viewport to window dimensions

    glViewport(0, 0, w, h);

	FAspect = (GLfloat)w / (GLfloat)h;
	// Reset projection matrix stack


	// Establish clipping volume (left, right, bottom, top, near, far)
    if (w <= h) 
		glOrtho (-nRange, nRange, -nRange*h/w, nRange*h/w, -nRange, nRange);
		glOrtho (-nRange*w/h, nRange*w/h, -nRange, nRange, -nRange, nRange);
	// Reset Model view matrix stack



Share this post

Link to post
Share on other sites
one thing the near and far clipping planes should always be positive.
so try: gluPerspective(60.0f, FAspect,1.f , 500.f);

and then use gluLookAt(...) to position the camera

something like this: gluLookAt( 0.f,0.f,-150.f, // eye
0.f,0.f,0.f, // look at
0.f,1.f,0.f); // up dir.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!