a-game

2D platformer written from scratch.
git clone git://git.amin.space/a-game.git
Log | Files | Refs | README | LICENSE

commit 90d5b564b7a0ff1078505821d876f421b9d3be18
parent 9c5a64c67702a8c2359b4c1fa2f5289c53c0fe6a
Author: amin <dev@aminmesbah.com>
Date:   Tue,  9 Jul 2019 00:39:19 +0000

Get webgl scissoring to work

FossilOrigin-Name: 83b4d483685b7cf1b90c52deb3b03a05ff95df0024ab8e94a1cf1bb0d1d1f1ea
Diffstat:
Msrc/game.c | 2+-
Msrc/platform_wasm_js_symbols.txt | 1+
Msrc/platform_wasm_loader.js | 3+++
Msrc/webgl.h | 7+++++++
4 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/game.c b/src/game.c @@ -416,7 +416,7 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga // game_detect_collisions { -#if 1 +#if 0 #define RENDER_COLLISION_DEBUG_QUAD(r, c) renderer_debug_quad_draw(&game_state->renderer, (r), (c)); #else #define RENDER_COLLISION_DEBUG_QUAD(r, c) diff --git a/src/platform_wasm_js_symbols.txt b/src/platform_wasm_js_symbols.txt @@ -29,6 +29,7 @@ webglGetShaderInfoLog webglGetShaderParameter webglGetUniformLocation webglLinkProgram +webglScissor webglShaderSource webglTexImage2D webglTexParameteri diff --git a/src/platform_wasm_loader.js b/src/platform_wasm_loader.js @@ -152,6 +152,9 @@ imports["webglLinkProgram"] = function(program_id) { let program = gl_id_map[program_id]; gl.linkProgram(program); } +imports["webglScissor"] = function(x, y, width, height) { + gl.scissor(x, y, width, height); +} imports["webglShaderSource"] = function(shader_id, source_ptr, source_len) { let shader = gl_id_map[shader_id]; let arr = memory.subarray(source_ptr, source_ptr + source_len); diff --git a/src/webgl.h b/src/webgl.h @@ -37,6 +37,7 @@ void webglGetShaderInfoLog(i32 shader, char *out_buf); int webglGetShaderParameter(i32 shader, i32 param); i32 webglGetUniformLocation(i32 program, const char name[static 1], i32 name_len); void webglLinkProgram(i32 program); +void webglScissor(i32 x, i32 y, i32 width, i32 height); void webglShaderSource(i32 shader, const char source[static 1], i32 source_len); void webglTexImage2D(i32 target, i32 level, i32 internalformat, i32 width, i32 height, i32 border, i32 format, i32 type, i32 pixels); void webglTexParameteri(i32 target, i32 pname, i32 param); @@ -59,6 +60,7 @@ void webglViewport(i32 x, i32 y, i32 width, i32 height); #define GL_FRONT_AND_BACK 0x0408 #define GL_DEPTH_TEST 0x0B71 #define GL_BLEND 0x0BE2 +#define GL_SCISSOR_TEST 0x0C11 #define GL_TEXTURE_2D 0x0DE1 #define GL_UNSIGNED_BYTE 0x1401 #define GL_UNSIGNED_INT 0x1405 @@ -287,6 +289,11 @@ inline void glPolygonMode(GLenum face, GLenum mode) // No Op. This doesn't exist in webgl } +inline void glScissor(GLint x, GLint y, GLsizei width, GLsizei height) +{ + webglScissor(WEBGL_CAST_I32(x), WEBGL_CAST_I32(y), WEBGL_CAST_I32(width), WEBGL_CAST_I32(height)); +} + inline void glShaderSource(GLuint shader, GLsizei count, const GLchar *const *string, const GLint *length) { const GLchar *s = (void *)*string;