stackgl / learning-webgl-01

Learning WebGL Lesson 1 converted from vanilla WebGL to use stack.gl.
http://stack.gl/learning-webgl-01/
28 stars 4 forks source link

Set vertex attribute pointers on shader program after bind() calls #3

Closed ranweiler closed 8 years ago

ranweiler commented 9 years ago

The change in ecc8a3a introduced an error in vertex attribute pointer setup, and thus rendering.

In that commit, the two calls to gl.vertexAttribPointer after the bind call of each shape's GLBuffer are replace by a single call to shader.attributes.aPosition.pointer, before either buffer bind. This resulted in the triangle being rendered with the first 3 "rows" of the square's vertex buffer. This visually manifests as a right triangle being rendered, not an isosceles.

This PR just adds a call to pointer after each vertex buffer's bind call. I'm new to both the gl-* libraries and Open/WebGL generally, so if there's a nicer way to do this, let me know, and I'll update the PR!