I want to draw several objects and then transform them by selecting the specific one with a keyboard index. Let's say 1-5.
- I loaded the canvas.
- I initialized the webgl-context.
- I defined vertex/fragment shaders and bound them to a program, which I "used" (
gl.useProgram("program")
).
And then I initialized a VertexBuffer
(it's an own function). There I defined the vertices for a cube and bound that buffer. In the same function I defined my cone vertices and I bound it to a different buffer.
The thing is, how can I make different objects, that I can transform separately? I mean the shader get's the data from the buffer. But when I tried it the last time, only one object was drawn.
This is the pseudo code for pretty much all WebGL programs
Pseudo code
This is no different than drawing 1 model with 1 shader program. Just do the same setup.
a little more code...
For setting up attributes would look something like
Setting up textures (might) look something liek this
Finally you'd use the program