aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvictorfisac <victorfisac@gmail.com>2016-05-30 19:55:13 +0200
committervictorfisac <victorfisac@gmail.com>2016-05-30 19:55:13 +0200
commitb0a0c5d4312d05d460cdd12f6af12321b0a55e66 (patch)
tree4f0b5967634052260873fd47f3b9d2418690cdcd /src
parentf2d61d4043850e89b2d2cb7bacffe628aef0b981 (diff)
downloadraylib-b0a0c5d4312d05d460cdd12f6af12321b0a55e66.tar.gz
raylib-b0a0c5d4312d05d460cdd12f6af12321b0a55e66.zip
Added tint color attribute to material data type
It tints all fragments, ignores lighting. Useful for some features like feedback (damage color, ...).
Diffstat (limited to 'src')
-rw-r--r--src/models.c3
-rw-r--r--src/raylib.h1
-rw-r--r--src/rlgl.c3
-rw-r--r--src/rlgl.h1
4 files changed, 7 insertions, 1 deletions
diff --git a/src/models.c b/src/models.c
index 90b752fd..092a43fc 100644
--- a/src/models.c
+++ b/src/models.c
@@ -751,6 +751,7 @@ Material LoadDefaultMaterial(void)
//material.texNormal; // NOTE: By default, not set
//material.texSpecular; // NOTE: By default, not set
+ material.colTint = WHITE; // Tint color
material.colDiffuse = WHITE; // Diffuse color
material.colAmbient = WHITE; // Ambient color
material.colSpecular = WHITE; // Specular color
@@ -1268,7 +1269,7 @@ void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rota
//Matrix matModel = MatrixMultiply(model.transform, matTransform); // Transform to world-space coordinates
model.transform = MatrixMultiply(MatrixMultiply(matScale, matRotation), matTranslation);
- // model.material.colDiffuse = tint;
+ model.material.colTint = tint;
rlglDrawMesh(model.mesh, model.material, model.transform);
}
diff --git a/src/raylib.h b/src/raylib.h
index 73a36a16..dfec956d 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -414,6 +414,7 @@ typedef struct Material {
Texture2D texNormal; // Normal texture (binded to shader mapTexture1Loc)
Texture2D texSpecular; // Specular texture (binded to shader mapTexture2Loc)
+ Color colTint; // Tint color
Color colDiffuse; // Diffuse color
Color colAmbient; // Ambient color
Color colSpecular; // Specular color
diff --git a/src/rlgl.c b/src/rlgl.c
index b4569207..0f68953e 100644
--- a/src/rlgl.c
+++ b/src/rlgl.c
@@ -1793,6 +1793,9 @@ void rlglDrawMesh(Mesh mesh, Material material, Matrix transform)
// Setup shader uniforms for lights
SetShaderLights(material.shader);
+ // Upload to shader material.colSpecular
+ glUniform4f(glGetUniformLocation(material.shader.id, "colTint"), (float)material.colTint.r/255, (float)material.colTint.g/255, (float)material.colTint.b/255, (float)material.colTint.a/255);
+
// Upload to shader material.colAmbient
glUniform4f(glGetUniformLocation(material.shader.id, "colAmbient"), (float)material.colAmbient.r/255, (float)material.colAmbient.g/255, (float)material.colAmbient.b/255, (float)material.colAmbient.a/255);
diff --git a/src/rlgl.h b/src/rlgl.h
index dc16e807..23ad29fb 100644
--- a/src/rlgl.h
+++ b/src/rlgl.h
@@ -202,6 +202,7 @@ typedef enum { OPENGL_11 = 1, OPENGL_33, OPENGL_ES_20 } GlVersion;
Texture2D texNormal; // Normal texture
Texture2D texSpecular; // Specular texture
+ Color colTint; // Tint color
Color colDiffuse; // Diffuse color
Color colAmbient; // Ambient color
Color colSpecular; // Specular color