I have a single mesh, and I give the vertex-shader a matrix which holds the objects position, scale and rotation. It seems to work.

in vec3 position;
uniform mat4 object;
uniform mat4 view;
uniform mat4 proj;

void main() {
   gl_Position = proj * view * object * vec4(position, 1.0);

What if I have multiple meshes? What is the standard way to approach this? Feed in a different mat4 for every mesh rendered, or have separate vertex shaders for each mesh?


Each mesh gets a different object matrix (world transformation matrix).

A common sequence of rendering multiple meshes is :

  • Use shader program
  • Set the uniforms for Mesh1
  • Bind VAO/VBO's for Mesh1
  • Draw

  • Set uniform for world matrix for Mesh2

  • Bind VBO/VAO for Mesh2
  • Draw


  • \$\begingroup\$ thanks mate, being a newb I still don't fully get VBO/VAO stuff, but I'll go do some more reading :) \$\endgroup\$ Nov 3 '15 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.