Permalink
Browse files

corrected shader validity check

  • Loading branch information...
1 parent a5f42bd commit 24a0c1445f5b354b0338a5d5d7d09698c1fc894a @alihelmy committed Apr 22, 2012
Showing with 6 additions and 28 deletions.
  1. +6 −28 LessonTwo/lwjgltutorial/lessonTwo/ShaderUtilities.java
@@ -1,26 +1,22 @@
package lwjgltutorial.lessonTwo;
-import static org.lwjgl.opengl.ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB;
import static org.lwjgl.opengl.ARBShaderObjects.glCompileShaderARB;
import static org.lwjgl.opengl.ARBShaderObjects.glCreateShaderObjectARB;
-import static org.lwjgl.opengl.ARBShaderObjects.glGetInfoLogARB;
-import static org.lwjgl.opengl.ARBShaderObjects.glGetObjectParameterARB;
import static org.lwjgl.opengl.ARBShaderObjects.glShaderSourceARB;
+import static org.lwjgl.opengl.GL11.GL_TRUE;
+import static org.lwjgl.opengl.GL20.GL_COMPILE_STATUS;
+import static org.lwjgl.opengl.GL20.glGetShader;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.IntBuffer;
-import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.ARBFragmentShader;
import org.lwjgl.opengl.ARBVertexShader;
public class ShaderUtilities {
- private static boolean verboseValidityCheck=false;
private static final String SHADERS_ROOT_PATH="shaders";
public static int createFragmentShader(String pathToShaderFile) {
@@ -67,27 +63,9 @@ private static String readInShaderCodeFromShaderFile(String pathToShaderFile) {
}
}
- public static boolean isShaderValid(int shaderToCheck) {
- IntBuffer iVal = BufferUtils.createIntBuffer(1);
- glGetObjectParameterARB(shaderToCheck, GL_OBJECT_INFO_LOG_LENGTH_ARB, iVal);
- int length = iVal.get();
- boolean isValid = length>1;
- if (isValid && verboseValidityCheck) {
- printShaderLogInfo(shaderToCheck, iVal, length);
- }
-
- return isValid;
- }
-
- private static void printShaderLogInfo(int shaderToCheck, IntBuffer iVal,
- int length) {
- ByteBuffer infoLog = BufferUtils.createByteBuffer(length);
- iVal.flip();
- glGetInfoLogARB(shaderToCheck, iVal, infoLog);
- byte[] infoBytes = new byte[length];
- infoLog.get(infoBytes);
- String out = new String(infoBytes);
- System.out.println("Info log:\n"+out);
+ public static boolean isShaderValid(int shaderToCheck) {
+ int status=glGetShader(shaderToCheck, GL_COMPILE_STATUS);
+ return status == GL_TRUE;
}
}

0 comments on commit 24a0c14

Please sign in to comment.