OpenGL position position after rendering (3d & # 8594; 2d)

I have an OpenGL scene with some numbers. Can you tell me what I need to do to calculate the shapes at the tops of the positions after the "rendering"? I know that I probably need to manually multiply some matrices, but I don’t know which one and how.

Thanks in advance for your help!

+4
source share
2 answers
+6
source

Do you want to know the maximum extents on your screen in pixels?

If so, the easiest way is to call gluProject for all your vertices and keep the maximum and minimum x and y positions.

It might look like this:

 GLdouble modelview[16], projection[16] GLint viewport[4]; glGetDoublev(GL_MODELVIEW_MATRIX, *modelView); glGetDoublev(GL_PROJECTION_MATRIX, *projection); glGetIntegerv(GL_VIEWPORT, *viewport); double tx, ty, tz; for(i = 0; i < VertexCount; i++) { glProject(vertices[i].x, vertices[i].y, vertices[i].z, modelview, projection, viewport, *tx, *ty, *tz); // now, the 2d position of the ith Vertex is stored in tx, ty, tz. // you can now use these values to determine the 2d-extends on your screen } 
+2
source

All Articles