Browse Source

Changed Shader compiling behaviour

Thomas Buck 9 years ago
parent
commit
362b45a8a5
1 changed files with 6 additions and 9 deletions
  1. 6
    9
      src/system/Shader.cpp

+ 6
- 9
src/system/Shader.cpp View File

153
     // Check vertex shader
153
     // Check vertex shader
154
     glGetShaderiv(vertexID, GL_COMPILE_STATUS, &result);
154
     glGetShaderiv(vertexID, GL_COMPILE_STATUS, &result);
155
     glGetShaderiv(vertexID, GL_INFO_LOG_LENGTH, &logLength);
155
     glGetShaderiv(vertexID, GL_INFO_LOG_LENGTH, &logLength);
156
-    if (logLength > 0) {
156
+    if ((logLength > 0) && (result != GL_TRUE)) {
157
         std::vector<char> message(logLength + 1);
157
         std::vector<char> message(logLength + 1);
158
         glGetShaderInfoLog(vertexID, logLength, nullptr, &message[0]);
158
         glGetShaderInfoLog(vertexID, logLength, nullptr, &message[0]);
159
-        if (result != GL_TRUE)
160
-            Log::get(LOG_ERROR) << "Vertex Shader compilation error:" << Log::endl;
159
+        Log::get(LOG_ERROR) << "Vertex Shader compilation error:" << Log::endl;
161
         Log::get(LOG_ERROR) << &message[0] << Log::endl;
160
         Log::get(LOG_ERROR) << &message[0] << Log::endl;
162
         glDeleteShader(vertexID);
161
         glDeleteShader(vertexID);
163
         glDeleteShader(fragmentID);
162
         glDeleteShader(fragmentID);
171
     // Check fragment shader
170
     // Check fragment shader
172
     glGetShaderiv(fragmentID, GL_COMPILE_STATUS, &result);
171
     glGetShaderiv(fragmentID, GL_COMPILE_STATUS, &result);
173
     glGetShaderiv(fragmentID, GL_INFO_LOG_LENGTH, &logLength);
172
     glGetShaderiv(fragmentID, GL_INFO_LOG_LENGTH, &logLength);
174
-    if (logLength > 0) {
173
+    if ((logLength > 0) && (result != GL_TRUE)) {
175
         std::vector<char> message(logLength + 1);
174
         std::vector<char> message(logLength + 1);
176
         glGetShaderInfoLog(fragmentID, logLength, nullptr, &message[0]);
175
         glGetShaderInfoLog(fragmentID, logLength, nullptr, &message[0]);
177
-        if (result != GL_TRUE)
178
-            Log::get(LOG_ERROR) << "Fragment Shader compilation error:" << Log::endl;
176
+        Log::get(LOG_ERROR) << "Fragment Shader compilation error:" << Log::endl;
179
         Log::get(LOG_ERROR) << &message[0] << Log::endl;
177
         Log::get(LOG_ERROR) << &message[0] << Log::endl;
180
         glDeleteShader(vertexID);
178
         glDeleteShader(vertexID);
181
         glDeleteShader(fragmentID);
179
         glDeleteShader(fragmentID);
191
     // Check resulting program
189
     // Check resulting program
192
     glGetProgramiv(programID, GL_LINK_STATUS, &result);
190
     glGetProgramiv(programID, GL_LINK_STATUS, &result);
193
     glGetProgramiv(programID, GL_INFO_LOG_LENGTH, &logLength);
191
     glGetProgramiv(programID, GL_INFO_LOG_LENGTH, &logLength);
194
-    if (logLength > 0) {
192
+    if ((logLength > 0) && (result != GL_TRUE)) {
195
         std::vector<char> message(logLength + 1);
193
         std::vector<char> message(logLength + 1);
196
         glGetProgramInfoLog(programID, logLength, nullptr, &message[0]);
194
         glGetProgramInfoLog(programID, logLength, nullptr, &message[0]);
197
-        if (result != GL_TRUE)
198
-            Log::get(LOG_ERROR) << "Shader link error:" << Log::endl;
195
+        Log::get(LOG_ERROR) << "Shader link error:" << Log::endl;
199
         Log::get(LOG_ERROR) << &message[0] << Log::endl;
196
         Log::get(LOG_ERROR) << &message[0] << Log::endl;
200
         glDeleteShader(vertexID);
197
         glDeleteShader(vertexID);
201
         glDeleteShader(fragmentID);
198
         glDeleteShader(fragmentID);

Loading…
Cancel
Save