List of usage examples for org.lwjgl.opengl GL20 glUniform1i
public static void glUniform1i(@NativeType("GLint") int location, @NativeType("GLint") int v0)
From source file:com.xrbpowered.gl.res.shaders.StandardShader.java
License:Open Source License
private void setPointLights(int n, Vector3f[] positions, Vector4f[] colors, Vector3f[] att) { GL20.glUseProgram(pId);//w w w .ja v a2 s . com GL20.glUniform1i(GL20.glGetUniformLocation(pId, "numPointLights"), n); for (int i = 0; i < n; i++) { String s = String.format("pointLights[%d].", i); uniform(GL20.glGetUniformLocation(pId, s + "position"), positions[i]); uniform(GL20.glGetUniformLocation(pId, s + "att"), att[i]); uniform(GL20.glGetUniformLocation(pId, s + "color"), colors[i]); } GL20.glUseProgram(0); }
From source file:com.xrbpowered.gl.ui.UIShader.java
License:Open Source License
@Override protected void storeUniformLocations() { alphaLocation = GL20.glGetUniformLocation(pId, "alpha"); anchorLocation = GL20.glGetUniformLocation(pId, "anchor"); screenSizeLocation = GL20.glGetUniformLocation(pId, "screenSize"); GL20.glUseProgram(pId);/*from w ww.j ava 2s. c om*/ GL20.glUniform1i(GL20.glGetUniformLocation(pId, "tex"), 0); GL20.glUniform2f(screenSizeLocation, Display.getWidth(), Display.getHeight()); GL20.glUseProgram(0); }
From source file:cuchaz.jfxgl.prism.JFXGLContext.java
License:Open Source License
@Override public void uniform1i(int location, int v0) { GL20.glUniform1i(location, v0); }
From source file:de.ikosa.mars.viewer.glviewer.engine.GLShader.java
License:Open Source License
public GLShader(int programId, int vertexShaderId, int fragmentShaderId) { this.programId = programId; this.vertexShaderId = vertexShaderId; this.fragmentShaderId = fragmentShaderId; use();//from w w w .j a va 2 s .c om // save uniform positions ul_col_Ambient = GL20.glGetUniformLocation(programId, "col_Ambient"); ul_col_Diffuse = GL20.glGetUniformLocation(programId, "col_Diffuse"); ul_col_Specular = GL20.glGetUniformLocation(programId, "col_Specular"); ul_val_SpecularCoefficient = GL20.glGetUniformLocation(programId, "val_SpecularCoefficient"); ul_mat_Projection = GL20.glGetUniformLocation(programId, "mat_Projection"); ul_mat_View = GL20.glGetUniformLocation(programId, "mat_View"); ul_mat_Model = GL20.glGetUniformLocation(programId, "mat_Model"); ul_mat_Normal = GL20.glGetUniformLocation(programId, "mat_Normal"); ul_PixelSizeH = GL20.glGetUniformLocation(programId, "pixelSizeH"); ul_PixelSizeV = GL20.glGetUniformLocation(programId, "pixelSizeV"); ul_val_drawModifier = GL20.glGetUniformLocation(programId, "val_drawModifier"); int texSlot = 0; int ul_tex_Diffuse = GL20.glGetUniformLocation(programId, "tex_Diffuse"); if (ul_tex_Diffuse >= 0) { tiu_Diffuse = texSlot++; GL20.glUniform1i(ul_tex_Diffuse, tiu_Diffuse); } else { tiu_Diffuse = -1; } int ul_tex_Color0 = GL20.glGetUniformLocation(programId, "tex_Color0"); if (ul_tex_Color0 >= 0) { tiu_Color0 = texSlot++; GL20.glUniform1i(ul_tex_Color0, tiu_Color0); } else { tiu_Color0 = -1; } int ul_tex_Depth = GL20.glGetUniformLocation(programId, "tex_Depth"); if (ul_tex_Depth >= 0) { tiu_Depth = texSlot++; GL20.glUniform1i(ul_tex_Depth, tiu_Depth); } else { tiu_Depth = -1; } int error = GL11.glGetError(); }
From source file:eu.over9000.veya.rendering.Scene.java
License:Open Source License
public void init() { GL20.glUniform1i(Veya.program_normal.getUniformLocation("textureData"), 0); GL20.glUniform1i(Veya.program_normal.getUniformLocation("shadowMap"), 1); this.light.init(); this.shadow.init(); this.updateModelMatrix(); }
From source file:eu.over9000.veya.Veya.java
License:Open Source License
private static void run() { Util.checkGLError();/* ww w . j av a2 s . c om*/ Veya.program_normal.use(true); Veya.camera.updateProjectionMatrix(Display.getWidth(), Display.getHeight()); Veya.camera.updateViewMatrix(); Veya.scene.init(); Veya.program_normal.use(false); program_normal.use(true); GL20.glUniform1i(Veya.program_normal.getUniformLocation("colorSwitch"), Veya.colorSwitch ? 1 : 0); program_normal.use(false); program_normal.use(true); GL20.glUniform1i(Veya.program_normal.getUniformLocation("aoSwitch"), Veya.aoSwitch ? 1 : 0); program_normal.use(false); Util.checkGLError(); long start = Sys.getTime(); long lastTime = start; long count = 0; while (!Display.isCloseRequested() && !shutdown) { final long time = Sys.getTime(); final float dt = (time - lastTime) / 1000.0f; lastTime = time; checkResize(); handleMovementKeys(dt); handleOtherKeys(); handleMouseInput(); if (gravitySwitch) { Veya.camera.applyGravity(dt); } Veya.camera.performMove(); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); Veya.program_normal.use(true); if (ENABLE_DAY_NIGHT) { final float posX = (float) Math.sin(System.currentTimeMillis() / 10000.0) * 512; final float posY = (float) Math.cos(System.currentTimeMillis() / 10000.0) * 512; // final float posZ = (float) Math.cos(System.currentTimeMillis() / 1500.0) * 20f; ambient = 0.25f + MathUtil.scale(posY, -1024, 1024, 0, 0.55f); diffuse = MathUtil.scale(posY, -1024, 1024, 0, 0.5f); specular = MathUtil.scale(posY, -1024, 1024, 0, 0.5f); final float kek = (posY / 1024f + 1) / 2; GL11.glClearColor(kek * 124f / 255f, kek * 169f / 255f, kek * 255f / 255f, 1.0f); Veya.scene.getLight().updateLightPosition(posX + Veya.camera.getPosition().getX(), posY, 1 + Veya.camera.getPosition().getZ()); } //Veya.scene.getLight().updateLightPosition(Veya.camera.getPosition().getX() + 1, 500, Veya.camera.getPosition().getZ() + 250); Veya.camera.updateViewMatrix(); Veya.camera.updateCameraPosition(); Veya.scene.getLight().updateLightFactors(Veya.ambient, Veya.diffuse, Veya.specular); Veya.scene.render(); Util.checkGLError(); Veya.program_normal.use(false); Display.update(); // Display.sync(60); Util.checkGLError(); final long end = Sys.getTime(); if (end - start > 1000) { start = end; frame.setTitle("VEYA | fps: " + count + " | pos: x=" + Veya.camera.getPosition().x + ", y=" + Veya.camera.getPosition().y + ", z=" + Veya.camera.getPosition().z + " | #chunks displayed: " + Veya.scene.getChunkCount() + " | lightFactors: A=" + Veya.ambient + ", D=" + Veya.diffuse + ", S=" + Veya.specular + " | chunk updates: " + scene.chunkUpdateCounterInRender.get() + "/" + scene.chunkUpdateCounterOffRender.get() + " | selected block: " + scene.placeBlockType); count = 0; scene.chunkUpdateCounterInRender.set(0); scene.chunkUpdateCounterOffRender.set(0); } else { count++; } } }
From source file:eu.over9000.veya.Veya.java
License:Open Source License
private static void handleOtherKeys() { while (Keyboard.next()) { if (Keyboard.getEventKey() == Keyboard.KEY_C && Keyboard.getEventKeyState()) { Veya.colorSwitch = !Veya.colorSwitch; program_normal.use(true);/*w w w . j a va2s.c om*/ GL20.glUniform1i(Veya.program_normal.getUniformLocation("colorSwitch"), Veya.colorSwitch ? 1 : 0); program_normal.use(false); } if (Keyboard.getEventKey() == Keyboard.KEY_Y && Keyboard.getEventKeyState()) { Veya.aoSwitch = !Veya.aoSwitch; program_normal.use(true); GL20.glUniform1i(Veya.program_normal.getUniformLocation("aoSwitch"), Veya.aoSwitch ? 1 : 0); program_normal.use(false); } if (Keyboard.getEventKey() == Keyboard.KEY_V && Keyboard.getEventKeyState()) { Veya.wireframeSwitch = !Veya.wireframeSwitch; } if (Keyboard.getEventKey() == Keyboard.KEY_Q && Keyboard.getEventKeyState()) { Veya.debugShadow = !Veya.debugShadow; } if (Keyboard.getEventKey() == Keyboard.KEY_SPACE && Keyboard.getEventKeyState()) { final long diff = Keyboard.getEventNanoseconds() - lastSpacePress; if (diff < 250 * 1000000) { Veya.gravitySwitch = !Veya.gravitySwitch; camera.resetVelocity(); } lastSpacePress = Keyboard.getEventNanoseconds(); } if (Keyboard.getEventKey() == Keyboard.KEY_X) { Mouse.setGrabbed(!Keyboard.getEventKeyState()); } if (Keyboard.getEventKey() == Keyboard.KEY_PRIOR && Keyboard.getEventKeyState()) { if (Veya.specular + Veya.df <= 1.0f) { Veya.specular += Veya.df; } else { Veya.specular = 1.0f; } } if (Keyboard.getEventKey() == Keyboard.KEY_NEXT && Keyboard.getEventKeyState()) { if (Veya.specular - Veya.df >= 0.0f) { Veya.specular -= Veya.df; } else { Veya.specular = 0.0f; } } if (Keyboard.getEventKey() == Keyboard.KEY_HOME && Keyboard.getEventKeyState()) { if (Veya.diffuse + Veya.df <= 1.0f) { Veya.diffuse += Veya.df; } else { Veya.diffuse = 1.0f; } } if (Keyboard.getEventKey() == Keyboard.KEY_END && Keyboard.getEventKeyState()) { if (Veya.diffuse - Veya.df >= 0.0f) { Veya.diffuse -= Veya.df; } else { Veya.diffuse = 0.0f; } } if (Keyboard.getEventKey() == Keyboard.KEY_INSERT && Keyboard.getEventKeyState()) { if (Veya.ambient + Veya.df <= 1.0f) { Veya.ambient += Veya.df; } else { Veya.ambient = 1.0f; } } if (Keyboard.getEventKey() == Keyboard.KEY_DELETE && Keyboard.getEventKeyState()) { if (Veya.ambient - Veya.df >= 0.0f) { Veya.ambient -= Veya.df; } else { Veya.ambient = 0.0f; } } if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState()) { shutdown = true; } } }
From source file:fr.guillaume.prive.viper.core.graphic.GraphicMotor.java
public static void draw() { GraphicMotor.checkInstance();/* w w w. j av a 2 s.com*/ GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL20.glUseProgram(instance.shipShaderId); GL20.glUniform1i(instance.useTextureLocation, instance.drawPolygonFrame ? 0 : 1); int drawStyle = instance.drawPolygonFrame ? GL11.GL_LINE_LOOP : GL11.GL_TRIANGLES; GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, instance.shipTextureId); GL30.glBindVertexArray(instance.shipVaoId); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); GL20.glEnableVertexAttribArray(3); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, instance.shipVboiId); GL11.glDrawElements(drawStyle, instance.shipVboiLenght, GL11.GL_UNSIGNED_INT, 0); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); GL20.glDisableVertexAttribArray(3); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); GL20.glUseProgram(0); }
From source file:fr.ign.cogit.geoxygene.util.gl.GLProgram.java
License:Open Source License
/** * @param uniformLocation/*from w w w.j av a 2 s . c om*/ * @param value */ private void setUniform1i(int uniformLocation, int value) { GLTools.glCheckError("GLERROR : before GL20.glUniform1i"); GL20.glUniform1i(uniformLocation, value); GLTools.glCheckError("GLERROR : after GL20.glUniform1i"); }
From source file:io.root.gfx.glutils.GL.java
License:Apache License
public static void glUniform1i(int location, int x) { GL20.glUniform1i(location, x); }