Skip to content

Commit

Permalink
YourGameLib automatic web example deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
duddel committed Aug 6, 2024
1 parent cac7b32 commit 2ca622b
Show file tree
Hide file tree
Showing 8 changed files with 232 additions and 0 deletions.
40 changes: 40 additions & 0 deletions yg_examples/template/assets/cube.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
v 1.000000 1.000000 -1.000000
v 1.000000 -1.000000 -1.000000
v 1.000000 1.000000 1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 1.000000 -1.000000
v -1.000000 -1.000000 -1.000000
v -1.000000 1.000000 1.000000
v -1.000000 -1.000000 1.000000
vt 0.875000 0.500000
vt 0.625000 0.750000
vt 0.625000 0.500000
vt 0.375000 1.000000
vt 0.375000 0.750000
vt 0.625000 0.000000
vt 0.375000 0.250000
vt 0.375000 0.000000
vt 0.375000 0.500000
vt 0.125000 0.750000
vt 0.125000 0.500000
vt 0.625000 0.250000
vt 0.875000 0.750000
vt 0.625000 1.000000
vn 0.0000 1.0000 0.0000
vn 0.0000 0.0000 1.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 -1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
f 5/1/1 3/2/1 1/3/1
f 3/2/2 8/4/2 4/5/2
f 7/6/3 6/7/3 8/8/3
f 2/9/4 8/10/4 6/11/4
f 1/3/5 4/5/5 2/9/5
f 5/12/6 2/9/6 6/7/6
f 5/1/1 7/13/1 3/2/1
f 3/2/2 7/14/2 8/4/2
f 7/6/3 5/12/3 6/7/3
f 2/9/4 4/5/4 8/10/4
f 1/3/5 3/2/5 4/5/5
f 5/12/6 1/3/6 2/9/6
25 changes: 25 additions & 0 deletions yg_examples/template/assets/default.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// meant to be compatible with glsl 330 and 300 es
// desired #version has to be prepended befor compiling

layout(location = 0) in vec3 inPosition;
layout(location = 1) in vec3 inNormal;
layout(location = 2) in vec2 inTexcoords;
layout(location = 3) in vec3 inColor;

out vec3 vOutPos;
out vec3 vOutNorm;
out vec2 vOutTex;
out vec3 vOutCol;

uniform mat4 mvpMat;
uniform mat4 modelMat;
uniform mat3 normalMat;

void main()
{
vOutPos = (modelMat * vec4(inPosition, 1.0)).xyz;
vOutNorm = normalMat * inNormal;
vOutTex = inTexcoords;
vOutCol = inColor;
gl_Position = mvpMat * vec4(inPosition, 1.0);
}
21 changes: 21 additions & 0 deletions yg_examples/template/assets/diffusecolor.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// meant to be compatible with glsl 330 and 300 es
// desired #version has to be prepended befor compiling

precision mediump float; // required for es

in vec3 vOutPos;
in vec3 vOutNorm;
in vec3 vOutCol;

layout(location = 0) out vec4 color;

uniform vec3 lightPosition;
uniform vec3 lightDiffuse;

void main()
{
vec3 lightDir = normalize(lightPosition - vOutPos);
float diff = max(dot(normalize(vOutNorm), lightDir), 0.0);

color = vec4(vOutCol * lightDiffuse * (diff + 0.2), 1.0);
}
131 changes: 131 additions & 0 deletions yg_examples/template/assets/grid.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
v -10 0 0 0.2 0 0
v 10 0 0 1 0 0
v 0 -10 0 0 0.2 0
v 0 10 0 0 1 0
v 0 0 -10 0 0 0.2
v 0 0 10 0 0 1

v -10 0 -10 0.5 0.5 0.5
v 10 0 -10 0.5 0.5 0.5
v -10 0 -9 0.5 0.5 0.5
v 10 0 -9 0.5 0.5 0.5
v -10 0 -8 0.5 0.5 0.5
v 10 0 -8 0.5 0.5 0.5
v -10 0 -7 0.5 0.5 0.5
v 10 0 -7 0.5 0.5 0.5
v -10 0 -6 0.5 0.5 0.5
v 10 0 -6 0.5 0.5 0.5
v -10 0 -5 1 1 1
v 10 0 -5 1 1 1
v -10 0 -4 0.5 0.5 0.5
v 10 0 -4 0.5 0.5 0.5
v -10 0 -3 0.5 0.5 0.5
v 10 0 -3 0.5 0.5 0.5
v -10 0 -2 0.5 0.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 -10 1 1 1
v 5 0 10 1 1 1
v 6 0 -10 0.5 0.5 0.5
v 6 0 10 0.5 0.5 0.5
v 7 0 -10 0.5 0.5 0.5
v 7 0 10 0.5 0.5 0.5
v 8 0 -10 0.5 0.5 0.5
v 8 0 10 0.5 0.5 0.5
v 9 0 -10 0.5 0.5 0.5
v 9 0 10 0.5 0.5 0.5
v 10 0 -10 0.5 0.5 0.5
v 10 0 10 0.5 0.5 0.5
l 1 2
l 3 4
l 5 6
l 7 8
l 9 10
l 11 12
l 13 14
l 15 16
l 17 18
l 19 20
l 21 22
l 23 24
l 25 26
l 27 28
l 29 30
l 31 32
l 33 34
l 35 36
l 37 38
l 39 40
l 41 42
l 43 44
l 45 46
l 47 48
l 49 50
l 51 52
l 53 54
l 55 56
l 57 58
l 59 60
l 61 62
l 63 64
l 65 66
l 67 68
l 69 70
l 71 72
l 73 74
l 75 76
l 77 78
l 79 80
l 81 82
l 83 84
l 85 86
13 changes: 13 additions & 0 deletions yg_examples/template/assets/simplecolor.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// meant to be compatible with glsl 330 and 300 es
// desired #version has to be prepended befor compiling

precision mediump float; // required for es

in vec3 vOutCol;

layout(location = 0) out vec4 color;

void main()
{
color = vec4(vOutCol, 1.0);
}
1 change: 1 addition & 0 deletions yg_examples/template/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!doctypehtml><html lang=en-us><head><meta charset=utf-8><meta content="text/html; charset=utf-8"http-equiv=Content-Type><title>YourGameLib project</title><style>.emscripten{padding-right:0;margin-left:auto;margin-right:auto;display:block}div.emscripten{text-align:center;color:#fff}canvas.emscripten{width:100vw;height:100vh;border:0 none;background-color:#000}body{background-color:#000;margin:0;padding:0}.spinner{height:50px;width:50px;margin:0 auto;-webkit-animation:rotation .8s linear infinite;-moz-animation:rotation .8s linear infinite;-o-animation:rotation .8s linear infinite;animation:rotation .8s linear infinite;border-left:10px solid #0096f0;border-right:10px solid #0096f0;border-bottom:10px solid #0096f0;border-top:10px solid #6400c8;border-radius:100%;background-color:#c864fa}@-webkit-keyframes rotation{from{-webkit-transform:rotate(0)}to{-webkit-transform:rotate(360deg)}}@-moz-keyframes rotation{from{-moz-transform:rotate(0)}to{-moz-transform:rotate(360deg)}}@-o-keyframes rotation{from{-o-transform:rotate(0)}to{-o-transform:rotate(360deg)}}@keyframes rotation{from{transform:rotate(0)}to{transform:rotate(360deg)}}</style></head><body><figure id=spinner style=overflow:visible><div class=spinner></div><center style=margin-top:.5em><strong>emscripten</strong></center></figure><div class=emscripten id=status>Downloading...</div><div class=emscripten><progress hidden id=progress max=100 value=0></progress></div><canvas class=emscripten id=canvas oncontextmenu=event.preventDefault() tabindex=-1></canvas><script>var statusElement=document.getElementById("status"),progressElement=document.getElementById("progress"),spinnerElement=document.getElementById("spinner"),Module={preRun:[],postRun:[],print:function(){var e=document.getElementById("output");return e&&(e.value=""),function(t){arguments.length>1&&(t=Array.prototype.slice.call(arguments).join(" ")),console.log(t),e&&(e.value+=t+"\n",e.scrollTop=e.scrollHeight)}}(),printErr:function(e){arguments.length>1&&(e=Array.prototype.slice.call(arguments).join(" ")),console.error(e)},canvas:function(){var e=document.getElementById("canvas");return e.addEventListener("webglcontextlost",(function(e){alert("WebGL context lost. You will need to reload the page."),e.preventDefault()}),!1),e}(),setStatus:function(e){if(Module.setStatus.last||(Module.setStatus.last={time:Date.now(),text:""}),e!==Module.setStatus.last.text){var t=e.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/),n=Date.now();t&&n-Module.setStatus.last.time<30||(Module.setStatus.last.time=n,Module.setStatus.last.text=e,t?(e=t[1],progressElement.value=100*parseInt(t[2]),progressElement.max=100*parseInt(t[4]),progressElement.hidden=!1,spinnerElement.hidden=!1):(progressElement.value=null,progressElement.max=null,progressElement.hidden=!0,e||(spinnerElement.hidden=!0)),statusElement.innerHTML=e)}},totalDependencies:0,monitorRunDependencies:function(e){this.totalDependencies=Math.max(this.totalDependencies,e),Module.setStatus(e?"Preparing... ("+(this.totalDependencies-e)+"/"+this.totalDependencies+")":"All downloads complete.")}};Module.setStatus("Downloading..."),window.onerror=function(){spinnerElement.style.display="none",Module.setStatus=function(e){e&&Module.printErr("[post-exception status] "+e)}}</script><script async src=template.js></script></body></html>
1 change: 1 addition & 0 deletions yg_examples/template/template.js

Large diffs are not rendered by default.

Binary file added yg_examples/template/template.wasm
Binary file not shown.

0 comments on commit 2ca622b

Please sign in to comment.