added renderfunction to a structure.

Complex structure soon to come.
This commit is contained in:
steffen 2017-08-29 16:30:53 +02:00
parent f4c68a8297
commit fa19643fa0
4 changed files with 32 additions and 7 deletions

View file

@ -4,7 +4,6 @@ layout(points) in;
layout(triangle_strip,max_vertices=24) out;
uniform mat4 projModelViewMatrix;
uniform mat3 normalMatrix;
uniform mat3 rotMatrix;
uniform mat4 lightProjModelViewMatrix[7];

View file

@ -116,4 +116,28 @@ class Structure:
glDisableVertexAttribArray(s)
glDeleteBuffers(1,[s])
glDeleteVertexArrays(1, a)
check_error("Could not destroy vertex array")
check_error("Could not destroy vertex array")
def render(self,projMatrix,geometryRotMatrix,alternateprograms = None):
for key,tupel in self.vais.items():
if alternateprograms == None:
program_id = key
else:
assert key in alternateprograms.keys
program_id = alternateprograms[key]
glUseProgram(program_id)
check_error("Renderingprogram is not initialized!")
projection = glGetUniformLocation(program_id, 'projModelViewMatrix')
rot = glGetUniformLocation(program_id, 'rotMatrix')
glUniformMatrix4fv(projection, 1, GL_FALSE, np.array(projMatrix))
glUniformMatrix3fv(rot, 1, GL_FALSE, np.array(geometryRotMatrix))
glBindVertexArray(tupel[0])
glDrawArrays(GL_POINTS, 0, len(self.Objects[key]))
check_error("Rendering problem")
glBindVertexArray(0)
glUseProgram(0)