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.github.begla.blockmania.world.main.World.java
License:Apache License
/** * Renders all chunks that are currently in the player's field of view. *///from www . java2s. co m private void renderChunksAndEntities() { ShaderManager.getInstance().enableShader("chunk"); GL13.glActiveTexture(GL13.GL_TEXTURE1); TextureManager.getInstance().bindTexture("custom_lava_still"); GL13.glActiveTexture(GL13.GL_TEXTURE2); TextureManager.getInstance().bindTexture("custom_water_still"); GL13.glActiveTexture(GL13.GL_TEXTURE0); TextureManager.getInstance().bindTexture("terrain"); int daylight = GL20.glGetUniformLocation(ShaderManager.getInstance().getShader("chunk"), "daylight"); int swimming = GL20.glGetUniformLocation(ShaderManager.getInstance().getShader("chunk"), "swimming"); int lavaTexture = GL20.glGetUniformLocation(ShaderManager.getInstance().getShader("chunk"), "textureLava"); int waterTexture = GL20.glGetUniformLocation(ShaderManager.getInstance().getShader("chunk"), "textureWater"); int textureAtlas = GL20.glGetUniformLocation(ShaderManager.getInstance().getShader("chunk"), "textureAtlas"); GL20.glUniform1i(lavaTexture, 1); GL20.glUniform1i(waterTexture, 2); GL20.glUniform1i(textureAtlas, 0); int tick = GL20.glGetUniformLocation(ShaderManager.getInstance().getShader("chunk"), "tick"); GL20.glUniform1f(tick, _tick); GL20.glUniform1f(daylight, getDaylight()); GL20.glUniform1i(swimming, _player.isHeadUnderWater() ? 1 : 0); // OPAQUE ELEMENTS for (int i = 0; i < _visibleChunks.size(); i++) { Chunk c = _visibleChunks.get(i); c.render(ChunkMesh.RENDER_TYPE.OPAQUE); c.render(ChunkMesh.RENDER_TYPE.LAVA); if ((Boolean) ConfigurationManager.getInstance().getConfig().get("System.Debug.chunkOutlines")) { c.getAABB().render(); } } for (int i = 0; i < _visibleChunks.size(); i++) { Chunk c = _visibleChunks.get(i); c.render(ChunkMesh.RENDER_TYPE.BILLBOARD_AND_TRANSLUCENT); } for (int j = 0; j < 2; j++) { // ANIMATED WATER for (int i = 0; i < _visibleChunks.size(); i++) { Chunk c = _visibleChunks.get(i); if (j == 0) { glColorMask(false, false, false, false); } else { glColorMask(true, true, true, true); } c.render(ChunkMesh.RENDER_TYPE.WATER); } } _mobManager.renderAll(); ShaderManager.getInstance().enableShader("block"); _bulletPhysicsRenderer.render(); ShaderManager.getInstance().enableShader(null); }
From source file:com.github.begla.blockmania.world.physics.BulletPhysicsRenderer.java
License:Apache License
public void render() { for (BlockRigidBody b : _blocks) { Transform t = new Transform(); b.getMotionState().getWorldTransform(t); GL11.glPushMatrix();//from w w w. ja v a 2 s .co m FloatBuffer mBuffer = BufferUtils.createFloatBuffer(16); float[] mFloat = new float[16]; t.getOpenGLMatrix(mFloat); mBuffer.put(mFloat); mBuffer.flip(); GL11.glTranslatef(-_parent.getPlayer().getPosition().x, -_parent.getPlayer().getPosition().y, -_parent.getPlayer().getPosition().z); GL11.glMultMatrix(mBuffer); float lightValue = calcLightValueForTransform(t); int lightRef = GL20.glGetUniformLocation(ShaderManager.getInstance().getShader("block"), "light"); GL20.glUniform1f(lightRef, lightValue); BlockManager.getInstance().getBlock(b.getType()).render(); GL11.glPopMatrix(); } }
From source file:com.github.begla.blockmania.world.World.java
License:Apache License
/** * Renders the chunks.//from w w w.j a va 2 s .co m */ private void renderChunks() { ShaderManager.getInstance().enableShader("chunk"); int daylight = GL20.glGetUniformLocation(ShaderManager.getInstance().getShader("chunk"), "daylight"); int swimming = GL20.glGetUniformLocation(ShaderManager.getInstance().getShader("chunk"), "swimming"); int animationOffset = GL20.glGetUniformLocation(ShaderManager.getInstance().getShader("chunk"), "animationOffset"); int animated = GL20.glGetUniformLocation(ShaderManager.getInstance().getShader("chunk"), "animated"); GL20.glUniform1f(daylight, (float) getDaylight()); GL20.glUniform1i(swimming, _player.isHeadUnderWater() ? 1 : 0); FastList<Chunk> visibleChunks = fetchVisibleChunks(); glEnable(GL_TEXTURE_2D); GL20.glUniform1i(animated, 0); TextureManager.getInstance().bindTexture("terrain"); // OPAQUE ELEMENTS for (FastList.Node<Chunk> n = visibleChunks.head(), end = visibleChunks.tail(); (n = n.getNext()) != end;) { Chunk c = n.getValue(); c.render(ChunkMesh.RENDER_TYPE.OPAQUE); if (Configuration.getSettingBoolean("CHUNK_OUTLINES")) { c.getAABB().render(); } } // ANIMATED LAVA GL20.glUniform1i(animated, 1); TextureManager.getInstance().bindTexture("custom_lava_still"); GL20.glUniform1f(animationOffset, ((float) (_tick % 16)) * (1.0f / 16f)); for (FastList.Node<Chunk> n = visibleChunks.head(), end = visibleChunks.tail(); (n = n.getNext()) != end;) { Chunk c = n.getValue(); c.render(ChunkMesh.RENDER_TYPE.LAVA); } GL20.glUniform1i(animated, 0); TextureManager.getInstance().bindTexture("terrain"); // BILLBOARDS AND TRANSLUCENT ELEMENTS for (FastList.Node<Chunk> n = visibleChunks.head(), end = visibleChunks.tail(); (n = n.getNext()) != end;) { Chunk c = n.getValue(); c.render(ChunkMesh.RENDER_TYPE.BILLBOARD_AND_TRANSLUCENT); } GL20.glUniform1i(animated, 1); GL20.glUniform1f(animationOffset, ((float) (_tick / 2 % 12)) * (1.0f / 16f)); TextureManager.getInstance().bindTexture("custom_water_still"); for (int i = 0; i < 2; i++) { // ANIMATED WATER for (FastList.Node<Chunk> n = visibleChunks.head(), end = visibleChunks .tail(); (n = n.getNext()) != end;) { Chunk c = n.getValue(); if (i == 0) { glColorMask(false, false, false, false); } else { glColorMask(true, true, true, true); } c.render(ChunkMesh.RENDER_TYPE.WATER); } } ShaderManager.getInstance().enableShader(null); glDisable(GL_TEXTURE_2D); }
From source file:com.github.kajdreef.mazerunnermvn.MazeRunner.ShaderProgram.java
public void newShaderProgram(String vertexShaderLocation, String fragmentShaderLocation) { // Initialize the vertex Shader vertexId = compileShader(GL20.GL_VERTEX_SHADER, vertexShaderLocation); // Initialize the fragment shader fragmentId = compileShader(GL20.GL_FRAGMENT_SHADER, fragmentShaderLocation); programId = GL20.glCreateProgram();/*from w w w. j ava 2s.c om*/ GL20.glAttachShader(programId, vertexId); GL20.glAttachShader(programId, fragmentId); // Position information will be attribute 0 GL20.glBindAttribLocation(programId, 0, "in_Position"); // Color information will be attribute 1 GL20.glBindAttribLocation(programId, 1, "in_Color"); // Texture information will be attribute 2 GL20.glBindAttribLocation(programId, 2, "in_TextureCoord"); GL20.glLinkProgram(programId); GL20.glValidateProgram(programId); // Get matrices uniform locations projectionMatrixLocation = GL20.glGetUniformLocation(programId, "projectionMatrix"); viewMatrixLocation = GL20.glGetUniformLocation(programId, "viewMatrix"); modelMatrixLocation = GL20.glGetUniformLocation(programId, "modelMatrix"); }
From source file:com.google.gapid.glviewer.gl.Shader.java
License:Apache License
private static Uniform[] getActiveUniforms(int program) { int maxUniformNameLength = GL20.glGetProgrami(program, GL20.GL_ACTIVE_UNIFORM_MAX_LENGTH); int numUniforms = GL20.glGetProgrami(program, GL20.GL_ACTIVE_UNIFORMS); IntBuffer size = createIntBuffer(1), type = createIntBuffer(1); Uniform[] result = new Uniform[numUniforms]; for (int i = 0; i < numUniforms; i++) { String name = GL20.glGetActiveUniform(program, i, maxUniformNameLength, size, type); if (name.endsWith("[0]")) { name = name.substring(0, name.length() - 3); }/*from w ww . ja va2s . c om*/ result[i] = new Uniform(GL20.glGetUniformLocation(program, name), name, type.get(0)); } return result; }
From source file:com.google.gapid.glviewer.gl.Util.java
License:Apache License
public static AttributeOrUniform[] getActiveUniforms(int program) { int maxUniformNameLength = getProgramiv(program, GL20.GL_ACTIVE_UNIFORM_MAX_LENGTH); int numUniforms = getProgramiv(program, GL20.GL_ACTIVE_UNIFORMS); IntBuffer size = createIntBuffer(1), type = createIntBuffer(1); AttributeOrUniform[] result = new AttributeOrUniform[numUniforms]; for (int i = 0; i < numUniforms; i++) { String name = GL20.glGetActiveUniform(program, i, maxUniformNameLength, size, type); if (name.endsWith("[0]")) { name = name.substring(0, name.length() - 3); }/* w w w. ja v a 2 s.c o m*/ result[i] = new AttributeOrUniform(GL20.glGetUniformLocation(program, name), name, type.get(0), size.get(0)); } return result; }
From source file:com.grillecube.client.opengl.GLProgram.java
public int getUniform(String name) { return (GL20.glGetUniformLocation(this.progID, name)); }
From source file:com.grillecube.engine.opengl.object.GLProgram.java
public int getUniform(String name) { return (GL20.glGetUniformLocation(this._programID, name)); }
From source file:com.kauridev.lunarfever.graphics.ShaderProgram.java
License:Open Source License
private int getUniformLocation(String name) { return GL20.glGetUniformLocation(program, name); }
From source file:com.opengrave.common.world.MaterialList.java
License:Open Source License
public synchronized void bind(int pID, int glTexture) { updateTex();/*w w w .j a v a 2 s.com*/ int texMain = GL20.glGetUniformLocation(pID, "arraytexture"); int texData = GL20.glGetUniformLocation(pID, "arraytexturedata"); GL20.glUniform1i(texMain, glTexture - GL13.GL_TEXTURE0); GL20.glUniform1i(texData, (glTexture - GL13.GL_TEXTURE0) + 1); if (!valid()) { return; } textureAtlas.bind(glTexture); textureDataAtlas.bind(glTexture + 1); }