diff options
| author | Andre Weissflog <floooh@gmail.com> | 2019-04-02 11:43:59 +0200 |
|---|---|---|
| committer | Andre Weissflog <floooh@gmail.com> | 2019-04-02 11:43:59 +0200 |
| commit | 35f6c9c502dd564220f4ea3c25b5a66d6218159e (patch) | |
| tree | 20c695d8e481f10862e91b564aa7bdbb808cd682 /util | |
| parent | a72edd2797d5d355468ba50dc6b6ac49b49a4eff (diff) | |
sokol_gl.h: fix memory layout of the mult- and load-matrix funcs
Diffstat (limited to 'util')
| -rw-r--r-- | util/sokol_gl.h | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/util/sokol_gl.h b/util/sokol_gl.h index e277ab5d..029e34b8 100644 --- a/util/sokol_gl.h +++ b/util/sokol_gl.h @@ -32,11 +32,6 @@ Matrix functions are taken from MESA and Regal. - TODO v1 - ======= - - check that the mult_matrix and load_matrix functions have the same - memory layout as GL - FEATURE OVERVIEW: ================= sokol_gl.h implements a subset of the OpenGLES 1.x feature set useful for @@ -1851,30 +1846,28 @@ SOKOL_API_IMPL void sgl_load_identity(void) { SOKOL_API_IMPL void sgl_load_matrix(const float m[16]) { SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); _sgl.matrix_dirty = true; - _sgl_transpose(_sgl_matrix(), (const _sgl_matrix_t*) &m[0]); + memcpy(&_sgl_matrix()->v[0][0], &m[0], 64); } SOKOL_API_IMPL void sgl_load_transpose_matrix(const float m[16]) { SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); _sgl.matrix_dirty = true; - memcpy(&_sgl_matrix()->v[0][0], &m[0], 64); + _sgl_transpose(_sgl_matrix(), (const _sgl_matrix_t*) &m[0]); } SOKOL_API_IMPL void sgl_mult_matrix(const float m[16]) { SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); _sgl.matrix_dirty = true; - _sgl_matrix_t m0; - _sgl_transpose(&m0, (const _sgl_matrix_t*) &m[0]); - /* order? */ - _sgl_mul(_sgl_matrix(), &m0); + const _sgl_matrix_t* m0 = (const _sgl_matrix_t*) &m[0]; + _sgl_mul(_sgl_matrix(), m0); } -SOKOL_API_IMPL void sgl_mult_transpose_matrix_matrix(const float m[16]) { +SOKOL_API_IMPL void sgl_mult_transpose_matrix(const float m[16]) { SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); _sgl.matrix_dirty = true; - const _sgl_matrix_t* m0 = (const _sgl_matrix_t*) &m[0]; - /* order? */ - _sgl_mul(_sgl_matrix(), m0); + _sgl_matrix_t m0; + _sgl_transpose(&m0, (const _sgl_matrix_t*) &m[0]); + _sgl_mul(_sgl_matrix(), &m0); } SOKOL_API_IMPL void sgl_rotate(float angle_rad, float x, float y, float z) { |