PDA

View Full Version : Perspective problem



darkrappey
11-18-2006, 12:52 AM
I'm trying to implement OpenGL's perspective calculations. I thought this would be a very simple task, and it should be, but for some reason there does not appear to be perspective. Things moved in Z do not appear bigger or smaller. I can't post every line of code in the project for it is quite long and i don't know what is causing the problem, so I tried to narrow it down to a few lines that relate to the perspective. If this doesn't include all the gl calls that are suspects of this problem please tell me and ill bee happy to post other sections of the code.

The code:


flags = SDL_OPENGL | SDL_FULLSCREEN;

GLsizei width = idConfig.resX;

GLsizei height = idConfig.resY;

if (idConfig.resY==0) // Prevent A Divide By Zero By

{

idConfig.resY=1; // Making Height Equal One

}

screen = SDL_SetVideoMode(idConfig.resX, idConfig.resY, 0, flags);

glViewport(0,0,width,height);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluPerspective(45,(GLdouble)width/(GLdouble)height,1,10.0);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

glDepthFunc(GL_LEQUAL);

glEnable(GL_DEPTH_TEST);

darkrappey
11-18-2006, 12:55 AM
Oh by the way, it may be worth mentioning that the idConfig variable is a structure that contains configuration for the init.

.resX and .resY are integers that stand for resolution in the X/Y.

I'm also using SDL (as you can see) to set the video mode.

I have noticed in some other project they call glHint with a value that to Perspective. Do I need to call that? If so what was it exactly?

darkrappey
11-23-2006, 01:06 AM
Never mind I fixed it, It was in GL_PROJECTION matrix which breaks perspective.