transparent-cube

Minimal cross-platform native/wasm graphics example.
git clone git://git.amin.space/transparent-cube.git
Log | Files | Refs | README | LICENSE

commit db83cd00d5a703af92c733e961bbe41b489cce3a
parent ea8c08ae5a42cecd06477b7836763b5a805a4c64
Author: amin <dev@aminmesbah.com>
Date:   Sun, 23 Jun 2019 21:00:37 +0000

Realize we just needed to pass down our bool

FossilOrigin-Name: 6f8fb9992fe99b31547e14edcdf6c3c20600eca11225621871eb227d0f74cbfd
Diffstat:
Mjs/imports.js | 6++----
Msrc/webgl.h | 4++--
2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/js/imports.js b/js/imports.js @@ -131,12 +131,10 @@ imports["webglUniform3f"] = function(location_id, x, y, z) { let loc = gl_id_map[location_id]; gl['uniform3fv'](loc, [x, y, z]); } -imports["webglUniformMatrix4fv"] = function(location_id, data) { +imports["webglUniformMatrix4fv"] = function(location_id, transpose, data) { let loc = gl_id_map[location_id]; let dataslice = memory.slice(data, data + 4 * 16); - // TODO: figure out why we need to transpose the matrix here, but not in - // normal opengl - gl.uniformMatrix4fv(loc, true, new Float32Array(dataslice.buffer)); + gl.uniformMatrix4fv(loc, transpose, new Float32Array(dataslice.buffer)); } imports["webglUseProgram"] = function(program_id) { let program = gl_id_map[program_id]; diff --git a/src/webgl.h b/src/webgl.h @@ -37,7 +37,7 @@ void webglShaderSource(i32 shader, const char source[static 1], i32 source_len); void webglUniform1f(i32 location, f32 value); void webglUniform1i(i32 location, i32 value); void webglUniform3f(i32 location, f32 x, f32 y, f32 z); -void webglUniformMatrix4fv(i32 location, const f32 data[static 16]); +void webglUniformMatrix4fv(i32 location, i32 transpose, const f32 data[static 16]); void webglUseProgram(i32 program); void webglVertexAttribPointer(i32 index, i32 size, i32 type, i32 normalized, i32 stride, i32 offset); void webglViewport(i32 x, i32 y, i32 width, i32 height); @@ -257,7 +257,7 @@ inline void glUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) inline void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { - webglUniformMatrix4fv(WEBGL_CAST_I32(location), value); + webglUniformMatrix4fv(WEBGL_CAST_I32(location), WEBGL_CAST_I32(transpose), value); } inline void glUseProgram(GLuint program)