Giter VIP home page Giter VIP logo

xwcoco / litegl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from juliopx/litegl

0.0 2.0 0.0 986 KB

Litegl is a library that wraps WebGL to make it more user-friendly by creating classes for managing different items like Buffer, Mesh, Texture, Shader and other common aspects of any WebGL applications. It is a fork from Litegl.js by Javi Agenjo (https://github.com/jagenjo/litegl.js) but modified to get it working as npm package.

License: Other

JavaScript 100.00%

litegl's Introduction

litegl

Litegl is a library that wraps WebGL to make it more user-friendly by creating classes for managing different items like Buffer, Mesh, Texture, Shader and other common aspects of any WebGL applications. It is a fork from Litegl.js by Javier Agenjo but with some changes to get it working as npm package.

Litegl.js by Javier Agenjo is a fork from LightGL.js by Evan Wallace, but some major changes have been made. Some of the main differences:

  • Matrices have been replaced by glMatrix
  • Meshes are forced to be stored in ArrayBuffer formats
  • Meshes support range rendering with offset
  • Removed fixed pipeline behaviour
  • Better event handling (mouse position, mouse wheel, dragging)
  • Textures expanded to support Arraybuffers and Cubemaps
  • Events system to trigger events from any object
  • Support for multiple WebGL contexts in the same page

Litegl.js by Javier Agenjo library has been used in several projects like Rendeer.js or Canvas2DtoWebGL.

Demos

Demos are included in the Examples folder.

Usage

npm install --save litegl

Create the context

var GL = require("litegl")
var gl = GL.create({width:800, height:600});

Attach to DOM

document.getElementById("mycontainer").appendChild( gl.canvas )

Compile shader

var shader = new GL.Shader( vertex_shader_code, fragment_shader_code );

Create Mesh

var mesh = new GL.Mesh({vertices:[-1,-1,0, 1,-1,0, 0,1,0], coords:[0,0, 1,0, 0.5,1]});

Load a texture

var texture = GL.Texture.fromURL("image.jpg", { minFilter: gl.LINEAR_MIPMAP_LINEAR });

Render

gl.ondraw = function() {
	texture.bind(0);
	var my_uniforms = { u_texture: 0, u_color: [1,1,1,1] };
	shader.uniforms( my_uniforms ).draw( mesh );
}

gl.animate(); //calls the requestAnimFrame constantly, which will call ondraw

Feedback

You can write any feedback to [email protected]

litegl's People

Contributors

juliopx avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.