Beginner's GLSL - 2 questions
BlitzMax Forums/OpenGL Module/Beginner's GLSL - 2 questions
| ||
Hello Blitzers, I'm starting to learn more about shader programming with GLSL, but in my "studies" these 2 questions came up: 1) Inside a Vertex Shader I have a Uniform array of Mat4's, which has about some 32 elements. Do I really need to map every single slot of that array using the "glGetUniformLocation()" and then later submit a matrix for every slot of this Uniform manually, or I can just submit a same-sized array of matrices at once? 2) If I have different meshes with different shaders "applied" (meaning, I want to use different shaders for different meshes), how would I change which shader to use? Would I need to: - Disable the current program using glUseProgram(0) first, and then use a different program (in other words, is it really necessary to put a NULL program before changing between programs), or... - Simply use glUseProgram(n) and put a different program number (is that going to automatically change which type of program the renderer will use? isn't there going to be a left over leak from the previously used program or something?) Thanks for reading. |
| ||
or I can just submit a same-sized array of matrices at once? You can do that using glUniformMatrix4fv. Simply use glUseProgram(n) and put a different program number As far as I know, glUseProgram with a different program number should do the job. glUseProgram(0) is just for switching back to the fixed pipeline. |
| ||
Thanks for the explanation, Noobody. |