List of usage examples for org.lwjgl.opengl GL20 glGetUniformLocation
@NativeType("GLint") public static int glGetUniformLocation(@NativeType("GLuint") int program, @NativeType("GLchar const *") CharSequence name)
From source file:com.samrj.devil.gl.ShaderProgram.java
License:Open Source License
/** * Specifies the value of a uniform variable for this program. Program must * be in use. Returns true if and only if the uniform exists and is active. * /* w w w. j av a2s .co m*/ * @param name The name of the uniform to specify. * @return Whether or not the uniform exists and is active. */ public boolean uniformMat2(String name, Mat2 matrix) { if (DGL.currentProgram() != this) throw new IllegalStateException("Program must be in use."); int loc = GL20.glGetUniformLocation(id, name); if (loc < 0) return false; long address = MemStack.wrap(matrix); GL20.nglUniformMatrix2fv(loc, 1, false, address); MemStack.pop(); return true; }
From source file:com.samrj.devil.gl.ShaderProgram.java
License:Open Source License
/** * Specifies the values of a uniform variable array for this program. Must * be in use. Returns true if and only if the uniform exists and is active. * //w w w .ja v a2s . c o m * @param name The name of the uniform array to specify. * @param array An array of values to set the uniform to. * @return Whether or not the uniform exists and is active. */ public boolean uniformMat2v(String name, Mat2... array) { if (DGL.currentProgram() != this) throw new IllegalStateException("Program must be in use."); int loc = GL20.glGetUniformLocation(id, name); if (loc < 0) return false; long address = MemStack.wrapv(array); GL20.nglUniformMatrix2fv(loc, array.length, false, address); MemStack.pop(); return true; }
From source file:com.samrj.devil.gl.ShaderProgram.java
License:Open Source License
/** * Specifies the value of a uniform variable for this program. Program must * be in use. Returns true if and only if the uniform exists and is active. * //from w w w . j a v a 2 s. co m * @param name The name of the uniform to specify. * @return Whether or not the uniform exists and is active. */ public boolean uniformMat3(String name, Mat3 matrix) { if (DGL.currentProgram() != this) throw new IllegalStateException("Program must be in use."); int loc = GL20.glGetUniformLocation(id, name); if (loc < 0) return false; long address = MemStack.wrap(matrix); GL20.nglUniformMatrix3fv(loc, 1, false, address); MemStack.pop(); return true; }
From source file:com.samrj.devil.gl.ShaderProgram.java
License:Open Source License
/** * Specifies the values of a uniform variable array for this program. Must * be in use. Returns true if and only if the uniform exists and is active. * //from ww w. jav a 2s .com * @param name The name of the uniform array to specify. * @param array An array of values to set the uniform to. * @return Whether or not the uniform exists and is active. */ public boolean uniformMat3v(String name, Mat3... array) { if (DGL.currentProgram() != this) throw new IllegalStateException("Program must be in use."); int loc = GL20.glGetUniformLocation(id, name); if (loc < 0) return false; long address = MemStack.wrapv(array); GL20.nglUniformMatrix3fv(loc, array.length, false, address); MemStack.pop(); return true; }
From source file:com.samrj.devil.gl.ShaderProgram.java
License:Open Source License
/** * Specifies the value of a uniform variable for this program. Program must * be in use. Returns true if and only if the uniform exists and is active. * /* ww w . j a v a2 s.com*/ * @param name The name of the uniform to specify. * @return Whether or not the uniform exists and is active. */ public boolean uniformMat4(String name, Mat4 matrix) { if (DGL.currentProgram() != this) throw new IllegalStateException("Program must be in use."); int loc = GL20.glGetUniformLocation(id, name); if (loc < 0) return false; long address = MemStack.wrap(matrix); GL20.nglUniformMatrix4fv(loc, 1, false, address); MemStack.pop(); return true; }
From source file:com.samrj.devil.gl.ShaderProgram.java
License:Open Source License
/** * Specifies the values of a uniform variable array for this program. Must * be in use. Returns true if and only if the uniform exists and is active. * /*from w w w .j a v a 2 s. c o m*/ * @param name The name of the uniform array to specify. * @param array An array of values to set the uniform to. * @return Whether or not the uniform exists and is active. */ public boolean uniformMat4v(String name, Mat4... array) { if (DGL.currentProgram() != this) throw new IllegalStateException("Program must be in use."); int loc = GL20.glGetUniformLocation(id, name); if (loc < 0) return false; long address = MemStack.wrapv(array); GL20.nglUniformMatrix4fv(loc, array.length, false, address); MemStack.pop(); return true; }
From source file:com.sgflt.ShaderManager.ShaderManager.java
License:Apache License
/** * Pass a FloatBuffer to the active shader. The shader to which the value will be passed must be bound. * /*from w w w . j ava 2s. c o m*/ * @param varName Name of the variable that is in the shader program. Must be an exact match. * @param buf FloatBuffer to be passed to the shader. */ public void putFloatBuffer(String varName, FloatBuffer buf) { if (activeShader != null) { //Courtesy of Drew Malin (that dick made me put this in here) int location = GL20.glGetUniformLocation(activeShader.shaderProgram, varName); buf.flip(); GL20.glUniform1(location, buf); } }
From source file:com.sgflt.ShaderManager.ShaderManager.java
License:Apache License
/** * Pass a float to the active shader. The shader to which the value will be passed must be bound. * /*w w w.j a va2 s . c o m*/ * @param varName Name of the variable that is in the shader program. Must be an exact match. * @param x Primitive float to be passed to the shader. */ public void putFloat(String varName, float x) { if (activeShader != null) { int location = GL20.glGetUniformLocation(activeShader.shaderProgram, varName); GL20.glUniform1f(location, x); } }
From source file:com.sgflt.ShaderManager.ShaderManager.java
License:Apache License
/** * Pass an LWJGL Vector2f to the active shader. The shader to which the value will be passed must be bound. * /*from w ww . j a v a 2 s . c om*/ * @param varName Name of the variable that is in the shader program. Must be an exact match. * @param v LWJGL Vector2f. */ public void putVector2f(String varName, Vector2f v) throws NullPointerException { if (v == null) { throw new NullPointerException("Vector2f passed is null."); } if (activeShader != null) { int location = GL20.glGetUniformLocation(activeShader.shaderProgram, varName); GL20.glUniform2f(location, v.x, v.y); } }
From source file:com.sgflt.ShaderManager.ShaderManager.java
License:Apache License
/** * Pass an LWJGL Vector3f to the active shader. The shader to which the value will be passed must be bound. * //from w w w .jav a2 s. co m * @param varName Name of the variable that is in the shader program. Must be an exact match. * @param v */ public void putVector3f(String varName, Vector3f v) throws NullPointerException { if (v == null) { throw new NullPointerException("Vector3f passed is null."); } if (activeShader != null) { int location = GL20.glGetUniformLocation(activeShader.shaderProgram, varName); GL20.glUniform3f(location, v.x, v.y, v.z); } }