In OpenGL OpenGL, you can change your view by transforming the matrix, and to get the transformation matrix, You can use g L G E T F L O A T V glGetFloatv glGetFloatv or g L G E T D O ub L E v glGetDoublev The former is the matrix you want to fetch, and the latter is a pointer that stores the obtained data where the pointer points.

glGetFloatv(GL_PROJECTION_MATRIX, mat);	// Get the projection matrix
glGetDoublev(GL_MODELVIEW_MATRIX, mat);	// Get the viewmodel matrix
Copy the code

If I want to send data to the transformation matrix, G L Loa D Ma T r I xf glLoadMatrixf or G L L O a D Ma T r I xd glLoadMatrixd glLoadMatrixd There is only one parameter, which is the data to be transferred, but you need to implement the switch to the matrix of the data to be transferred.

glMatrixMode(GL_MODELVIEW);	// Switch to the Viewmodel matrix
glLoadMatrixf(mat);			// Pass values to the matrix
glMatrixMode(GL_PROJECTION);// Switch to the projection matrix
glLoadMatrixd(mat);			/ /...
Copy the code

Note that these matrices are not in regular main order by row, but by column, and M A T mat is not a two-dimensional array of 4∗4, 4*4, 4∗4, but an array of 16, 16 and 16 units in space, which requires special attention.

With that said, the key to the problem is that the problem is easy to describe. At some point, there will always be a situation where you can get the transformation matrix, but you can’t load the transformation matrix (assign a value to the matrix), run without any error message, and the view doesn’t change at all. G lLoadMatr I x glLoadMatrix glLoadMatrix function does not implement the function.

G L Loa D Ma T r I x glLoadMatrix glLoadMatrix

glBegin(GL_POINTS);
Copy the code

The following uses…

glEnd(a);Copy the code

That is, it is stuck between these two functions. This part is mainly for rendering, and it cannot modify the transformation matrix, so it just needs to put G L L O A D M A T R I X glLoadMatrix glLoadMatrix outside these two functions.

This is very pit, according to the principle of this situation should report an error, but when the compile run, a little bit of error message is not, even a little warning, too pit.