|
@ -204,8 +204,8 @@ static bool texCompPVRTSupported = false; // PVR texture compression support |
|
|
static bool texCompASTCSupported = false; // ASTC texture compression support |
|
|
static bool texCompASTCSupported = false; // ASTC texture compression support |
|
|
|
|
|
|
|
|
// Lighting data |
|
|
// 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 |
|
|
#endif |
|
|
|
|
|
|
|
|
// Compressed textures support flags |
|
|
// Compressed textures support flags |
|
@ -404,6 +404,12 @@ void rlOrtho(double left, double right, double bottom, double top, double near, |
|
|
|
|
|
|
|
|
#endif |
|
|
#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 |
|
|
// Module Functions Definition - Vertex level operations |
|
|
//---------------------------------------------------------------------------------- |
|
|
//---------------------------------------------------------------------------------- |
|
@ -725,17 +731,25 @@ void rlDisableTexture(void) |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Enable rendering to texture (fbo) |
|
|
void rlEnableRenderTexture(unsigned int id) |
|
|
void rlEnableRenderTexture(unsigned int id) |
|
|
{ |
|
|
{ |
|
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
|
glBindFramebuffer(GL_FRAMEBUFFER, id); |
|
|
glBindFramebuffer(GL_FRAMEBUFFER, id); |
|
|
|
|
|
|
|
|
|
|
|
//glDisable(GL_CULL_FACE); // Allow double side drawing for texture flipping |
|
|
|
|
|
//glCullFace(GL_FRONT); |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Disable rendering to texture |
|
|
void rlDisableRenderTexture(void) |
|
|
void rlDisableRenderTexture(void) |
|
|
{ |
|
|
{ |
|
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
|
glBindFramebuffer(GL_FRAMEBUFFER, 0); |
|
|
glBindFramebuffer(GL_FRAMEBUFFER, 0); |
|
|
|
|
|
|
|
|
|
|
|
//glEnable(GL_CULL_FACE); |
|
|
|
|
|
//glCullFace(GL_BACK); |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -1779,6 +1793,9 @@ void rlglDrawMesh(Mesh mesh, Material material, Matrix transform) |
|
|
// Setup shader uniforms for lights |
|
|
// Setup shader uniforms for lights |
|
|
SetShaderLights(material.shader); |
|
|
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 |
|
|
// 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); |
|
|
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)) |
|
|
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); |
|
|
glActiveTexture(GL_TEXTURE1); |
|
|
glBindTexture(GL_TEXTURE_2D, material.texNormal.id); |
|
|
glBindTexture(GL_TEXTURE_2D, material.texNormal.id); |
|
|
glUniform1i(material.shader.mapTexture1Loc, 1); // Normal 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.mapTexture2Loc != -1)) |
|
|
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); |
|
|
glActiveTexture(GL_TEXTURE2); |
|
|
glBindTexture(GL_TEXTURE_2D, material.texSpecular.id); |
|
|
glBindTexture(GL_TEXTURE_2D, material.texSpecular.id); |
|
|
glUniform1i(material.shader.mapTexture2Loc, 2); // Specular texture fits in active texture unit 2 |
|
|
glUniform1i(material.shader.mapTexture2Loc, 2); // Specular texture fits in active texture unit 2 |
|
@ -2279,7 +2299,13 @@ void DrawLights(void) |
|
|
{ |
|
|
{ |
|
|
switch (lights[i]->type) |
|
|
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: |
|
|
case LIGHT_DIRECTIONAL: |
|
|
{ |
|
|
{ |
|
|
Draw3DLine(lights[i]->position, lights[i]->target, (lights[i]->enabled ? lights[i]->diffuse : BLACK)); |
|
|
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 |
|
|
// Load standard shader |
|
|
// NOTE: This shader supports: |
|
|
// NOTE: This shader supports: |
|
|
// - Up to 3 different maps: diffuse, normal, specular |
|
|
// - 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 |
|
|
// - Up to 8 lights: Point, Directional or Spot |
|
|
static Shader LoadStandardShader(void) |
|
|
static Shader LoadStandardShader(void) |
|
|
{ |
|
|
{ |
|
@ -3091,9 +3117,9 @@ static void SetShaderLights(Shader shader) |
|
|
locPoint = GetShaderLocation(shader, locName); |
|
|
locPoint = GetShaderLocation(shader, locName); |
|
|
glUniform3f(locPoint, lights[i]->position.x, lights[i]->position.y, lights[i]->position.z); |
|
|
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); |
|
|
locPoint = GetShaderLocation(shader, locName); |
|
|
glUniform1f(locPoint, lights[i]->attenuation); |
|
|
|
|
|
|
|
|
glUniform1f(locPoint, lights[i]->radius); |
|
|
} break; |
|
|
} break; |
|
|
case LIGHT_DIRECTIONAL: |
|
|
case LIGHT_DIRECTIONAL: |
|
|
{ |
|
|
{ |
|
|