Java Code Examples for org.lwjgl.opengl.GL20#glUniform2f()
The following examples show how to use
org.lwjgl.opengl.GL20#glUniform2f() .
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: OutlineShader.java From LiquidBounce with GNU General Public License v3.0 | 5 votes |
@Override public void updateUniforms() { GL20.glUniform1i(getUniform("texture"), 0); GL20.glUniform2f(getUniform("texelSize"), 1F / mc.displayWidth * (radius * quality), 1F / mc.displayHeight * (radius * quality)); GL20.glUniform4f(getUniform("color"), red, green, blue, alpha); GL20.glUniform1f(getUniform("radius"), radius); }
Example 2
Source File: BackgroundShader.java From LiquidBounce with GNU General Public License v3.0 | 5 votes |
@Override public void updateUniforms() { final ScaledResolution scaledResolution = new ScaledResolution(mc); final int resolutionID = getUniform("iResolution"); if(resolutionID > -1) GL20.glUniform2f(resolutionID, (float) scaledResolution.getScaledWidth() * 2, (float) scaledResolution.getScaledHeight() * 2); final int timeID = getUniform("iTime"); if(timeID > -1) GL20.glUniform1f(timeID, time); time += 0.005F * RenderUtils.deltaTime; }
Example 3
Source File: GlowShader.java From LiquidBounce with GNU General Public License v3.0 | 5 votes |
@Override public void updateUniforms() { GL20.glUniform1i(getUniform("texture"), 0); GL20.glUniform2f(getUniform("texelSize"), 1F / mc.displayWidth * (radius * quality), 1F / mc.displayHeight * (radius * quality)); GL20.glUniform3f(getUniform("color"), red, green, blue); GL20.glUniform1f(getUniform("divider"), 140F); GL20.glUniform1f(getUniform("radius"), radius); GL20.glUniform1f(getUniform("maxSample"), 10F); }
Example 4
Source File: UniformVec2.java From LowPolyWater with The Unlicense | 5 votes |
public void loadVec2(float x, float y) { if (!used || x != currentX || y != currentY) { this.currentX = x; this.currentY = y; used = true; GL20.glUniform2f(super.getLocation(), x, y); } }
Example 5
Source File: UniformVec2.java From OpenGL-Animation with The Unlicense | 5 votes |
public void loadVec2(float x, float y) { if (!used || x != currentX || y != currentY) { this.currentX = x; this.currentY = y; used = true; GL20.glUniform2f(super.getLocation(), x, y); } }
Example 6
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 7
Source File: LWJGL20DrawContext.java From settlers-remake with MIT License | 5 votes |
@Override public void drawTrianglesWithTextureColored(TextureHandle textureid, GeometryHandle shapeHandle, GeometryHandle colorHandle, int offset, int lines, int width, int stride, float x, float y) { bindTexture(textureid); if(backgroundVAO == -1) { if(glcaps.GL_ARB_vertex_array_object) { backgroundVAO = ARBVertexArrayObject.glGenVertexArrays(); bindFormat(backgroundVAO); } GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); bindGeometry(shapeHandle); GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 5 * 4, 0); GL20.glVertexAttribPointer(1, 2, GL11.GL_FLOAT, false, 5 * 4, 3 * 4); bindGeometry(colorHandle); GL20.glVertexAttribPointer(2, 1, GL11.GL_FLOAT, false, 0, 0); setObjectLabel(GL11.GL_VERTEX_ARRAY, backgroundVAO, "background-vao"); setObjectLabel(KHRDebug.GL_BUFFER, shapeHandle.getInternalId(), "background-shape"); setObjectLabel(KHRDebug.GL_BUFFER, colorHandle.getInternalId(), "background-color"); } int starti = offset < 0 ? (int)Math.ceil(-offset/(float)stride) : 0; useProgram(prog_background); GL20.glUniform2f(prog_background.ufs[TRANS], x, y); bindFormat(backgroundVAO); for (int i = starti; i != lines; i++) { GL11.glDrawArrays(GL11.GL_TRIANGLES, (offset + stride * i) * 3, width * 3); } }
Example 8
Source File: BlurPane.java From LWJGUI with MIT License | 4 votes |
@Override public void render(Context context, int x, int y, int w, int h) { if ( !isVisible() ) return; if ( this.quad == null || quadDirty ) { if ( this.quad != null ) { this.quad.cleanup(); } quad = new TexturedQuad(0, 0, w, h, source.getTexId()); } GL11.glViewport(x, y, w, h); this.quadDirty = false; quadShader.bind(); quadShader.projectOrtho(0, h, w, -h); // bind stuff GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, source.getTexId()); if ( internalBackground instanceof BackgroundSolid ) { BackgroundSolid bg = (BackgroundSolid)internalBackground; GL20.glUniform4f(GL20.glGetUniformLocation(quadShader.getProgram(), "uColor"), bg.getColor().getRed()/255f-0.5f, bg.getColor().getGreen()/255f-0.5f, bg.getColor().getBlue()/255f-0.5f, bg.getColor().getAlpha()/255f); } GL20.glUniform1f(GL20.glGetUniformLocation(quadShader.getProgram(), "uBlurSize"), blurRadius); GL20.glUniform2f(GL20.glGetUniformLocation(quadShader.getProgram(), "uTexelSize"), 1.0f/(float)w, 1.0f/(float)h); GL20.glUniform4f(GL20.glGetUniformLocation(quadShader.getProgram(), "uCornerRadii"), (float)Math.max(BlurPane.this.getBorderRadii()[0], 0.1), (float)Math.max(BlurPane.this.getBorderRadii()[1], 0.1), (float)Math.max(BlurPane.this.getBorderRadii()[2], 0.1), (float)Math.max(BlurPane.this.getBorderRadii()[3], 0.1)); // Draw quad if ( context.isCoreOpenGL() ) { if ( quad != null ) { quad.render(); } } else { GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, source.getTexId()); GL11.glBegin(GL11.GL_QUADS); GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glTexCoord2f(0, 0); GL11.glVertex2f(0, 0); GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glTexCoord2f(1, 0); GL11.glVertex2f(w, 0); GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glTexCoord2f(1, 1); GL11.glVertex2f(w, h); GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glTexCoord2f(0, 1); GL11.glVertex2f(0, h); GL11.glEnd(); } }