Java Code Examples for org.lwjgl.opengl.GL20#glUniformMatrix4fv()
The following examples show how to use
org.lwjgl.opengl.GL20#glUniformMatrix4fv() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShaderUniformCache.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void apply() { if (dirty) { switch (type.getCarrier()) { //@formatter:off case FLOAT: switch (type.getSize()) { case 1: GL20.glUniform1f(getLocation(), cache[0]); break; case 2: GL20.glUniform2f(getLocation(), cache[0], cache[1]); break; case 3: GL20.glUniform3f(getLocation(), cache[0], cache[1], cache[2]); break; case 4: GL20.glUniform4f(getLocation(), cache[0], cache[1], cache[2], cache[3]); break; default: throw new IllegalStateException("Invalid size for Float type." + type.getSize()); } break; case D_MATRIX: switch (type) { case MAT2: GL20.glUniformMatrix2fv (getLocation(), transpose, cache); break; case MAT3: GL20.glUniformMatrix3fv (getLocation(), transpose, cache); break; case MAT4: GL20.glUniformMatrix4fv (getLocation(), transpose, cache); break; case MAT2x3: GL21.glUniformMatrix2x3fv(getLocation(), transpose, cache); break; case MAT2x4: GL21.glUniformMatrix2x4fv(getLocation(), transpose, cache); break; case MAT3x2: GL21.glUniformMatrix3x2fv(getLocation(), transpose, cache); break; case MAT3x4: GL21.glUniformMatrix3x4fv(getLocation(), transpose, cache); break; case MAT4x2: GL21.glUniformMatrix4x2fv(getLocation(), transpose, cache); break; case MAT4x3: GL21.glUniformMatrix4x3fv(getLocation(), transpose, cache); break; default: throw new IllegalStateException("Invalid Matrix type: " + type); } break; default: throw new IllegalStateException("Invalid type for FloatUniformEntry: " + type.getCarrier()); //@formatter:on } dirty = false; } }
Example 2
Source File: GLMatrixStack.java From ldparteditor with MIT License | 5 votes |
public void clear() { stack.clear(); final Matrix4f ID = new Matrix4f(); Matrix4f.setIdentity(ID); final FloatBuffer ID_buf = BufferUtils.createFloatBuffer(16); ID.store(ID_buf); ID_buf.position(0); currentMatrix = ID; int model = shader.getUniformLocation("model" ); //$NON-NLS-1$ GL20.glUniformMatrix4fv(model, false, ID_buf); }
Example 3
Source File: GLMatrixStack.java From ldparteditor with MIT License | 5 votes |
public void glPopMatrix() { if (!stack.isEmpty()) { currentMatrix = stack.pop(); final FloatBuffer buf = BufferUtils.createFloatBuffer(16); currentMatrix.store(buf); buf.position(0); int model = shader.getUniformLocation("model" ); //$NON-NLS-1$ GL20.glUniformMatrix4fv(model, false, buf); } }
Example 4
Source File: GLMatrixStack.java From ldparteditor with MIT License | 5 votes |
public void glLoadIdentity() { final Matrix4f ID = new Matrix4f(); Matrix4f.setIdentity(ID); final FloatBuffer ID_buf = BufferUtils.createFloatBuffer(16); ID.store(ID_buf); ID_buf.position(0); currentMatrix = ID; int model = shader.getUniformLocation("model" ); //$NON-NLS-1$ GL20.glUniformMatrix4fv(model, false, ID_buf); int view = shader.getUniformLocation("view" ); //$NON-NLS-1$ GL20.glUniformMatrix4fv(view, false, ID_buf); }
Example 5
Source File: GLMatrixStack.java From ldparteditor with MIT License | 5 votes |
public void glLoadMatrix(Matrix4f m) { final FloatBuffer m_buf = BufferUtils.createFloatBuffer(16); m.store(m_buf); m_buf.position(0); currentMatrix = m; int model = shader.getUniformLocation("model" ); //$NON-NLS-1$ GL20.glUniformMatrix4fv(model, false, m_buf); }
Example 6
Source File: GLMatrixStack.java From ldparteditor with MIT License | 5 votes |
public void glMultMatrixf(Matrix4f matrix) { Matrix4f.mul(currentMatrix, matrix, currentMatrix); final FloatBuffer buf = BufferUtils.createFloatBuffer(16); currentMatrix.store(buf); buf.position(0); int model = shader.getUniformLocation("model" ); //$NON-NLS-1$ GL20.glUniformMatrix4fv(model, false, buf); }
Example 7
Source File: GLMatrixStack.java From ldparteditor with MIT License | 5 votes |
public void glTranslatef(float x, float y, float z) { Matrix4f.translate(new Vector3f(x, y, z), currentMatrix, currentMatrix); final FloatBuffer buf = BufferUtils.createFloatBuffer(16); currentMatrix.store(buf); buf.position(0); int model = shader.getUniformLocation("model" ); //$NON-NLS-1$ GL20.glUniformMatrix4fv(model, false, buf); }
Example 8
Source File: GLMatrixStack.java From ldparteditor with MIT License | 5 votes |
public void glScalef(float x, float y, float z) { Matrix4f.scale(new Vector3f(x, y, z), currentMatrix, currentMatrix); final FloatBuffer buf = BufferUtils.createFloatBuffer(16); currentMatrix.store(buf); buf.position(0); int model = shader.getUniformLocation("model" ); //$NON-NLS-1$ GL20.glUniformMatrix4fv(model, false, buf); }
Example 9
Source File: LWJGL20DrawContext.java From settlers-remake with MIT License | 5 votes |
@Override public void setGlobalAttributes(float x, float y, float z, float sx, float sy, float sz) { global.identity(); global.translate(x, y, z); global.scale(sx, sy, sz); global.get(matBfr); for(ShaderProgram shader : shaders) { useProgram(shader); GL20.glUniformMatrix4fv(shader.ufs[GLOBAL], false, matBfr); } }
Example 10
Source File: LWJGL20DrawContext.java From settlers-remake with MIT License | 5 votes |
@Override public void resize(int width, int height) { GL11.glViewport(0, 0, width, height); mat.identity(); mat.ortho(0, width, 0, height, -1, 1); mat.get(matBfr); for(ShaderProgram shader : shaders) { useProgram(shader); GL20.glUniformMatrix4fv(shader.ufs[PROJ], false, matBfr); } }
Example 11
Source File: LWJGL20DrawContext.java From settlers-remake with MIT License | 4 votes |
@Override public void setHeightMatrix(float[] matrix) { useProgram(prog_background); GL20.glUniformMatrix4fv(prog_background.ufs[HEIGHT], false, matrix); }