aboutsummaryrefslogtreecommitdiff
path: root/src/rlgl.c
diff options
context:
space:
mode:
authorJoshua Reisenauer <kd7tck@msn.com>2016-05-30 15:39:21 -0700
committerJoshua Reisenauer <kd7tck@msn.com>2016-05-30 15:39:21 -0700
commit6ad832386097d6301555490e94cf9cc2c882137d (patch)
tree2f18bcb487aabe5b3b6073f88078a986328fbec2 /src/rlgl.c
parent9f2fc81df2ad6731b521bd7dfd523ee10f63be90 (diff)
parent8a4e28f81db16c034274e5d78dddfe33824e59fe (diff)
downloadraylib-6ad832386097d6301555490e94cf9cc2c882137d.tar.gz
raylib-6ad832386097d6301555490e94cf9cc2c882137d.zip
Merge remote-tracking branch 'refs/remotes/raysan5/develop' into develop
Diffstat (limited to 'src/rlgl.c')
-rw-r--r--src/rlgl.c44
1 files changed, 35 insertions, 9 deletions
diff --git a/src/rlgl.c b/src/rlgl.c
index d319119f..0f68953e 100644
--- a/src/rlgl.c
+++ b/src/rlgl.c
@@ -204,8 +204,8 @@ static bool texCompPVRTSupported = false; // PVR texture compression support
static bool texCompASTCSupported = false; // ASTC texture compression support
// Lighting data
-static Light lights[MAX_LIGHTS]; // Lights pool
-static int lightsCount; // Counts current enabled physic objects
+static Light lights[MAX_LIGHTS]; // Lights pool
+static int lightsCount; // Counts current enabled physic objects
#endif
// Compressed textures support flags
@@ -404,6 +404,12 @@ void rlOrtho(double left, double right, double bottom, double top, double near,
#endif
+// Set the viewport area (trasnformation from normalized device coordinates to window coordinates)
+void rlViewport(int x, int y, int width, int height)
+{
+ glViewport(x, y, width, height);
+}
+
//----------------------------------------------------------------------------------
// Module Functions Definition - Vertex level operations
//----------------------------------------------------------------------------------
@@ -725,17 +731,25 @@ void rlDisableTexture(void)
#endif
}
+// Enable rendering to texture (fbo)
void rlEnableRenderTexture(unsigned int id)
{
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
glBindFramebuffer(GL_FRAMEBUFFER, id);
+
+ //glDisable(GL_CULL_FACE); // Allow double side drawing for texture flipping
+ //glCullFace(GL_FRONT);
#endif
}
+// Disable rendering to texture
void rlDisableRenderTexture(void)
{
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
glBindFramebuffer(GL_FRAMEBUFFER, 0);
+
+ //glEnable(GL_CULL_FACE);
+ //glCullFace(GL_BACK);
#endif
}
@@ -1779,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);
@@ -1796,16 +1813,19 @@ void rlglDrawMesh(Mesh mesh, Material material, Matrix transform)
if ((material.texNormal.id != 0) && (material.shader.mapTexture1Loc != -1))
{
+ // Upload to shader specular map flag
+ glUniform1i(glGetUniformLocation(material.shader.id, "useNormal"), 1);
+
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, material.texNormal.id);
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.mapTexture2Loc != -1))
{
+ // Upload to shader specular map flag
+ glUniform1i(glGetUniformLocation(material.shader.id, "useSpecular"), 1);
+
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, material.texSpecular.id);
glUniform1i(material.shader.mapTexture2Loc, 2); // Specular texture fits in active texture unit 2
@@ -2279,7 +2299,13 @@ void DrawLights(void)
{
switch (lights[i]->type)
{
- case LIGHT_POINT: DrawSphereWires(lights[i]->position, 0.3f*lights[i]->intensity, 4, 8, (lights[i]->enabled ? lights[i]->diffuse : BLACK)); break;
+ case LIGHT_POINT:
+ {
+ DrawSphereWires(lights[i]->position, 0.3f*lights[i]->intensity, 4, 8, (lights[i]->enabled ? lights[i]->diffuse : BLACK));
+ Draw3DCircle(lights[i]->position, lights[i]->radius, 0.0f, (Vector3){ 0, 0, 0 }, (lights[i]->enabled ? lights[i]->diffuse : BLACK));
+ Draw3DCircle(lights[i]->position, lights[i]->radius, 90.0f, (Vector3){ 1, 0, 0 }, (lights[i]->enabled ? lights[i]->diffuse : BLACK));
+ Draw3DCircle(lights[i]->position, lights[i]->radius, 90.0f, (Vector3){ 0, 1, 0 }, (lights[i]->enabled ? lights[i]->diffuse : BLACK));
+ } break;
case LIGHT_DIRECTIONAL:
{
Draw3DLine(lights[i]->position, lights[i]->target, (lights[i]->enabled ? lights[i]->diffuse : BLACK));
@@ -2539,7 +2565,7 @@ static Shader LoadDefaultShader(void)
// Load standard shader
// NOTE: This shader supports:
// - Up to 3 different maps: diffuse, normal, specular
-// - Material properties: colAmbient, colDiffuse, colSpecular, glossiness, normalDepth
+// - Material properties: colAmbient, colDiffuse, colSpecular, glossiness
// - Up to 8 lights: Point, Directional or Spot
static Shader LoadStandardShader(void)
{
@@ -3091,9 +3117,9 @@ static void SetShaderLights(Shader shader)
locPoint = GetShaderLocation(shader, locName);
glUniform3f(locPoint, lights[i]->position.x, lights[i]->position.y, lights[i]->position.z);
- memcpy(&locName[10], "attenuation\0", strlen("attenuation\0"));
+ memcpy(&locName[10], "radius\0", strlen("radius\0") + 2);
locPoint = GetShaderLocation(shader, locName);
- glUniform1f(locPoint, lights[i]->attenuation);
+ glUniform1f(locPoint, lights[i]->radius);
} break;
case LIGHT_DIRECTIONAL:
{