List of usage examples for org.lwjgl.opengl GL20 glGetShaderi
@NativeType("void") public static int glGetShaderi(@NativeType("GLuint") int shader, @NativeType("GLenum") int pname)
From source file:br.com.perin.shaders.ShaderProgram.java
private static int loadShader(String file, int type) { StringBuilder shaderSource = new StringBuilder(); try (BufferedReader reader = new BufferedReader(new FileReader(file))) { String line;/*www . j a v a 2 s. co m*/ while ((line = reader.readLine()) != null) { shaderSource.append(line).append("//\n"); } } catch (IOException e) { e.printStackTrace(); System.exit(-1); } int shaderID = GL20.glCreateShader(type); GL20.glShaderSource(shaderID, shaderSource); GL20.glCompileShader(shaderID); if (GL20.glGetShaderi(shaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) { System.out.println(GL20.glGetShaderInfoLog(shaderID, 500)); System.err.println("Could not compile shader!"); System.exit(-1); } return shaderID; }
From source file:com.flowpowered.caustic.lwjgl.gl20.GL20Shader.java
License:MIT License
@Override public void compile() { checkCreated();// w w w .j a v a2s . co m // Compile the shader GL20.glCompileShader(id); // Get the shader compile status property, check it's false and fail if that's the case if (GL20.glGetShaderi(id, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) { throw new IllegalStateException( "OPEN GL ERROR: Could not compile shader\n" + GL20.glGetShaderInfoLog(id, 1000)); } // Check for errors LWJGLUtil.checkForGLError(); }
From source file:com.geekyaubergine.geekyjgameutil.shader.ShaderProgram.java
License:Open Source License
/** * Loads shader program from file and returns the shader ID * @param file File to read//from w ww .jav a2 s . c o m * @param type Type of shader * @return Shader ID * @throws IOException */ private int loadShaderFile(File file, int type) throws IOException { List<String> lines = FileUtil.readLinesFromFile(file, false, true); StringBuilder shaderSource = new StringBuilder(); for (String line : lines) { shaderSource.append(line).append("\n"); } int shaderID = GL20.glCreateShader(type); GL20.glShaderSource(shaderID, shaderSource); GL20.glCompileShader(shaderID); if (GL20.glGetShaderi(shaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) { Log.error("Could not complile shader"); Log.error(GL20.glGetShaderInfoLog(shaderID, 500)); } return shaderID; }
From source file:com.github.kajdreef.mazerunnermvn.MazeRunner.ShaderProgram.java
public int compileShader(int shaderType, String shaderName) { // Initialize the vertex Shader int shaderId = GL20.glCreateShader(shaderType); GL20.glShaderSource(shaderId, loadShader(defaultShaderLocation + shaderName)); GL20.glCompileShader(shaderId);/*from w ww. ja va 2 s. c om*/ // Check if the vertex shader compiled if (GL20.glGetShaderi(shaderId, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) { log.logError("Failed to compile " + shaderName + " shader"); System.exit(-1); } return shaderId; }
From source file:com.github.ryancwilliams.WJ3dPL.graphics.GLUtils.ShaderProgram.java
License:Apache License
/** * Compiles a shader from the provided source and returns its OpenGL handle. * @param type the shader type to use when compiling. * @param source the source to compile./*from www. j a v a 2s .c o m*/ * @return the OpenGL handle for this shader. * @throws LWJGLException if compilation was unsuccessful */ public static int compileShader(int type, String source) throws LWJGLException { //Create the shader ponter varable int shader; //Create the shader shader = GL20.glCreateShader(type); //load the source GL20.glShaderSource(shader, source); //compile the source GL20.glCompileShader(shader); //Get if the compile was good boolean compile = GL20.glGetShaderi(shader, GL20.GL_COMPILE_STATUS) == GL11.GL_TRUE; //Get the log String infoLog = GL20.glGetShaderInfoLog(shader, GL20.glGetShaderi(shader, GL20.GL_INFO_LOG_LENGTH)); //Log the log if a log is present if (infoLog != null && infoLog.trim().length() != 0) { Logger.getLogger(ShaderProgram.class.getName()).log(Level.FINEST, infoLog); } //Check if the compiling was unsuccessful if (compile == false) { //throw a exception if unsuccessful throw new LWJGLException( "Failure in compiling " + ShaderProgram.typeToString(type) + ". Error log:\n" + infoLog); } //Return the OpenGL pointer for the shader return shader; }
From source file:com.google.gapid.glviewer.gl.Shader.java
License:Apache License
private static int createShader(int type, String source) { int shader = GL20.glCreateShader(type); GL20.glShaderSource(shader, source); GL20.glCompileShader(shader);/*from ww w .j a va2s.co m*/ if (GL20.glGetShaderi(shader, GL20.GL_COMPILE_STATUS) != GL11.GL_TRUE) { LOG.log(WARNING, "Failed to compile shader:\n" + GL20.glGetShaderInfoLog(shader) + "\n\nSource:\n" + source); GL20.glDeleteShader(shader); return -1; } return shader; }
From source file:com.google.gapid.glviewer.gl.Util.java
License:Apache License
public static int getShaderiv(int shader, int name) { return GL20.glGetShaderi(shader, name); }
From source file:com.grillecube.client.opengl.GLShader.java
public static int loadShader(String filepath, int type, String preprocessor) { Logger.get().log(Logger.Level.FINE, "Loading shader: " + filepath); try {/*from ww w .j a v a 2 s . co m*/ String source = readFile(filepath) + preprocessor; int shader_id = GL20.glCreateShader(type); GL20.glShaderSource(shader_id, source); GL20.glCompileShader(shader_id); if (GL20.glGetShaderi(shader_id, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) { System.out.println(GL20.glGetShaderInfoLog(shader_id, 512)); System.err.println("Couldnt compile shader: " + filepath); return (-1); } return (shader_id); } catch (IOException e) { System.out.println("couldnt read file: " + filepath); e.printStackTrace(); return (-1); } }
From source file:com.grillecube.engine.opengl.object.GLShader.java
public static int loadShader(String filepath, int type) { Logger.get().log(Logger.Level.FINE, "Loading shader: " + filepath); try {// w ww . j a va 2s. c om String source = readFile(filepath); int shader_id = GL20.glCreateShader(type); GL20.glShaderSource(shader_id, source); GL20.glCompileShader(shader_id); if (GL20.glGetShaderi(shader_id, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) { System.out.println(GL20.glGetShaderInfoLog(shader_id, 512)); System.err.println("Couldnt compile shader: " + filepath); return (-1); } return (shader_id); } catch (IOException e) { System.out.println("couldnt read file: " + filepath); e.printStackTrace(); return (-1); } }
From source file:com.kauridev.lunarfever.graphics.ShaderProgram.java
License:Open Source License
private int compileShader(int type, String source) { int shader = GL20.glCreateShader(type); if (shader == 0) { throw new RuntimeException(); }//from ww w . j av a 2 s. c o m GL20.glShaderSource(shader, source); GL20.glCompileShader(shader); int comp = GL20.glGetShaderi(shader, GL20.GL_COMPILE_STATUS); int len = GL20.glGetShaderi(shader, GL20.GL_INFO_LOG_LENGTH); if (comp == GL11.GL_FALSE) { throw new RuntimeException(GL20.glGetShaderInfoLog(shader, len)); } return shader; }