List of usage examples for org.lwjgl.opengl GL20 glUniformMatrix4fv
public static void glUniformMatrix4fv(@NativeType("GLint") int location, @NativeType("GLboolean") boolean transpose, @NativeType("GLfloat const *") float[] value)
From source file:opengl.test.object.XO.java
@Override protected void initUniformValues() { this.bind();//from w w w . j av a2 s . c om if (x != -1 && y != -1) { modelID = GL20.glGetUniformLocation(this.getProgramID(), "model"); x_calc = 0; y_calc = 0; if (x == 0) y_calc = 0.3f; if (x == 1) y_calc = 0; if (x == 2) y_calc = -0.3f; if (y == 0) x_calc = -0.3f; if (y == 1) x_calc = 0f; if (y == 2) x_calc = 0.3f; Matrix4F m = Matrix4F.ratio(0.10f, 0.10f, 0.10f).nhanMaTran(Matrix4F.rotateOX(90)) .nhanMaTran(Matrix4F.move(x_calc, y_calc, -0.0005f)); GL20.glUniformMatrix4fv(modelID, false, m.toFloatBuffer()); } else { modelID = GL20.glGetUniformLocation(this.getProgramID(), "model"); Matrix4F m = new Matrix4F(); GL20.glUniformMatrix4fv(modelID, false, m.toFloatBuffer()); } viewID = GL20.glGetUniformLocation(this.getProgramID(), "view"); Matrix4F v = new Matrix4F(); GL20.glUniformMatrix4fv(viewID, false, v.toFloatBuffer()); projectionID = GL20.glGetUniformLocation(this.getProgramID(), "projection"); Matrix4F p = new Matrix4F(); GL20.glUniformMatrix4fv(projectionID, false, p.toFloatBuffer()); this.unbind(); }
From source file:opengl.test.object.XO.java
@Override public void setModelMatrix(Matrix4F m) { this.bind();//from w w w .j a v a 2 s. co m Matrix4F m2 = Matrix4F.ratio(0.10f, 0.10f, 0.10f).nhanMaTran(Matrix4F.rotateOX(90)) .nhanMaTran(Matrix4F.move(x_calc, y_calc, -0.0005f)).nhanMaTran(m); GL20.glUniformMatrix4fv(modelID, false, m2.toFloatBuffer()); this.unbind(); }
From source file:wrath.client.graphics.Camera.java
License:Open Source License
/** * Is called automatically, this method is used to update the specified shader's View Matrix, if need be. * @param shader The {@link wrath.client.graphics.ShaderProgram} to update. *///from w w w .ja v a2 s .c om public void updateViewMatrix(ShaderProgram shader) { GL20.glUseProgram(shader.getProgramID()); if (updateMat) { ClientUtils.createViewMatrix(this).store(matrixBuf); matrixBuf.flip(); updateMat = false; } GL20.glUniformMatrix4fv(shader.getUniformVariableLocation("viewMatrix"), false, matrixBuf); }
From source file:wrath.client.graphics.ShaderProgram.java
License:Open Source License
/** * Changes the shader's projection matrix to the one specified. * This will only work with the 3D shader! * @param value The {@link org.lwjgl.util.vector.Matrix4f} object containing the shader projection data. *//*from www. java 2 s. co m*/ public void setProjectionMatrix(Matrix4f value) { GL20.glUseProgram(programID); FloatBuffer pbuf = BufferUtils.createFloatBuffer(16); value.store(pbuf); pbuf.flip(); GL20.glUniformMatrix4fv(getUniformVariableLocation("projectionMatrix"), false, pbuf); }
From source file:wrath.client.graphics.ShaderProgram.java
License:Open Source License
/** * Changes the shader's transformation matrix to the one specified. * @param value The {@link org.lwjgl.util.vector.Matrix4f} object containing the shader transformation data. *//* w ww. ja v a 2 s. co m*/ public void setTransformationMatrix(Matrix4f value) { GL20.glUseProgram(programID); value.store(matrixBuf); matrixBuf.flip(); GL20.glUniformMatrix4fv(getUniformVariableLocation("transformationMatrix"), false, matrixBuf); }
From source file:wrath.client.graphics.ShaderProgram.java
License:Open Source License
/** * Sets the value of a uniform variable in the shader. * @param location The integer id of the Uniform variable. * @param value The value to set./*w w w .ja va 2 s . c o m*/ */ public void setUniformVariable(int location, Matrix4f value) { GL20.glUseProgram(programID); value.store(matrixBuf); matrixBuf.flip(); GL20.glUniformMatrix4fv(location, false, matrixBuf); }