List of usage examples for org.lwjgl.opengl GL13 glActiveTexture
public static void glActiveTexture(@NativeType("GLenum") int texture)
From source file:org.terasology.rendering.dag.nodes.BloomPassesNode.java
License:Apache License
private void generateHighPass() { highPass.enable();/*from w w w .ja va 2s . c om*/ 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>//from w ww .ja va2 s .c om * 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();//from w w w .ja va 2s . c o m 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();// w w w. j ava2s.co 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 ww w. j a va2 s. co m // Set the shader parameters if available if (shaderParameters != null) { shaderParameters.applyParameters(this); } } }
From source file:org.terasology.rendering.opengl.LwjglRenderingProcess.java
License:Apache License
public void applyLightBufferPass(String target) { Material program = Assets.getMaterial("engine:prog.lightBufferPass"); program.enable();/*ww w . j a v a 2 s .co m*/ 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); } FBO targetPingPong = getFBO(target + "PingPong"); targetPingPong.bind(); graphicState.setRenderBufferMask(targetPingPong, 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.LwjglRenderingProcess.java
License:Apache License
private void generateHighPass() { Material program = Assets.getMaterial("engine:prog.highp"); program.setFloat("highPassThreshold", bloomHighPassThreshold, true); program.enable();// w ww . ja v a 2s . co 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++); setViewportTo(highPass.dimensions()); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderFullscreenQuad(); highPass.unbind(); setViewportToFullSize(); }
From source file:org.terasology.rendering.opengl.PostProcessor.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 * * See http://en.wikipedia.org/wiki/Deferred_shading as a starting point. *//*from ww w .j a v a2 s . c om*/ public void applyLightBufferPass() { int texId = 0; GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); buffers.sceneOpaque.bindTexture(); materials.lightBufferPass.setInt("texSceneOpaque", texId++); GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); buffers.sceneOpaque.bindDepthTexture(); materials.lightBufferPass.setInt("texSceneOpaqueDepth", texId++); GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); buffers.sceneOpaque.bindNormalsTexture(); materials.lightBufferPass.setInt("texSceneOpaqueNormals", texId++); GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); buffers.sceneOpaque.bindLightBufferTexture(); materials.lightBufferPass.setInt("texSceneOpaqueLightBuffer", texId, true); buffers.sceneOpaquePingPong.bind(); graphicState.setRenderBufferMask(buffers.sceneOpaquePingPong, true, true, true); setViewportTo(buffers.sceneOpaquePingPong.dimensions()); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // TODO: verify this is necessary renderFullscreenQuad(); graphicState.bindDisplay(); // TODO: verify this is necessary setViewportToWholeDisplay(); // TODO: verify this is necessary renderingProcess.swapSceneOpaqueFBOs(); buffers.sceneOpaque.attachDepthBufferTo(buffers.sceneReflectiveRefractive); }
From source file:org.terasology.rendering.opengl.PostProcessor.java
License:Apache License
private void generateHighPass() { materials.highPass.enable();//w ww . ja v a 2 s .c om materials.highPass.setFloat("highPassThreshold", bloomHighPassThreshold, true); int texId = 0; GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); buffers.sceneOpaque.bindTexture(); materials.highPass.setInt("tex", texId); // GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); // buffers.sceneOpaque.bindDepthTexture(); // program.setInt("texDepth", texId++); buffers.sceneHighPass.bind(); setViewportTo(buffers.sceneHighPass.dimensions()); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderFullscreenQuad(); graphicState.bindDisplay(); setViewportToWholeDisplay(); }
From source file:org.terasology.rendering.opengl.PostProcessor.java
License:Apache License
private void applyOculusDistortion(FBO inputBuffer) { materials.ocDistortion.enable();//from w w w. j a v a 2 s . c o m int texId = 0; GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); inputBuffer.bindTexture(); materials.ocDistortion.setInt("texInputBuffer", texId, true); if (renderingProcess.isNotTakingScreenshot()) { updateOcShaderParametersForVP(0, 0, fullScale.width() / 2, fullScale.height(), WorldRenderer.WorldRenderingStage.LEFT_EYE); renderFullscreenQuad(0, 0, Display.getWidth(), Display.getHeight()); updateOcShaderParametersForVP(fullScale.width() / 2 + 1, 0, fullScale.width() / 2, fullScale.height(), WorldRenderer.WorldRenderingStage.RIGHT_EYE); renderFullscreenQuad(0, 0, Display.getWidth(), Display.getHeight()); } else { // what follows -should- work also when there is no screenshot being taken, but somehow it doesn't, hence the block above updateOcShaderParametersForVP(0, 0, fullScale.width() / 2, fullScale.height(), WorldRenderer.WorldRenderingStage.LEFT_EYE); renderFullscreenQuad(0, 0, fullScale.width(), fullScale.height()); updateOcShaderParametersForVP(fullScale.width() / 2 + 1, 0, fullScale.width() / 2, fullScale.height(), WorldRenderer.WorldRenderingStage.RIGHT_EYE); renderFullscreenQuad(0, 0, fullScale.width(), fullScale.height()); } }