# OpenGL ModelView matrix

Hello I am trying to understand matrix operations behind OpenGL and I have some questions.

1- When we first create a simple window using glut and opengl, we use such a command below to draw a simple triangle.

glBegin(GL_TRIANGLE);
glVertex3f(0.25, 0.25, 0.0); // coordinate 1
glVertex3f(0.75, 0.25, 0.0);
glVertex3f(0.75, 0.75, 0.0); // coordinate 3
glEnd();


Does this drawing take plece in object coordinate sytem or at other coordinate sytems ?

Assume that, I applied a transformation using glTranslate(), so this translation manipulates the modelview matrix. Now if I apply the command above again

glBegin(GL_TRIANGLE);
glVertex3f(0.25, 0.25, 0.0); // coordinate 1
glVertex3f(0.75, 0.25, 0.0);
glVertex3f(0.75, 0.75, 0.0); // coordinate 3
glEnd();


Is this drawing still done in object space coordinates and transformed to eye space using modelview matrix ?

edit:

at first when you use command glvertex(0,0,0) , you draw a point at (0,0,0) in both object, world and eye coordinates it is (0,0,0). of course this is done after modelview matrix is cleared using gloadidentity().

now apply the command gltranslate(2,0,0) , and again use command glvertex(1,0,0), now you draw a point at (3,0,0) . this is good but which coordinate system (3,0,0) is represented in ? do you draw in eye coordinates (3,0,0) ?

Is my thought below true ?

I think that glvertex(1,0,0) draws a point in object coordinate (1,0,0) , and since model view 4x4 matrix now is not an identity but has a "2" at the first row and fourt column because we applied gltranslate(). if we multiply our new modelview matrix with (1,0,0) in obj. coordinates, now we have (3,0,0) in eye coordinates .

I'm assuming you've set up your viewport and the projection matrix. Also i'm assuming that eye space is camera space and that object space is model space.

The model-view matrix represents the combined transformations you're applying to a set of vertices. A camera is just another transformation applied to your model. Whether you consider your model being in camera space or world space depends on whether a particular transformation represents moving an object in world space or moving the whole world to be drawn in respect to the camera position.

In your first example you aren't applying any transformations, so you're drawing in model space. Now in the second example, it depends what that translation represents. Does it represent the camera moving, or the object moving in world space? It all depends, but it's definitely not being drawn in model space anymore, since you moved it.

Is this drawing still done in object space coordinates and transformed to eye space using modelview matrix ?

You can't first draw something and then transform it. A 3D world doesn't exist inside of a graphic's card. OpenGL, especially the old one you're using, is like a state machine. You set the state (matrices, light, etc.), submit input (vertices, normals, etc.) and receive output (an image in the frame buffer).

now apply the command gltranslate(2,0,0) , and again use command glvertex(1,0,0), now you draw a point at (3,0,0) . this is good but which coordinate system (3,0,0) is represented in ? do you draw in eye coordinates (3,0,0) ?

Technically speaking, all drawing is done in eye coordinate space since that's what you end up seeing in the end, so the answer is yes. As i said, the whole concept of spaces comes from the separation of the stages of transformation. A translation by itself doesn't say much of anything.

I think that glvertex(1,0,0) draws a point in object coordinate (1,0,0) , and since model view 4x4 matrix now is not an identity but has a "2" at the first row and fourt column because we applied gltranslate(). if we multiply our new modelview matrix with (1,0,0) in obj. coordinates, now we have (3,0,0) in eye coordinates.

You take an object's position, transform it from model to camera space using the model-view matrix. Yes, what you said is true.