Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok, You have your ortho matrix and quad, so whats the problem, translate modelview matrix of your quad to desired position (x,y,z=0), multiply it by ortho matrix , pass multiplied matrix to vertex shader, multiply vert position by your matrix and done :), i am not using any lookat function in my code to do this, but i have own code for matrices computation its partially code from some bada tutorial, for projection matrix i have other function.</p> <pre><code> void Letter::Ortho(Matrix* result, float fovy, float aspect, float nearZ, float farZ) { GLfloat frustumW, frustumH; frustumH = tanf(fovy / 360.0f * PI) * nearZ; frustumW = frustumH * aspect; Frustum(result, -frustumW, frustumW, -frustumH, frustumH, nearZ, farZ); } void Letter::LoadIdentity(Matrix* result) { memset(result, 0x0, sizeof(Matrix)); result-&gt;m[0][0] = 1.0f; result-&gt;m[1][1] = 1.0f; result-&gt;m[2][2] = 1.0f; result-&gt;m[3][3] = 1.0f; } void Letter::Frustum(Matrix *result, float left, float right, float bottom, float top, float nearZ, float farZ) { float deltaX = right - left; float deltaY = top - bottom; float deltaZ = farZ - nearZ; Matrix frustum; if ((nearZ &lt;= 0.0f) || (farZ &lt;= 0.0f) || (deltaX &lt;= 0.0f) || (deltaY &lt;= 0.0f) || (deltaZ &lt;= 0.0f)) { return; } frustum.m[0][0] = 2.0f * nearZ / deltaX; frustum.m[0][1] = frustum.m[0][2] = frustum.m[0][3] = 0.0f; frustum.m[1][1] = 2.0f * nearZ / deltaY; frustum.m[1][0] = frustum.m[1][2] = frustum.m[1][3] = 0.0f; frustum.m[2][0] = (right + left) / deltaX; frustum.m[2][1] = (top + bottom) / deltaY; frustum.m[2][2] = -(nearZ + farZ) / deltaZ; frustum.m[2][3] = -1.0f; frustum.m[3][2] = -2.0f * nearZ * farZ / deltaZ; frustum.m[3][0] = frustum.m[3][1] = frustum.m[3][3] = 0.0f; Multiply(result, &amp;frustum, result); } </code></pre> <p>So, with this code : </p> <pre><code>LoadIdentity(&amp;matPerspective); Ortho(&amp;matPerspective, 60.0f, TEXMANAGER.aspect, -1.0f, 20.0f); LoadIdentity(&amp;matModelview); Translate(&amp;matModelview, x ,y ,z); Scale(&amp;matModelview,size); //Rotate(&amp;matModelview, 0.0f, 1.0f, 0.0f, 1.0f); Multiply(&amp;posMatrix, &amp;matModelview, &amp;matPerspective); </code></pre> <p>And pass posMatrix to shader :)</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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