Skip to content

atme/golem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golem

Small library to have a comfortable environment to write a WebGL application

Installation

yarn add atme/golem

or

npm i atme/golem

Examples

import golem from 'golem'

const vertex = `
attribute vec4 a_position;

void main() {
    gl_Position = a_position;
}
`;

const fragment = `
precision mediump float;

void main() {
    gl_FragColor = vec4(1, 0, 0.5, 1);
}
`;

const canvas = document.getElementById("c");
const [gl, program] = golem.create(canvas, vertex, fragment);

const position = [
  0, 0,
  0, 0.5,
  0.7, 0,
];
golem.vertex(gl, program, 'a_position', position);

const count = 1;
golem.drawTriangles(gl, count);

API

Draw texture

// ... some previous code

const texCoord = [
  0.0, 0.0,
  0.0, 1.0,
  1.0, 0.0,
  0.0, 1.0,
  1.0, 0.0,
  1.0, 1.0,
];
golem.vertex(gl, program, 'a_texCoord', texCoord);

const image = new Image();
image.src = 'https://your.domain/image.png';
im.onload = () => {
    golem.texture(gl, image);

    golem.drawTriangles(gl, 2);
};

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published