commit 83919887d28477a5ca817ced13ef96e8c98da92c
parent 6c8484affddd2fda4089840883990c7b22a574bf
Author: Amin Mesbah <dev@aminmesbah.com>
Date: Sun, 30 Jun 2019 23:29:42 -0700
Get it running in the browser
For now we use the lowest common denominator shader API.
Diffstat:
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];
}