Jump to content
  • Advertisement
Sign in to follow this  
keptblue

OpenGL Frustrating 3d newb problem (please help!)

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

so.. ive been developing a 2d game using SDL and OpenGL for several months now and it's turning out lovely. i decided it might be nice to convert it to very basic 3d. it was very easy to change 2d vertices to 3d and so forth. i basically print the game to the 800x600 screen with a z depth of 1. i made some minor modifications, and voila, was able to manipulate the game view and give it some perspective. so i use glulookat( 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); and it displays the game correctly.. however, im having a really difficult time giving it the right perspective. id like to lay the screen down flat, away from the viewer. i figured all id have to do is position the viewer above and below slightly (increase y and z values) i change the cam y to glulookat( 0.0, 0.1, 4.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); and it adds some depth, but the perspective fades into the top left of the screen. im trying to center the perspective so that it fades into the center of the screen as if im walking on the 2d game . ive tried changing lots of values to no avail.. can anyone give me advice or help as to why it's behaving this way? thanks very much for the help..

Share this post


Link to post
Share on other sites
Advertisement
WIDTH=800
HEIGHT=600

glfrustum(0, WIDTH/2, HEIGHT/2, 0, 1.0, 15.0);




is it possible my x coordinates are off? my screen rectangle goes from 0,0 to 800,600


thanks a lot for the help :>

Share this post


Link to post
Share on other sites
Try glfrustum(-WIDTH/2, WIDTH/2, HEIGHT/2, -HEIGHT/2, 1.0, 15.0);

Also: do you call glMatrixMode(GL_PROJECTION) and glLoadIdentity() before the glFrustum() call?

Share this post


Link to post
Share on other sites
wow! that sure puts me one giant step in the right direction.


i really appreciate it... do you think you could explain a little bit why that is working? thanks again!

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.

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!