Hello, please tell me how you can extract the matrix with the coordinates of the vertices of the shape after the transformation with the commands glRotate, glTranslate, glScale.

I need to update the vertex matrix using the new coordinates after the transformation (the matrix itself is stored in the object variable).

Added from comment .

//Класс фигуры @interface Square:NSObject { CGFloat vertexData[8]; } @end //View for drawing @implementation OpenGLView -(void)draw{ glClearColor(0.78f, 0.78f, 0.78f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glColor4f(1.0, 0.0, 0.0, 1.0); // SQUARE transformations glTranslatef(point.x, point.y, 0.0); glRotatef(squareFigure.rotationAngle, 0, 0, 1); glTranslatef(-point.x, -point.y, 0.0); glVertexPointer (2, GL_FLOAT , 0, [squareFigure getVertexData]); //glEnableClientState (GL_VERTEX_ARRAY); glDrawArrays (GL_TRIANGLE_FAN, 0, 4); glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); [context presentRenderbuffer:GL_RENDERBUFFER_OES]; @end 
  • Throw off the code, otherwise it is a fortune telling on the coffee grounds. - Michael Nikolaev
  • Moved to the question. - Sergey Picnic

1 answer 1

First, maybe you meant the matrix of the model-specific transformation, since new coordinates of the vertices are calculated thanks to her. In addition, the matrix of vertices does not exist.

Secondly, in OpenGL any value is retrieved with the glGet*(type,pointer) command, where type is what you want to retrieve, pointer is the pointer where the extracted value should be saved.

In C, to copy, for example, a matrix of model-specific transformations into a double-precision array of real numbers, use the following code:

 double mvmat[16]; glGetDoublev(GL_MODELVIEW_MATRIX,mvmat);