From 9572d6c0632fae001481d8395e8e6f154aaf4a4c Mon Sep 17 00:00:00 2001 From: raysan5 Date: Tue, 16 Jun 2015 20:02:01 +0200 Subject: [PATCH] Updated postpro shaders system --- src/core.c | 2 ++ src/models.c | 12 ++++++++++-- src/rlgl.c | 14 +++++++++++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/core.c b/src/core.c index ff704ed4..7bbe3892 100644 --- a/src/core.c +++ b/src/core.c @@ -999,6 +999,8 @@ void SetCustomShader(Shader shader) void SetDefaultShader(void) { rlglSetDefaultShader(); + + enabledPostpro = false; } //---------------------------------------------------------------------------------- diff --git a/src/models.c b/src/models.c index 179032d4..de3f6da0 100644 --- a/src/models.c +++ b/src/models.c @@ -1112,8 +1112,16 @@ void UnloadModel(Model model) // Link a texture to a model void SetModelTexture(Model *model, Texture2D texture) { - if (texture.id <= 0) model->texture.id = whiteTexture; // Default white texture (use mesh color) - else model->texture = texture; + if (texture.id <= 0) + { + model->texture.id = whiteTexture; // Default white texture (use mesh color) + model->shader.texDiffuseId = whiteTexture; + } + else + { + model->texture = texture; + model->shader.texDiffuseId = texture.id; + } } // Load a custom shader (vertex shader + fragment shader) diff --git a/src/rlgl.c b/src/rlgl.c index c1dbc722..02776995 100644 --- a/src/rlgl.c +++ b/src/rlgl.c @@ -1058,7 +1058,11 @@ void rlglInitPostpro(void) void rlglSetPostproShader(Shader shader) { #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) - SetModelShader(&postproQuad, shader); + rlglSetModelShader(&postproQuad, shader); + + //TraceLog(INFO, "Postproquad texture id: %i", postproQuad.texture.id); + //TraceLog(INFO, "Postproquad shader diffuse map id: %i", postproQuad.shader.texDiffuseId); + //TraceLog(INFO, "Shader diffuse map id: %i", shader.texDiffuseId); #endif } @@ -1365,7 +1369,8 @@ void rlglDrawModel(Model model, Vector3 position, float rotationAngle, Vector3 r // Set shader textures (diffuse, normal, specular) glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, model.shader.texDiffuseId); + glBindTexture(GL_TEXTURE_2D, model.texture.id); + //glBindTexture(GL_TEXTURE_2D, model.shader.texDiffuseId); //glUniform1i(model.shader.mapDiffuseLoc, 0); // Diffuse texture fits in texture unit 0 if (vaoSupported) @@ -2104,6 +2109,8 @@ void rlglSetModelShader(Model *model, Shader shader) glVertexAttribPointer(shader.normalLoc, 3, GL_FLOAT, 0, 0, 0); if (vaoSupported) glBindVertexArray(0); // Unbind VAO + + //if (model->texture.id > 0) model->shader.texDiffuseId = model->texture.id; #endif } @@ -2144,7 +2151,8 @@ void rlglSetCustomShader(Shader shader) void rlglSetDefaultShader(void) { #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) - rlglSetCustomShader(defaultShader); + //rlglSetCustomShader(defaultShader); + rlglSetPostproShader(defaultShader); #endif }