Frage

Might be a weird question, but I'm fairly unexperienced with OpenGL's 3D, so can somebody please tell me how to draw a simple 2D box (C++ preferred) when:

  GL_PROJECTION_MATRIX = [1.125, 0.00, 0.00, 0.0]
                         [0.000, 2.00, 0.00, 0.0]
                         [0.000, 0.00, -1.0, 0.0]
                         [0.000, -1.0, 0.00, 1.0]

  GL_MODELVIEW_MATRIX  = [1.0, 0.0, 0.0, 0.0]
                         [0.0, 1.0, 0.0, 0.0]
                         [0.0, 0.0, 1.0, 0.0]
                         [0.0, 0.0, 0.0, 1.0]

Changing these two is not possible due to external code.

War es hilfreich?

Lösung

What fixed function GL will do is multiply each vertex first by modelview, then by the projection matrix and finally divide by the (clip space) w component to reach NDC space. In NDC space, the viewing volume is represented by the cube [-1,1] along all 3 dimensions.

So, in general, knowing the matrices that are used, you can project the viewing volume back into eye or object space by inverting that chaing of transformations and trasforming back the corner points of the NDC cube (assuming the matrices can be inverted, what usually is the case).

Assuming the typical matrix storage order of fixed function GL, this prjection matrix is some sort of orthogonal projection, so there is no perspectivic distortion and the viewing volume will be a cuboid in eye space/object space.

If one uses the matrices you did specify, then everything drawing in x in [-0,8889, 0.8889] (left, right), y in [0,1] (bottom/top) and z in [-1,1] (far!, near) should be visible.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top