From 4db2da91850fcc55ec08df253e533e236eb91451 Mon Sep 17 00:00:00 2001 From: victorfisac Date: Mon, 21 Dec 2015 16:42:13 +0100 Subject: Added new matrix location points and extra functions - New model and view transformation matrix added, useful for shaders. Modelview matrix not deleted to keep opengl 1.1 pipeline compatibility. - New extra function added DrawModelWiresEx() to set a rotation and scale transformations to a wire model drawing. - Other writing and little audio.c bug fixed. --- src/rlgl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/rlgl.c') diff --git a/src/rlgl.c b/src/rlgl.c index 3862ac74..f9108342 100644 --- a/src/rlgl.c +++ b/src/rlgl.c @@ -1498,6 +1498,8 @@ void rlglDrawModel(Model model, Vector3 position, float rotationAngle, Vector3 r glUseProgram(model.shader.id); // Apply transformation provided in model.transform matrix + // TODO: review if at this point the modelview matrix just contains view matrix values + Matrix viewworld = modelview; // Store view matrix before applying model transformations Matrix modelviewworld = MatrixMultiply(model.transform, modelview); // World-space transformation // Apply transformations provided in function @@ -1513,6 +1515,8 @@ void rlglDrawModel(Model model, Vector3 position, float rotationAngle, Vector3 r // NOTE: Drawing in OpenGL 3.3+, transform is passed to shader glUniformMatrix4fv(model.shader.projectionLoc, 1, false, GetMatrixVector(projection)); + glUniformMatrix4fv(model.shader.modelLoc, 1, false, GetMatrixVector(transform)); + glUniformMatrix4fv(model.shader.viewLoc, 1, false, GetMatrixVector(viewworld)); glUniformMatrix4fv(model.shader.modelviewLoc, 1, false, GetMatrixVector(modelviewworld)); // Apply color tinting to model @@ -2242,6 +2246,8 @@ Shader LoadShader(char *vsFileName, char *fsFileName) // Get handles to GLSL uniform locations (vertex shader) shader.modelviewLoc = glGetUniformLocation(shader.id, "modelviewMatrix"); + shader.modelLoc = glGetUniformLocation(shader.id, "modelMatrix"); + shader.viewLoc = glGetUniformLocation(shader.id, "viewMatrix"); shader.projectionLoc = glGetUniformLocation(shader.id, "projectionMatrix"); // Get handles to GLSL uniform locations (fragment shader) @@ -2781,6 +2787,8 @@ static Shader LoadDefaultShader(void) // Get handles to GLSL uniform locations (vertex shader) shader.modelviewLoc = glGetUniformLocation(shader.id, "modelviewMatrix"); + shader.modelLoc = glGetUniformLocation(shader.id, "modelMatrix"); + shader.viewLoc = glGetUniformLocation(shader.id, "viewMatrix"); shader.projectionLoc = glGetUniformLocation(shader.id, "projectionMatrix"); // Get handles to GLSL uniform locations (fragment shader) @@ -2861,6 +2869,8 @@ static Shader LoadSimpleShader(void) // Get handles to GLSL uniform locations (vertex shader) shader.modelviewLoc = glGetUniformLocation(shader.id, "modelviewMatrix"); + shader.modelLoc = glGetUniformLocation(shader.id, "modelMatrix"); + shader.viewLoc = glGetUniformLocation(shader.id, "viewMatrix"); shader.projectionLoc = glGetUniformLocation(shader.id, "projectionMatrix"); // Get handles to GLSL uniform locations (fragment shader) -- cgit v1.2.3