aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoshua Reisenauer <kd7tck@msn.com>2016-05-25 11:26:31 -0700
committerJoshua Reisenauer <kd7tck@msn.com>2016-05-25 11:26:31 -0700
commit5a041a6af58a221060e8202cd0a12a1aa562838c (patch)
tree8755884114784e71d424ce10d72c572a3f6d9350 /src
parentf74791ed7bcb3585c576f40766bf4e22b0923a7e (diff)
parent3d6696f6c981a7a8f523d631926380eced475733 (diff)
downloadraylib-5a041a6af58a221060e8202cd0a12a1aa562838c.tar.gz
raylib-5a041a6af58a221060e8202cd0a12a1aa562838c.zip
Merge remote-tracking branch 'refs/remotes/raysan5/develop' into develop
Diffstat (limited to 'src')
-rw-r--r--src/raylib.h34
-rw-r--r--src/rlgl.c24
-rw-r--r--src/rlgl.h8
3 files changed, 34 insertions, 32 deletions
diff --git a/src/raylib.h b/src/raylib.h
index 9cd02fd8..d0231be2 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -369,6 +369,7 @@ typedef struct BoundingBox {
// Vertex data definning a mesh
typedef struct Mesh {
int vertexCount; // number of vertices stored in arrays
+ int triangleCount; // number of triangles stored (indexed or not)
float *vertices; // vertex position (XYZ - 3 components per vertex) (shader-location = 0)
float *texcoords; // vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
float *texcoords2; // vertex second texture coordinates (useful for lightmaps) (shader-location = 5)
@@ -376,8 +377,7 @@ typedef struct Mesh {
float *tangents; // vertex tangents (XYZ - 3 components per vertex) (shader-location = 4)
unsigned char *colors; // vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
unsigned short *indices; // vertex indices (in case vertex data comes indexed)
- int triangleCount; // number of triangles stored (indexed or not)
-
+
BoundingBox bounds; // mesh limits defined by min and max points
unsigned int vaoId; // OpenGL Vertex Array Object id
@@ -389,30 +389,30 @@ typedef struct Shader {
unsigned int id; // Shader program id
// Vertex attributes locations (default locations)
- int vertexLoc; // Vertex attribute location point (default-location = 0)
- int texcoordLoc; // Texcoord attribute location point (default-location = 1)
- int normalLoc; // Normal attribute location point (default-location = 2)
- int colorLoc; // Color attibute location point (default-location = 3)
- int tangentLoc; // Tangent attribute location point (default-location = 4)
+ int vertexLoc; // Vertex attribute location point (default-location = 0)
+ int texcoordLoc; // Texcoord attribute location point (default-location = 1)
int texcoord2Loc; // Texcoord2 attribute location point (default-location = 5)
+ int normalLoc; // Normal attribute location point (default-location = 2)
+ int tangentLoc; // Tangent attribute location point (default-location = 4)
+ int colorLoc; // Color attibute location point (default-location = 3)
// Uniform locations
int mvpLoc; // ModelView-Projection matrix uniform location point (vertex shader)
int tintColorLoc; // Diffuse color uniform location point (fragment shader)
- // Texture map locations
- int mapDiffuseLoc; // Diffuse map texture uniform location point (fragment shader)
- int mapNormalLoc; // Normal map texture uniform location point (fragment shader)
- int mapSpecularLoc; // Specular map texture uniform location point (fragment shader)
+ // Texture map locations (generic for any kind of map)
+ int mapTexture0Loc; // Map texture uniform location point (default-texture-unit = 0)
+ int mapTexture1Loc; // Map texture uniform location point (default-texture-unit = 1)
+ int mapTexture2Loc; // Map texture uniform location point (default-texture-unit = 2)
} Shader;
// Material type
typedef struct Material {
- Shader shader; // Standard shader (supports 3 map types: diffuse, normal, specular)
+ Shader shader; // Standard shader (supports 3 map textures)
- Texture2D texDiffuse; // Diffuse texture
- Texture2D texNormal; // Normal texture
- Texture2D texSpecular; // Specular texture
+ Texture2D texDiffuse; // Diffuse texture (binded to shader mapTexture0Loc)
+ Texture2D texNormal; // Normal texture (binded to shader mapTexture1Loc)
+ Texture2D texSpecular; // Specular texture (binded to shader mapTexture2Loc)
Color colDiffuse; // Diffuse color
Color colAmbient; // Ambient color
@@ -439,8 +439,8 @@ typedef struct LightData {
Vector3 target; // Used on LIGHT_DIRECTIONAL and LIGHT_SPOT (cone direction target)
float attenuation; // Lost of light intensity with distance (world distance)
- Color diffuse; // Use Vector3 diffuse
- float intensity;
+ Color diffuse; // Light color
+ float intensity; // Light intensity level
float coneAngle; // Spot light max angle
} LightData, *Light;
diff --git a/src/rlgl.c b/src/rlgl.c
index 85c0cae2..d319119f 100644
--- a/src/rlgl.c
+++ b/src/rlgl.c
@@ -1792,23 +1792,23 @@ void rlglDrawMesh(Mesh mesh, Material material, Matrix transform)
// Set shader textures (diffuse, normal, specular)
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, material.texDiffuse.id);
- glUniform1i(material.shader.mapDiffuseLoc, 0); // Texture fits in active texture unit 0
+ glUniform1i(material.shader.mapTexture0Loc, 0); // Diffuse texture fits in active texture unit 0
- if ((material.texNormal.id != 0) && (material.shader.mapNormalLoc != -1))
+ if ((material.texNormal.id != 0) && (material.shader.mapTexture1Loc != -1))
{
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, material.texNormal.id);
- glUniform1i(material.shader.mapNormalLoc, 1); // Texture fits in active texture unit 1
+ glUniform1i(material.shader.mapTexture1Loc, 1); // Normal texture fits in active texture unit 1
// TODO: Upload to shader normalDepth
//glUniform1f(???, material.normalDepth);
}
- if ((material.texSpecular.id != 0) && (material.shader.mapSpecularLoc != -1))
+ if ((material.texSpecular.id != 0) && (material.shader.mapTexture2Loc != -1))
{
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, material.texSpecular.id);
- glUniform1i(material.shader.mapSpecularLoc, 2); // Texture fits in active texture unit 2
+ glUniform1i(material.shader.mapTexture2Loc, 2); // Specular texture fits in active texture unit 2
}
if (vaoSupported)
@@ -2569,19 +2569,19 @@ static void LoadDefaultShaderLocations(Shader *shader)
// Get handles to GLSL input attibute locations
shader->vertexLoc = glGetAttribLocation(shader->id, DEFAULT_ATTRIB_POSITION_NAME);
shader->texcoordLoc = glGetAttribLocation(shader->id, DEFAULT_ATTRIB_TEXCOORD_NAME);
+ shader->texcoord2Loc = glGetAttribLocation(shader->id, DEFAULT_ATTRIB_TEXCOORD2_NAME);
shader->normalLoc = glGetAttribLocation(shader->id, DEFAULT_ATTRIB_NORMAL_NAME);
- shader->colorLoc = glGetAttribLocation(shader->id, DEFAULT_ATTRIB_COLOR_NAME);
shader->tangentLoc = glGetAttribLocation(shader->id, DEFAULT_ATTRIB_TANGENT_NAME);
- shader->texcoord2Loc = glGetAttribLocation(shader->id, DEFAULT_ATTRIB_TEXCOORD2_NAME);
+ shader->colorLoc = glGetAttribLocation(shader->id, DEFAULT_ATTRIB_COLOR_NAME);
// Get handles to GLSL uniform locations (vertex shader)
shader->mvpLoc = glGetUniformLocation(shader->id, "mvpMatrix");
// Get handles to GLSL uniform locations (fragment shader)
shader->tintColorLoc = glGetUniformLocation(shader->id, "colDiffuse");
- shader->mapDiffuseLoc = glGetUniformLocation(shader->id, "texture0");
- shader->mapNormalLoc = glGetUniformLocation(shader->id, "texture1");
- shader->mapSpecularLoc = glGetUniformLocation(shader->id, "texture2");
+ shader->mapTexture0Loc = glGetUniformLocation(shader->id, "texture0");
+ shader->mapTexture1Loc = glGetUniformLocation(shader->id, "texture1");
+ shader->mapTexture2Loc = glGetUniformLocation(shader->id, "texture2");
}
// Unload default shader
@@ -2864,8 +2864,10 @@ static void DrawDefaultBuffers(void)
Matrix matMVP = MatrixMultiply(modelview, projection);
glUniformMatrix4fv(currentShader.mvpLoc, 1, false, MatrixToFloat(matMVP));
- glUniform1i(currentShader.mapDiffuseLoc, 0);
glUniform4f(currentShader.tintColorLoc, 1.0f, 1.0f, 1.0f, 1.0f);
+ glUniform1i(currentShader.mapTexture0Loc, 0);
+
+ // NOTE: Additional map textures not considered for default buffers drawing
}
// Draw lines buffers
diff --git a/src/rlgl.h b/src/rlgl.h
index 0765a8a7..fa35dbc6 100644
--- a/src/rlgl.h
+++ b/src/rlgl.h
@@ -171,10 +171,10 @@ typedef enum { OPENGL_11 = 1, OPENGL_33, OPENGL_ES_20 } GlVersion;
int mvpLoc; // ModelView-Projection matrix uniform location point (vertex shader)
int tintColorLoc; // Color uniform location point (fragment shader)
- // Texture map locations
- int mapDiffuseLoc; // Diffuse map texture uniform location point (fragment shader)
- int mapNormalLoc; // Normal map texture uniform location point (fragment shader)
- int mapSpecularLoc; // Specular map texture uniform location point (fragment shader)
+ // Texture map locations (generic for any kind of map)
+ int mapTexture0Loc; // Map texture uniform location point (default-texture-unit = 0)
+ int mapTexture1Loc; // Map texture uniform location point (default-texture-unit = 1)
+ int mapTexture2Loc; // Map texture uniform location point (default-texture-unit = 2)
} Shader;
// Texture2D type