aboutsummaryrefslogtreecommitdiff
path: root/web/pw-visualizer/src/webgl/index.ts
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2021-12-29 22:54:30 +0100
committerIlion Beyst <ilion.beyst@gmail.com>2021-12-29 22:54:30 +0100
commit71ee6c99e963d96286cae8d0bfc2f20a9c9c920b (patch)
treec4d290c4a658853436477cb07cd469684c64f8e3 /web/pw-visualizer/src/webgl/index.ts
parent0c6d978442b244ca3f29c1ffdd44b5007ae7ad93 (diff)
downloadplanetwars.dev-71ee6c99e963d96286cae8d0bfc2f20a9c9c920b.tar.xz
planetwars.dev-71ee6c99e963d96286cae8d0bfc2f20a9c9c920b.zip
move assets to visualizer package
Diffstat (limited to 'web/pw-visualizer/src/webgl/index.ts')
-rw-r--r--web/pw-visualizer/src/webgl/index.ts15
1 files changed, 11 insertions, 4 deletions
diff --git a/web/pw-visualizer/src/webgl/index.ts b/web/pw-visualizer/src/webgl/index.ts
index fdb7886..1742713 100644
--- a/web/pw-visualizer/src/webgl/index.ts
+++ b/web/pw-visualizer/src/webgl/index.ts
@@ -4,15 +4,22 @@ import { VertexBuffer, IndexBuffer } from './buffer';
import { VertexArray, VertexBufferLayout } from './vertexBufferLayout';
import { Renderer } from './renderer';
import { Texture } from './texture';
+import * as assets from "../assets";
-const URL = window.location.origin+window.location.pathname;
-const LOCATION = URL.substring(0, URL.lastIndexOf("/") + 1);
+// const URL = window.location.origin+window.location.pathname;
+// const LOCATION = URL.substring(0, URL.lastIndexOf("/") + 1);
async function create_texture_from_svg(gl: WebGLRenderingContext, name: string, path: string, width: number, height: number): Promise<Texture> {
const [mesh, factory] = await Promise.all([
url_to_mesh(path),
- ShaderFactory.create_factory(LOCATION + "static/shaders/frag/static_color.glsl", LOCATION + "static/shaders/vert/svg.glsl")
+ ShaderFactory.create_factory(
+ // assets.simpleFragmentShader,
+ // assets.simpleVertexShader,
+ // TODO: previously: this was the old code, which was not working.
+ // what is the correct shader here?
+ "static/shaders/frag/static_color.glsl", "static/shaders/vert/svg.glsl"
+ )
]);
const program = factory.create_shader(gl);
@@ -54,7 +61,7 @@ async function main() {
console.log(Math.max(...mesh.positions), Math.min(...mesh.positions));
const renderer = new Renderer();
- const factory = await ShaderFactory.create_factory(LOCATION + "static/shaders/frag/static_color.glsl", LOCATION + "static/shaders/vert/simple.glsl");
+ const factory = await ShaderFactory.create_factory(assets.simpleFragmentShader, assets.simpleVertexShader);
const program = factory.create_shader(gl);
var positionBuffer = new VertexBuffer(gl, mesh.positions);