Exactly what matrices does OpenGL extend in the pipeline?

Recently, I have been compiling an OpenGL program, and I have reached the point where I code in my transformation matrices (model transformation, camera transformation, and perspective transformation). So far, I have been calculating the model transformation and sending it to the uniform and multiplying it by the vertex shader. Recently, I added a camera and promising transformations to a matrix, which is sent to the form in the shader.

But now many things are not working, and some things I can’t understand:

Firstly, this webpage says that OpenGL automatically divides everything into component Z positions (for use with perspective conversion), but I cannot figure out where this happens, and secondly:

There are number of resources that mention OpenGL functions such as glFrustumf (), glMatrixMode (), glPushMatrix (), glPopMatrix (), glLoadIdentity (), gRotatef (), etc. All these functions that seem to be missed and change the matrices inside OpenGL, where I don’t have to worry about them at all in the vertex shader.

So, now I completely lost my idea of ​​how transformations are performed in OpenGL. Do we compute them ourselves and multiply them in the vertex shader or send parameters to OpenGL and let it do all the work for the API or something else completely different?

thank

+4
source share
2 answers

Vista Divison

ModelViewProjection, . x, y z w- -w w. .

( w-) , -1 1, " ". OpenGL gl_Position. ( ) , .

, OpenGL (yay!). .

, glFrustumf(), glMatrixMode(), glPushMatrix(), glPopMatrix(), glLoadIdentity(), gRotatef() .., .

+4

glMatrixMode() , , (.. glTranslate(), glRotate() ..). GL_MODELVIEW, GL_PROJECTION, .

glFrustumf() . OpenGL , , , GPU.

" Z". " W", . , , 3D- OpenGL 4 (x, y, z) 4- (x, y, z, w). , , - 4 4 . , 3D-, , , 4x4.

w, , GLSL. OpenGL . , , . :

gl_position=proj*view*model*vec4(in_vertex,1);

-, , . , , . w , , glFrustum(), [-1,1] x [-1, 1] x [-1,1]. .

+4

All Articles