Jump to content
  • Advertisement
Sign in to follow this  
Bucky-O-Hare

OpenGL Probobly something simple? Perspective 3d

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

Hey... I've got a nice little project which I've been wirting in Visual Studio.net using C / OpenGL... Basically its probobly rather simple, but never having done this before I'm having a little bit of trouble.. Basically I've managed to plot out a room with a few items inside it... At the moment I'm just looking at it from a 2D front.... I'm not sure what I need to add in to give it perspective... Got a small amount of time let and I'm starting to panic a little... lol Asked around the class to find I've done more than any of my friends... So maybe I'm panicing over nothing... lol If anyone can give us a brief example on how to add the perspective effect in openGL I'd be greatful Thanks Bucky-O-Hare

Share this post


Link to post
Share on other sites
Advertisement
To make things appear smaller in the distance you can use:
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

The first line enables depth testing. Depth testing makes closer objects render on top of distant objects. glDepthFunc() tells OGL which type of depth testing we want to use. Finally, glHint adds in a nice and smooth perspective which renders distant objects smaller.

Good luck!

Share this post


Link to post
Share on other sites
Also make sure your using something like gluPerspective() or glFrustum() to setup the viewport rather then glOrtho

glOrtho will not render with perspective, its mostly used in stuff like CAD programs for example where you really don't want perspective.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!