Perspective is not reacting

Started by
3 comments, last by FreeMinded 15 years, 6 months ago
I have this here function: void Perspective( float angle, float aspectratio, float near, float far) { glMatrixMode( GL_PROJECTION); glLoadIdentity(); gluPerspective( angle, aspectratio, near, far); glMatrixMode( GL_MODELVIEW); glLoadIdentity(); }; And strangely it doesin't change a thing no matter what arguments i use: Perspective( 45.0f, 4.0f/3.0f,0.0f, 1000.0f);
Advertisement
The function you've posted looks correct. Without seeing it in context it's hard to tell what's wrong. Have you made the context current? Have you perhaps popped the projection matrix stack after calling this function? Do you overwrite the matrix somewhere else?

Maybe you could post a larger chunk of your code? Please use the 'source' tag to post code when you do.
depth buffers correct? goodluck!


Quote:Original post by FreeMinded
And strangely it doesin't change a thing no matter what arguments i use:
Perspective( 45.0f, 4.0f/3.0f,0.0f, 1000.0f);

It may or may not be related, it's hard to tell without seeing more code (post it between [source] and [/source] tags), but don't use 0.0 as your near plane. It causes unhappiness in your depth buffer - see more here.
void createcamera()	 {	Perspective( 15.0f, 0.5f,100.0f, 1000.0f);	Camera cam; //create camera object 	Color4f lcol (0.5,0.5,0.4,1);//, col (1,1,1,1);  	Light light; //create a light object	//lcol.r = 1; lcol.g = 1; lcol.b = 1; //create the RGB colour	//light.setDiffuse(lcol, true); //Set deffuse colour of RGB above	Point3f lpos; //create a point of position	lpos.x = 200; lpos.y = 200; lpos.z = 200; //set the x y z of the light    	light.setPos( lpos); //PUT the light at the x y z ^	light.Enable( 1, true); //Turn on the light 	glEnable( GL_LIGHTING);	 }


Well, it has some functions that don't belong here, light for instance. But ill clean up later. I didn't pop the projection matrixes in the whole program.
This createcamera function is called in the main, before a loop:

int main() {	bool suc = CreateWindow(scr, "TBS", R_WINDOW, 16) ; // Creates a window.		rmesh[0].LoadCSource( "cube.c");	rmesh[0].Compile ();	mcity[0].LoadCSource( "city.c");	mcity[0].Compile ();	tship.Load( "houses.tga");		createcamera ();//	createsprites ();		randomap ();		while ( IsRogueRunning() && !input::IsReleased( R_KEY_ESCAPE) )	{.......................


The perspective script is from a game engine that my friend is making with GLFW.
Im sure he was the one that messed up here, but he's not online atm... I think it worked on the previous release of the engine...

This topic is closed to new replies.

Advertisement