Frustrating 3d newb problem (please help!)
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..
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 :>
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 :>
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?
Also: do you call glMatrixMode(GL_PROJECTION) and glLoadIdentity() before the glFrustum() call?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement