View Full Version : urgent exam help pls!.what is the current matrix?

theju

05-25-2011, 05:47 AM

in opengl i know that there is a projection matrix and a modelview matrix.but then what is the current matrix?

in the code below,glLoadIdentity() is used to load identity matrix into what matrix?why is it needed?

void display()

{

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

glLoadIdentity();

tetrahedron(n);

glFlush();

}

without the glLoadIdentity() function the object i draw gets smaller and smaller each time i minimize and maximize.

mobeen

05-25-2011, 06:23 AM

The loadidentity call is similar to clearing a variable. Its is setting the current modelview matrix to identity.

Explanation:

Suppose you have a program which does this in the display function;

int x=0;

int dx=1;

void display(){

x+= dx; //similar to translate call

}

In the above code, the x variable will increment each time and then the object will move in the x direction 1 units. What we wanted was to shift the object to pos x=1; So the solution we do is this,

void display(){

x=0; //similar to loadidentity

x+= dx; //similar to translate call

}

NOw x will have a value of 1 and it will remain 1. I hope this helps u in understanding what is going on.

mhagain

05-25-2011, 06:39 AM

Which is the "current matrix"? The first line of this will tell you the answer: http://www.opengl.org/sdk/docs/man/xhtml/glMatrixMode.xml

The last line of the "description" section also contains more useful info.

Shouldn't you already know this if you're getting to exam time?

Powered by vBulletin® Version 4.2.5 Copyright © 2018 vBulletin Solutions Inc. All rights reserved.