Socket
Book a DemoInstallSign in
Socket

gl-simplified-vao

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gl-simplified-vao

A simplified interface for creating vertex array objects without the need to calculate strides and offets.

0.1.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

gl-simplified-vao

A simplified interface for creating vertex array objects without the need to calculate strides and offsets or perform seperate buffer allocations

The following code was shamelessly repurposed from the stack.gl vao project:

var shell = require("gl-now")()
var createVAO = require("gl-simplified-vao")
var glslify = require("glslify")
 
var createShader = glslify({
  vertex: "\
    attribute vec2 position;\
    attribute vec3 color;\
    varying vec3 fragColor;\
    void main() {\
      gl_Position = vec4(position, 0, 1.0);\
      fragColor = color;\
    }",
  fragment: "\
    precision highp float;\
    varying vec3 fragColor;\
    void main() {\
      gl_FragColor = vec4(fragColor, 1.0);\
    }",
  inline: true
})
 
var vao, shader
 
shell.on("gl-init", function() {
  var gl = shell.gl
  
  //Create shader object 
  shader = createShader(gl)
  shader.attributes.position.location = 0
  shader.attributes.color.location = 1
  
  //Create vertex array object 
  vao = createVAO(gl,[-1, 0 ,0.8, 1, 0.5, 
   0, -1,0.8, 1, 0.5,
   1, 1, 0.8, 1, 0.5], 
   [{'type': gl.FLOAT, 'size': 2},
    {'type': gl.FLOAT, 'size': 3}])
})
 
shell.on("gl-render", function(t) {
  var gl = shell.gl
 
  //Bind the shader 
  shader.bind()
  
  //Bind vertex array object and draw it 
  vao.vao.bind()
  vao.vao.draw(gl.TRIANGLES, 3)
  
  //Unbind vertex array when fini 
  vao.vao.unbind()
})

createVAO will return an object with two attributes:

  • vao: the vertex array object to use
  • buffer: the buffer object that was allocated for this array

Keywords

vao

FAQs

Package last updated on 22 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.