a-game

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

commit 728a0a52d0964c1cc74c39466ad2828db6e82b5d
parent 1c203dfe26f61410ad56d324c21f42e0d85d3994
Author: amin <dev@aminmesbah.com>
Date:   Mon,  1 Jul 2019 06:29:41 +0000

Get it running in the browser

For now we use the lowest common denominator shader API.

FossilOrigin-Name: 807b4d9a6b576a61d2724569b4adb72a3199a98771d3404800dae250f711adaf
Diffstat:
Mshader/main_f.glsl | 7++++++-
Mshader/main_v.glsl | 4+++-
Msrc/platform_wasm_index.html | 2+-
Msrc/platform_wasm_loader.js | 8++++----
4 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/shader/main_f.glsl b/shader/main_f.glsl @@ -1,4 +1,9 @@ -#version 330 core +#version 300 es + +// NOTE(amin): this is necessary for webgl compat +precision highp float; + +// TODO: dynamically instert the version header after loading the file in vec4 vertex_color; diff --git a/shader/main_v.glsl b/shader/main_v.glsl @@ -1,4 +1,6 @@ -#version 330 core +#version 300 es + +// TODO: dynamically instert the version header after loading the file layout (location = 0) in vec2 position; diff --git a/src/platform_wasm_index.html b/src/platform_wasm_index.html @@ -1,5 +1,5 @@ <!DOCTYPE html> -<title>Transparent Cube</title> +<title>A Game</title> <meta name=viewport content='width=device-width,initial-scale=1' charset='utf-8'> <style> body { diff --git a/src/platform_wasm_loader.js b/src/platform_wasm_loader.js @@ -157,9 +157,9 @@ imports["webglViewport"] = function(x, y, width, height) { } imports["js_read_entire_file"] = function(name, name_len, out_buf) { let file_name = utf8decoder.decode(memory.subarray(name, name + name_len)) - if (file_name == "shader/cube_f.glsl") { + if (file_name == "shader/main_f.glsl") { var file = files[1]; - } else if (file_name == "shader/cube_v.glsl") { + } else if (file_name == "shader/main_v.glsl") { var file = files[2]; } else { return false; @@ -228,8 +228,8 @@ window.onload = async function() { error_fatal("Your browser does not support WebGL 2."); } files[0] = file_load("binary.wasm"); - files[1] = file_load("shader/cube_f.glsl"); - files[2] = file_load("shader/cube_v.glsl"); + files[1] = file_load("shader/main_f.glsl"); + files[2] = file_load("shader/main_v.glsl"); for(var i=0; i<files.length; i++) { files[i] = await files[i]; }