List of usage examples for org.lwjgl.opengl GL13 GL_TEXTURE0
int GL_TEXTURE0
To view the source code for org.lwjgl.opengl GL13 GL_TEXTURE0.
Click Source Link
From source file:org.terasology.logic.manager.ShaderManager.java
License:Apache License
public void bindTexture(int slot, Texture texture) { if (activateMaterial != null && !activateMaterial.isDisposed()) { GL13.glActiveTexture(GL13.GL_TEXTURE0 + slot); // TODO: Need to be cubemap aware, only need to clear bind when switching from cubemap to 2D and vice versa, // TODO: Don't bind if already bound to the same GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getId()); GL13.glActiveTexture(GL13.GL_TEXTURE0); }/* w w w . jav a2 s .c om*/ }
From source file:org.terasology.logic.particles.BlockParticleEmitterSystem.java
License:Apache License
private void render(Iterable<EntityRef> particleEntities) { Assets.getMaterial("engine:prog.particle").enable(); glDisable(GL11.GL_CULL_FACE);/* w w w . ja v a 2 s . co m*/ Vector3f cameraPosition = worldRenderer.getActiveCamera().getPosition(); for (EntityRef entity : particleEntities) { LocationComponent location = entity.getComponent(LocationComponent.class); if (null == location) { continue; } Vector3f worldPos = location.getWorldPosition(); if (!worldProvider.isBlockRelevant(worldPos)) { continue; } BlockParticleEffectComponent particleEffect = entity.getComponent(BlockParticleEffectComponent.class); if (particleEffect.texture == null) { Texture terrainTex = Assets.getTexture("engine:terrain"); if (terrainTex == null) { return; } GL13.glActiveTexture(GL13.GL_TEXTURE0); glBindTexture(GL11.GL_TEXTURE_2D, terrainTex.getId()); } else { GL13.glActiveTexture(GL13.GL_TEXTURE0); glBindTexture(GL11.GL_TEXTURE_2D, particleEffect.texture.getId()); } if (particleEffect.blendMode == BlockParticleEffectComponent.ParticleBlendMode.ADD) { glBlendFunc(GL_ONE, GL_ONE); } if (particleEffect.blockType != null) { renderBlockParticles(worldPos, cameraPosition, particleEffect); } else { renderParticles(worldPos, cameraPosition, particleEffect); } if (particleEffect.blendMode == BlockParticleEffectComponent.ParticleBlendMode.ADD) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } } glEnable(GL11.GL_CULL_FACE); }
From source file:org.terasology.particles.rendering.SpriteParticleRenderer.java
License:Apache License
public void drawParticles(Material material, ParticleRenderingData<ParticleDataSpriteComponent> particleSystem, Vector3f camera) {/* w ww . j av a2 s . co m*/ ParticlePool particlePool = particleSystem.particlePool; material.setBoolean("useTexture", particleSystem.particleData.texture != null); if (particleSystem.particleData.texture != null) { GL13.glActiveTexture(GL13.GL_TEXTURE0); glBindTexture(GL11.GL_TEXTURE_2D, particleSystem.particleData.texture.getId()); material.setFloat2("texSize", particleSystem.particleData.textureSize.getX(), particleSystem.particleData.textureSize.getY()); } glPushMatrix(); glTranslatef(-camera.x(), -camera.y(), -camera.z()); for (int i = 0; i < particlePool.livingParticles(); i++) { final int i2 = i * 2; final int i3 = i * 3; final int i4 = i * 4; material.setFloat3("position", particlePool.position[i3], particlePool.position[i3 + 1], particlePool.position[i3 + 2]); material.setFloat3("scale", particlePool.scale[i3], particlePool.scale[i3 + 1], particlePool.scale[i3 + 2]); material.setFloat4("color", particlePool.color[i4], particlePool.color[i4 + 1], particlePool.color[i4 + 2], particlePool.color[i4 + 3]); material.setFloat2("texOffset", particlePool.textureOffset[i2], particlePool.textureOffset[i2 + 1]); drawUnitQuad.call(); } glPopMatrix(); }
From source file:org.terasology.rendering.assets.GLSLShaderProgramInstance.java
License:Apache License
/** * Makes sure this shader program is the current shader program in the * OpenGL state./*w w w. j a v a2s . c o m*/ * It checks if this shader program is the active shader program in the OpenGL * state, if not it sets this shader program to be the current shader program. */ public void enable() { GLSLShaderProgramInstance activeProgram = ShaderManager.getInstance().getActiveShaderProgram(); if (activeProgram != this || activeFeaturesChanged) { GL13.glActiveTexture(GL13.GL_TEXTURE0); GL20.glUseProgram(getActiveShaderProgramId()); // Make sure the shader manager knows that this program is currently active ShaderManager.getInstance().setActiveShaderProgram(this); activeFeaturesChanged = false; // Set the shader parameters if available if (shaderParameters != null) { shaderParameters.applyParameters(this); } prevValues.clear(); } }
From source file:org.terasology.rendering.assets.skeletalmesh.SkeletalMesh.java
License:Apache License
public void preRender() { glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboUVBuffer); GL13.glClientActiveTexture(GL13.GL_TEXTURE0); glTexCoordPointer(2, GL11.GL_FLOAT, TEX_COORD_SIZE * 4, 0); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboIndexBuffer); }
From source file:org.terasology.rendering.dag.nodes.BloomPassesNode.java
License:Apache License
private void generateHighPass() { highPass.enable();/*from ww w . j a v a 2 s . co m*/ highPass.setFloat("highPassThreshold", bloomHighPassThreshold, true); int texId = 0; GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); READ_ONLY_GBUFFER.bindTexture(); highPass.setInt("tex", texId); // TODO: Investigate why this is here // GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); // buffers.READ_ONLY_GBUFFER.bindDepthTexture(); // program.setInt("texDepth", texId++); sceneHighPass.bind(); setViewportToSizeOf(sceneHighPass); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // TODO: verify this is necessary renderFullscreenQuad(); bindDisplay(); // TODO: verify this is necessary setViewportToSizeOf(READ_ONLY_GBUFFER); // TODO: verify this is necessary }
From source file:org.terasology.rendering.dag.nodes.DirectionalLightsNode.java
License:Apache License
/** * Part of the deferred lighting technique, this method applies lighting through screen-space * calculations to the previously flat-lit world rendering stored in the primary FBO. // TODO: rename sceneOpaque* FBOs to primaryA/B * <p>// w w w . ja va 2 s . c o m * See http://en.wikipedia.org/wiki/Deferred_shading as a starting point. */ private void applyLightBufferPass() { int texId = 0; GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); READ_ONLY_GBUFFER.bindTexture(); lightBufferPass.setInt("texSceneOpaque", texId++, true); GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); READ_ONLY_GBUFFER.bindDepthTexture(); lightBufferPass.setInt("texSceneOpaqueDepth", texId++, true); GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); READ_ONLY_GBUFFER.bindNormalsTexture(); lightBufferPass.setInt("texSceneOpaqueNormals", texId++, true); GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); READ_ONLY_GBUFFER.bindLightBufferTexture(); lightBufferPass.setInt("texSceneOpaqueLightBuffer", texId, true); sceneReflectiveRefractive = displayResolutionDependentFBOs.get(REFRACTIVE_REFLECTIVE); WRITE_ONLY_GBUFFER.bind(); WRITE_ONLY_GBUFFER.setRenderBufferMask(true, true, true); setViewportToSizeOf(WRITE_ONLY_GBUFFER); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // TODO: verify this is necessary renderFullscreenQuad(); bindDisplay(); // TODO: verify this is necessary setViewportToSizeOf(READ_ONLY_GBUFFER); // TODO: verify this is necessary displayResolutionDependentFBOs.swapReadWriteBuffers(); READ_ONLY_GBUFFER.attachDepthBufferTo(sceneReflectiveRefractive); }
From source file:org.terasology.rendering.opengl.DefaultRenderingProcess.java
License:Apache License
private void applyLightBufferPass(String target) { Material program = Assets.getMaterial("engine:prog.lightBufferPass"); program.enable();/* w ww . j a v a2s . c om*/ DefaultRenderingProcess.FBO targetFbo = getFBO(target); int texId = 0; if (targetFbo != null) { GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); targetFbo.bindTexture(); program.setInt("texSceneOpaque", texId++); GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); targetFbo.bindDepthTexture(); program.setInt("texSceneOpaqueDepth", texId++); GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); targetFbo.bindNormalsTexture(); program.setInt("texSceneOpaqueNormals", texId++); GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); targetFbo.bindLightBufferTexture(); program.setInt("texSceneOpaqueLightBuffer", texId++, true); } bindFbo(target + "PingPong"); setRenderBufferMask(true, true, true); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderFullscreenQuad(); unbindFbo(target + "PingPong"); flipPingPongFbo(target); if (target.equals("sceneOpaque")) { attachDepthBufferToFbo("sceneOpaque", "sceneReflectiveRefractive"); } }
From source file:org.terasology.rendering.opengl.DefaultRenderingProcess.java
License:Apache License
private void generateHighPass() { Material program = Assets.getMaterial("engine:prog.highp"); program.setFloat("highPassThreshold", bloomHighPassThreshold, true); program.enable();/*ww w. j a v a 2s . c o m*/ FBO highPass = getFBO("sceneHighPass"); if (highPass == null) { return; } highPass.bind(); FBO sceneOpaque = getFBO("sceneOpaque"); int texId = 0; GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); sceneOpaque.bindTexture(); program.setInt("tex", texId++); // GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); // sceneOpaque.bindDepthTexture(); // program.setInt("texDepth", texId++); glViewport(0, 0, highPass.width, highPass.height); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderFullscreenQuad(); highPass.unbind(); glViewport(0, 0, rtFullWidth, rtFullHeight); }
From source file:org.terasology.rendering.opengl.GLSLMaterial.java
License:Apache License
@Override public void enable() { if (shaderManager.getActiveMaterial() != this || activeFeaturesChanged) { GL13.glActiveTexture(GL13.GL_TEXTURE0); GL20.glUseProgram(getActiveShaderProgramId()); // Make sure the shader manager knows that this program is currently active shaderManager.setActiveMaterial(this); activeFeaturesChanged = false;//from www . java2s . c om // Set the shader parameters if available if (shaderParameters != null) { shaderParameters.applyParameters(this); } } }