Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>With OpenGL up to version not including 3 you can replace it with the following:</p> <pre><code>void GL2_SetTransform(float x, float y, float dx, float dy, float rot, float hscale, float vscale) { glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // we start off a identity matrix // Instead of testing for 0, you should test for some // threshold, to increase numerical stability if( fabs(vscale) &gt;= 1e-7 ) { glTranslatef(-x, -y, 0.0f); glScalef(hscale, vscale, 1.0f); glRotatef(-rot, 0., 0., 1.); glTranslatef(x+dx, y+dy, 0.0f); } } </code></pre> <p>OpenGL-3 deprecated the matrix manipulation functions, so the code looks almost identical to the DirectX version (I changed a few things to improve stability):</p> <pre><code>typedef float mat4x4[4][4]; // OpenGL uses column major mode, so the first // index selects column, the second row - this is // opposite to the usual C notation. // The following functions must be implemented as well. // But they're easy enough. // function to set the matrix to identity void mat4x4_identity(mat4x4 *M); // those functions transform the matrix in-place, // i.e. no temporaries needed. void mat4x4_rotX(mat4x4 *M, float angle); void mat4x4_rotY(mat4x4 *M, float angle); void mat4x4_rotZ(mat4x4 *M, float angle); void mat4x4_scale(mat4x4 *M, float x, float y, float z); void mat4x4_translate(mat4x4 *M, float x, float y, float z); void GL3_SetTransform(float x, float y, float dx, float dy, float rot, float hscale, float vscale) { mat4x4 view; mat4x4_identity(view); if( fabs(vscale) &gt;= 1e-8 ) { mat4x4_translate(view, -x, -y, 0.0f); mat4x4_scale(view, hscale, vscale, 1.0f); mat4x4_rotZ(view, -rot); mat4x4_translate(view, x+dx, y+dy, 0.0f); } _render_batch(); // get_view_uniform_location returns the handle for the currently loaded // shader's modelview matrix' location. Application specific, so you've to // come up with that yourself. glUniformMatrix4fv(get_view_uniform_locaton(), 1, false, view); } </code></pre> <p>I put up source code for the matrix manipulation functions up here: <a href="http://pastebin.com/R0PHTW0M" rel="nofollow">http://pastebin.com/R0PHTW0M</a> They're not using exactly the same naming scheme, though.</p>
 

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