Im fairly new to OpenGL. Ive just started learning about shaders, particularly the vertex and fragment shaders. My understanding is that when things are done through the shaders you can gain a pretty significant performance increase, because the shader runs on the GPU.
However, I've tried doing some research into this topic and I seem to be finding some mixed opinions on the matter, at least in regards to the vertex shader.
What is the major difference between rendering an object like below and using calls like glMultMatrixd for my transformations:
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, &vertices[0]);
glNormalPointer(GL_FLOAT, 0, &normals[0]);
glDrawArrays(GL_TRIANGLES, 0, vertices.size() / 3);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
vs using a VAO/VBO setup like below where I set my transformation matrices to Uniform variables in the shader and do the transformation there.
glBindVertexArray(vaoHandle);
glBindBuffer(GL_ARRAY_BUFFER, bufferHandle[0]);
glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(float), vertices.data(), GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, bufferHandle[1]);
glBufferData(GL_ARRAY_BUFFER, normals.size() * sizeof(float), normals.data(), GL_STATIC_DRAW);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(1);
.....
glBindVertexArray(vaoHandle);
glDrawArrays(GL_TRIANGLES, 0, vertices.size() / 3);
Just a heads up...I dont care about whats wrong with the code below. Again, I just wanna know if there is in fact a performance difference and why? Whats going on underneath the hood for both these approaches? WHy would one be faster/slower then the other? And same goes for the transformations. Why would doing one in a vertex shader with a uniform be faster then using glMultMatrix?