Hi I am trying to figure out how to switch shader in a simple test program but every time i enable the 2nd shader program all polygons disappear completely.
If I enable only one of the shaders (doesn’t matter which) then I see both tris rendered but of course both using that shader.
I have tested both shader programs individually and they work on their own.
The two geometries are two slightly different single triangles.
My setup is like this:
GLuint shader_program, shader_program2; GLint pos, pos2; shader_program = common_get_shader_program(vertex_shader_source, fragment_shader_source); shader_program2 = common_get_shader_program(vertex_shader_source, fragment_shader_source2); pos = glGetAttribLocation(shader_program, "position"); pos2 = glGetAttribLocation(shader_program2, "position"); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, vVertices); glEnableVertexAttribArray(0); glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, vVertices2); glEnableVertexAttribArray(1);
Then my draw loop looks like:
glViewport(0, 0, 1280, 720); glClearColor(1.0, 1.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glUseProgram(shader_program); glDrawArrays(GL_TRIANGLES, 0, 3); glUseProgram(shader_program2); glDrawArrays(GL_TRIANGLES, 1, 3);
I have been trying to look for a simple example program but all tutorial programs only use one shader.
What am I doing wrong?
(probably several things)