Example usage for org.lwjgl.opengl GL13 GL_TEXTURE0

List of usage examples for org.lwjgl.opengl GL13 GL_TEXTURE0

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL13 GL_TEXTURE0.

Prototype

int GL_TEXTURE0

To view the source code for org.lwjgl.opengl GL13 GL_TEXTURE0.

Click Source Link

Document

Accepted by the texture parameter of ActiveTexture and MultiTexCoord.

Usage

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();//  w  w w  .ja  va 2 s .c  om

    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();//from  w ww.  j a  va 2s .  c om

    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.OpenGLMesh.java

License:Apache License

public void preRender() {
    if (!isDisposed()) {
        glEnableClientState(GL_VERTEX_ARRAY);
        if (hasTexCoord0 || hasTexCoord1) {
            glEnableClientState(GL_TEXTURE_COORD_ARRAY);
        }/*www  .  j  av  a 2s.  c  om*/
        if (hasColor) {
            glEnableClientState(GL_COLOR_ARRAY);
        }
        if (hasNormal) {
            glEnableClientState(GL_NORMAL_ARRAY);
        }

        GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboVertexBuffer);
        GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboIndexBuffer);

        glVertexPointer(VERTEX_SIZE, GL11.GL_FLOAT, stride, vertexOffset);

        if (hasTexCoord0) {
            GL13.glClientActiveTexture(GL13.GL_TEXTURE0);
            glTexCoordPointer(TEX_COORD_0_SIZE, GL11.GL_FLOAT, stride, texCoord0Offset);
        }

        if (hasTexCoord1) {
            GL13.glClientActiveTexture(GL13.GL_TEXTURE1);
            glTexCoordPointer(TEX_COORD_1_SIZE, GL11.GL_FLOAT, stride, texCoord1Offset);
        }

        if (hasColor) {
            glColorPointer(COLOR_SIZE, GL11.GL_FLOAT, stride, colorOffset);
        }
        if (hasNormal) {
            glNormalPointer(GL11.GL_FLOAT, stride, normalOffset);
        }
    } else {
        logger.error("Attempted to render disposed mesh: {}", getURI());
    }
}

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 www. ja v  a2s .c  o m*/
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  w  w . j a v  a 2  s. com
    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  va  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());
    }
}

From source file:org.terasology.rendering.primitives.ChunkMesh.java

License:Apache License

private void renderVbo(int id) {
    if (lock.tryLock()) {
        try {//from  w  ww .j  a  v  a2  s .  c  om
            if (vertexBuffers[id] <= 0 || disposed) {
                return;
            }

            glEnableClientState(GL_VERTEX_ARRAY);
            glEnableClientState(GL_TEXTURE_COORD_ARRAY);
            glEnableClientState(GL_COLOR_ARRAY);
            glEnableClientState(GL_NORMAL_ARRAY);

            GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, idxBuffers[id]);
            GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertexBuffers[id]);

            glVertexPointer(SIZE_VERTEX, GL11.GL_FLOAT, STRIDE, OFFSET_VERTEX);

            GL13.glClientActiveTexture(GL13.GL_TEXTURE0);
            glTexCoordPointer(SIZE_TEX0, GL11.GL_FLOAT, STRIDE, OFFSET_TEX_0);

            GL13.glClientActiveTexture(GL13.GL_TEXTURE1);
            glTexCoordPointer(SIZE_TEX1, GL11.GL_FLOAT, STRIDE, OFFSET_TEX_1);

            glColorPointer(SIZE_COLOR * 4, GL11.GL_UNSIGNED_BYTE, STRIDE, OFFSET_COLOR);

            glNormalPointer(GL11.GL_FLOAT, STRIDE, OFFSET_NORMAL);

            GL11.glDrawElements(GL11.GL_TRIANGLES, vertexCount[id], GL11.GL_UNSIGNED_INT, 0);

            GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
            GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);

            glDisableClientState(GL_NORMAL_ARRAY);
            glDisableClientState(GL_COLOR_ARRAY);
            glDisableClientState(GL_TEXTURE_COORD_ARRAY);
            glDisableClientState(GL_VERTEX_ARRAY);

        } finally {
            lock.unlock();
        }
    }
}

From source file:org.terasology.rendering.primitives.Mesh.java

License:Apache License

public void preRender() {
    glEnableClientState(GL_VERTEX_ARRAY);
    if (hasTexCoord0 || hasTexCoord1)
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    if (hasColor)
        glEnableClientState(GL_COLOR_ARRAY);
    if (hasNormal)
        glEnableClientState(GL_NORMAL_ARRAY);

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboVertexBuffer);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboIndexBuffer);

    glVertexPointer(VERTEX_SIZE, GL11.GL_FLOAT, stride, vertexOffset);

    if (hasTexCoord0) {
        GL13.glClientActiveTexture(GL13.GL_TEXTURE0);
        glTexCoordPointer(TEX_COORD_0_SIZE, GL11.GL_FLOAT, stride, texCoord0Offset);
    }//  w ww .j a va2  s .  c o m

    if (hasTexCoord1) {
        GL13.glClientActiveTexture(GL13.GL_TEXTURE1);
        glTexCoordPointer(TEX_COORD_1_SIZE, GL11.GL_FLOAT, stride, texCoord1Offset);
    }

    if (hasColor)
        glColorPointer(COLOR_SIZE, GL11.GL_FLOAT, stride, colorOffset);
    if (hasNormal)
        glNormalPointer(GL11.GL_FLOAT, stride, normalOffset);
}

From source file:org.terasology.rendering.renderingProcesses.DefaultRenderingProcess.java

License:Apache License

private void applyLightBufferPass(String target) {
    GLSLShaderProgramInstance program = ShaderManager.getInstance().getShaderProgramInstance("lightBufferPass");
    program.enable();//w  w  w .j av a 2  s .  co  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++);
    }

    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", "sceneTransparent");
    }
}

From source file:org.terasology.rendering.renderingProcesses.DefaultRenderingProcess.java

License:Apache License

private void generateHighPass() {
    GLSLShaderProgramInstance program = ShaderManager.getInstance().getShaderProgramInstance("highp");
    program.setFloat("highPassThreshold", (Float) bloomHighPassThreshold.getValue());
    program.enable();//  w ww  .  ja  v  a2 s.com

    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);
}