1
votes

I am trying to learn some OpenGL basics by reading OpenGL Superbible.

I am at the beginning of the 4th chapter and I have a question about the transformations.

Firstly, relevant link:http://www.songho.ca/opengl/gl_transform.html

If I understand this pipeline (so to speak) right, if in my code I would have something like this

const float vertexPositions[] = {
0.75f, 0.75f, 0.0f, 1.0f,
0.75f, -0.75f, 0.0f, 1.0f,
-0.75f, -0.75f, 0.0f, 1.0f,
};

those coordinates are in so called object space coordinates, and I can specify each value as something in [-1,1] range.

After applying viewmodel matrix, each vertex coordinates can be any number and those coordinates will be in so called eye coordinates.

After applying projection matrix (be it perspective projection) we are in clip space, and still the numbers can have any possible value.

Now here is the point I am wondering about. In this page it is said that for each vertex x,y,z coordinate we are diving it by fourth value w, which is present because we are using homogeneous coordinate system, and after the division, x,y,z are in range [-1,1].

My question is, how can be sure that after all those transformations the value of w will be sufficient enough, that after dividing x,y,z by it we will get something in range [-1,1]?

1

1 Answers

2
votes

… object space coordinates, and I can specify each value as something in [-1,1] range.

You're not limited in the range for object coordinates.

My question is, how can be sure that after all those transformations the value of w will be sufficient enough, that after dividing x,y,z by it we will get something in range [-1,1]?

The range [-1, 1] is the range of what will be in the viewport after transformation. Everything outside that range is outside the viewport and hence clipped. There's nothing to ensure about this. If things are in range, they are visible, if not, they are outside the viewport window.