Added init struct (resource loading helpers)
This commit is contained in:
9
sunpy/canvas/gl/shaders/texture.fs
Normal file
9
sunpy/canvas/gl/shaders/texture.fs
Normal file
@@ -0,0 +1,9 @@
|
||||
precision mediump float;
|
||||
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
varying vec2 v_texcoord;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = texture2D(u_texture, v_texcoord);
|
||||
}
|
||||
11
sunpy/canvas/gl/shaders/texture.vs
Normal file
11
sunpy/canvas/gl/shaders/texture.vs
Normal file
@@ -0,0 +1,11 @@
|
||||
attribute vec4 position;
|
||||
attribute vec2 texcoord;
|
||||
|
||||
uniform mat4 u_matrix;
|
||||
|
||||
varying vec2 v_texcoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_matrix * position;
|
||||
v_texcoord = texcoord;
|
||||
}
|
||||
23
sunpy/canvas/gl/texture.js
Normal file
23
sunpy/canvas/gl/texture.js
Normal file
@@ -0,0 +1,23 @@
|
||||
//const fs = await (await fetch("./shaders/texture.fs")).text();
|
||||
|
||||
export async function compile() {
|
||||
/*
|
||||
const fs = await (await fetch("./shaders/texture.fs")).text();
|
||||
const vs = await (await fetch("./shaders/texture.vs")).text();
|
||||
*/
|
||||
|
||||
const fs = import("./shaders/texture.fs");
|
||||
const vs = import("./shaders/texture.vs");
|
||||
|
||||
window.fs = fs;
|
||||
window.vs = vs;
|
||||
console.log("done");
|
||||
}
|
||||
|
||||
export function drawImage(gl, tex, texWidth, texHeight, dstX, dstY) {
|
||||
gl.bindTexture(gl.TEXTURE_2D, tex);
|
||||
|
||||
gl.useProgram(program); // TODO
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user