Note that there are some explanatory texts on larger screens.

plurals
  1. POGL Project doesn't work properly
    primarykey
    data
    text
    <p>I'm using code which tries to work like Glu.Project() since OpenTK doesn't support Glu.</p> <pre><code> Vector4 pos = new Vector4(s.Position.X, 0.0f, s.Position.Y, 1.0f); Matrix4 mov = new Matrix4(); Matrix4 prj = new Matrix4(); Matrix4 mpj = new Matrix4(); float[] vp = new float[4]; GL.GetFloat(GetPName.ModelviewMatrix, out mov); GL.GetFloat(GetPName.ProjectionMatrix, out prj); GL.GetFloat(GetPName.Viewport, vp); Matrix4.Mult(ref prj, ref mov, out mpj); Vector4.Transform(ref pos, ref mpj, out pos); // Final mathematics as described in OpenGL 2.1 Glu specs s.set2DPos(new Vector2f( (vp[0] + (vp[2] * (pos.X + 1) / 2.0f)), (vp[1] + (vp[3] * (pos.Y + 1) / 2.0f)) )); // Final mathematics as described in OpenGL 3 Vector specs s.set2DPos(new Vector2f( (view[2] / 2 * pos.X + view[0]), (view[3] / 2 * pos.X + view[1]) )); // Neither of them work, but in relation OpenGL 3 vector specs work better. </code></pre> <p>s is a class which primary exists as a model in 3D space at s.Position. But the values I'm getting from this are astronomically far beyond the window boundaries.</p> <p>The ModelView matrix from a breakpoint:</p> <pre><code>{(1, 0, 0, 0) (0, 0.7071068, 0.7071068, 0) (0, -0.7071068, 0.7071068, 0) (0, -141.4214, -141.4214, 1)} </code></pre> <p>The Projection matrix from a breakpoint:</p> <pre><code>{(1.931371, 0, 0, 0) (0, 2.414213, 0, 0) (0, 0, -1.0002, -1) (0, 0, -2.0002, 0)} </code></pre> <p>Am I doing something wrong or did I get something wrong? Am I missing something?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload