Sign in to follow this  
FreeMinded

Perspective is not reacting

Recommended Posts

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);

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this