List of usage examples for org.lwjgl.opengl GL13 glActiveTexture
public static void glActiveTexture(@NativeType("GLenum") int texture)
From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL10.java
License:Apache License
public final void glActiveTexture(int texture) { GL13.glActiveTexture(texture); }
From source file:com.bossletsplays.duthorix.rendering.Texture.java
License:Apache License
public void bind(int samplerSlot) { try {/* w w w .ja v a 2 s . co m*/ assert (samplerSlot >= 0 && samplerSlot <= 31); GL13.glActiveTexture(GL13.GL_TEXTURE0 + samplerSlot); glBindTexture(GL_TEXTURE_2D, manager.getID()); } catch (Exception e) { System.err.println("Could not bind texture: " + file); System.exit(1); } }
From source file:com.flowpowered.caustic.lwjgl.gl20.GL20Texture.java
License:MIT License
@Override public void bind(int unit) { checkCreated();/* w ww .ja v a2 s . c o m*/ if (unit != -1) { // Activate the texture unit GL13.glActiveTexture(GL13.GL_TEXTURE0 + unit); } // Bind the texture GL11.glBindTexture(GL11.GL_TEXTURE_2D, id); // Check for errors LWJGLUtil.checkForGLError(); }
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 ww w.ja v a2 s .c om 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.kajdreef.mazerunnermvn.Object.GameObject.java
/** * Render the Object.//from w ww . j a v a 2 s . c o m */ public void render() { FloatBuffer matrix44Buffer = BufferUtils.createFloatBuffer(16); modelMatrix.store(matrix44Buffer); matrix44Buffer.flip(); GL20.glUniformMatrix4(ShaderProgram.getMML(), false, matrix44Buffer); // Bind the texture GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId); // Bind to the VAO that has all the information about the quad vertices GL30.glBindVertexArray(vaoId); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); // Bind to the index VBO that has all the information about the order of the vertices GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboIndicesId); // Draw the vertices GL11.glDrawElements(GL11.GL_TRIANGLES, indicesData.length, GL11.GL_UNSIGNED_BYTE, 0); // Put everything back to default (deselect) GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); GL20.glDisableVertexAttribArray(2); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(0); GL30.glBindVertexArray(0); }
From source file:com.github.kajdreef.mazerunnermvn.Object.GameObject.java
protected void setTextureUnit(Texture texture, int textureUnit) { // Create a new texture object in memory and bind it texId = GL11.glGenTextures();//ww w.jav a2 s . c om GL13.glActiveTexture(textureUnit); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId); // All RGB bytes are aligned to each other and each component is 1 byte GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); // Upload the texture data and generate mip maps (for scaling) GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, texture.getWidth(), texture.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, texture.getTexBuffer()); GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); // Setup the ST coordinate system GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); // Setup what to do when the texture has to be scaled GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR); }
From source file:com.google.gapid.glviewer.gl.Texture.java
License:Apache License
static void activate(int unit) { GL13.glActiveTexture(GL13.GL_TEXTURE0 + unit); }
From source file:com.grillecube.client.opengl.GLTexture.java
public final void bind(int texture, int target) { GL13.glActiveTexture(texture); GL11.glBindTexture(target, this.glID); }
From source file:com.grillecube.client.renderer.particles.ParticleRenderer.java
/** * render every given billoaded particles with the given camera (billboarded * = textured quad facing the camera)/* www .j a v a2s . co m*/ */ public final void renderBillboardedParticles(CameraProjective camera, ArrayList<ParticleBillboarded> particles) { if (particles.size() == 0) { return; } GL13.glActiveTexture(GL13.GL_TEXTURE0 + 0); // Texture unit 0 GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); this.programBillboardedParticles.useStart(); this.getMainRenderer().getDefaultVAO().bind(); this.programBillboardedParticles.loadGlobalUniforms(camera); HashMap<ParticleBillboarded, Double> distances = new HashMap<ParticleBillboarded, Double>( particles.size() * 4); for (ParticleBillboarded particle : particles) { distances.put(particle, Vector3f.distanceSquare(particle.getPosition(), camera.getPosition())); } particles.sort(new Comparator<ParticleBillboarded>() { @Override public int compare(ParticleBillboarded a, ParticleBillboarded b) { double da = distances.get(a); double db = distances.get(b); if (da < db) { return (1); } else if (da > db) { return (-1); } return (0); } }); int i = 0; while (i < particles.size()) { ParticleBillboarded particle = particles.get(i); float radius = Maths.max(Maths.max(particle.getSizeX(), particle.getSizeY()), particle.getSizeZ()); if (particle != null && distances.get(particle) < camera.getSquaredRenderDistance() && camera.isSphereInFrustum(particle.getPosition(), radius)) { this.programBillboardedParticles.loadInstanceUniforms(particle); this.getMainRenderer().getDefaultVAO().draw(GL11.GL_POINTS, 0, 1); } ++i; } }
From source file:com.grillecube.engine.opengl.object.GLTexture.java
public void bind(int texture, int target) { GL13.glActiveTexture(texture); GL11.glBindTexture(target, this._glID); }