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.shader.ShaderParametersSSAO.java

License:Apache License

@Override
public void applyParameters(Material program) {
    super.applyParameters(program);

    DefaultRenderingProcess.FBO scene = DefaultRenderingProcess.getInstance().getFBO("sceneOpaque");

    int texId = 0;

    if (scene != null) {
        GL13.glActiveTexture(GL13.GL_TEXTURE0);
        scene.bindDepthTexture();/*from w  w  w.  java 2s .c om*/
        program.setInt("texDepth", texId++, true);
        GL13.glActiveTexture(GL13.GL_TEXTURE1);
        scene.bindNormalsTexture();
        program.setInt("texNormals", texId++, true);
    }

    Texture ssaoNoiseTexture = updateNoiseTexture();

    GL13.glActiveTexture(GL13.GL_TEXTURE2);
    glBindTexture(GL11.GL_TEXTURE_2D, ssaoNoiseTexture.getId());
    program.setInt("texNoise", texId++, true);

    program.setFloat4("ssaoSettings", ssaoStrength, ssaoRad, 0.0f, 0.0f, true);

    if (CoreRegistry.get(WorldRenderer.class) != null) {
        Camera activeCamera = CoreRegistry.get(WorldRenderer.class).getActiveCamera();
        if (activeCamera != null) {
            program.setMatrix4("invProjMatrix", activeCamera.getInverseProjectionMatrix(), true);
            program.setMatrix4("projMatrix", activeCamera.getProjectionMatrix(), true);
        }
    }
}

From source file:org.terasology.rendering.shader.ShaderParametersToneMapping.java

License:Apache License

@Override
public void applyParameters(Material program) {
    super.applyParameters(program);

    DisplayResolutionDependentFBOs displayResolutionDependentFBOs = CoreRegistry
            .get(DisplayResolutionDependentFBOs.class); // TODO: switch from CoreRegistry to Context.
    ScreenGrabber screenGrabber = CoreRegistry.get(ScreenGrabber.class);

    // TODO: move into a tone mapping node
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    displayResolutionDependentFBOs.bindFboColorTexture(InitialPostProcessingNode.INITIAL_POST_FBO);
    program.setInt("texScene", 0, true);

    program.setFloat("exposure", screenGrabber.getExposure() * exposureBias, true);
    program.setFloat("whitePoint", whitePoint, true);
}

From source file:org.terasology.rendering.shader.ShaderParametersVolumetricLightingRayMarching.java

License:Apache License

@Override
public void applyParameters(Material program) {
    super.applyParameters(program);

    int texId = 0;

    DefaultRenderingProcess.FBO sceneOpaque = DefaultRenderingProcess.getInstance().getFBO("sceneOpaque");

    if (CoreRegistry.get(Config.class).getRendering().isVolumetricLighting()) {

        if (sceneOpaque != null) {
            GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
            sceneOpaque.bindDepthTexture();
            program.setInt("texSceneOpaqueDepth", texId++, true);
        }//from ww w.  j  av a 2 s  . com

        DefaultRenderingProcess.FBO volumetricLighting = DefaultRenderingProcess.getInstance()
                .getFBO("volumetricLighting");

        program.setFloat2("texelSize", 1.0f / volumetricLighting.width, 1.0f / volumetricLighting.height, true);

        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        DefaultRenderingProcess.getInstance().bindFboDepthTexture("sceneShadowMap");
        program.setInt("texSceneShadowMap", texId++, true);

        Camera activeCamera = CoreRegistry.get(WorldRenderer.class).getActiveCamera();
        Camera lightCamera = CoreRegistry.get(WorldRenderer.class).getLightCamera();
        if (lightCamera != null && activeCamera != null) {
            program.setMatrix4("invViewProjMatrix", activeCamera.getInverseViewProjectionMatrix(), true);

            program.setMatrix4("lightViewMatrix", lightCamera.getViewMatrix(), true);
            program.setMatrix4("lightProjMatrix", lightCamera.getProjectionMatrix(), true);
            program.setMatrix4("lightViewProjMatrix", lightCamera.getViewProjectionMatrix(), true);

            Vector3f activeCameraToLightSpace = new Vector3f();
            activeCameraToLightSpace.sub(activeCamera.getPosition(), lightCamera.getPosition());
            program.setFloat3("activeCameraToLightSpace", activeCameraToLightSpace.x,
                    activeCameraToLightSpace.y, activeCameraToLightSpace.z, true);
        }

        program.setFloat4("volumetricLightingSettings", volLightingDensity, volLightingDecay, volLightingPhi,
                volLightingScattering, true);

        if (CoreRegistry.get(Config.class).getRendering().isCloudShadows()) {
            Texture clouds = Assets.getTexture("engine:perlinNoiseTileable");
            GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
            glBindTexture(GL11.GL_TEXTURE_2D, clouds.getId());
            program.setInt("texSceneClouds", texId++, true);
        }
    }
}

From source file:org.terasology.rendering.shader.ShaderProgram.java

License:Apache License

public void enable() {
    ShaderProgram activeProgram = ShaderManager.getInstance().getActiveShaderProgram();

    if (activeProgram != this) {
        GL13.glActiveTexture(GL13.GL_TEXTURE0);
        GL20.glUseProgram(shaderProgram);

        // Make sure the shader manager knows that this program is currently active
        ShaderManager.getInstance().setActiveShaderProgram(this);

        // Set the shader parameters if available
        if (parameters != null) {
            parameters.applyParameters(this);
        }//from w  ww .  ja  v a  2s . c o m
    }
}

From source file:org.terasology.rendering.ShaderManager.java

License:Apache License

public void bindTexture(int slot, Texture texture) {
    if (activeMaterial != null && !activeMaterial.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, texture.getId());
        GL13.glActiveTexture(GL13.GL_TEXTURE0);
    }/*from w w w. jav a2 s.c  o m*/
}

From source file:org.terasology.rendering.ShaderManagerLwjgl.java

License:Apache License

@Override
public void bindTexture(int slot, Texture texture) {
    if (activeMaterial != null && !activeMaterial.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, texture.getId());
        GL13.glActiveTexture(GL13.GL_TEXTURE0);
    }//  www.  j  a  v  a  2  s  .  com
}

From source file:resource.Material.java

License:Open Source License

public void bind() {
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    if (textures[0] == null) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
    } else {//from w  w w .  j  a v a 2s  .  c om
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, textures[0].getID());
        //            GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);
    }
    GL13.glActiveTexture(GL13.GL_TEXTURE1);
    if (textures[1] == null) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
    } else {
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, textures[1].getID());
        //            GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);
    }

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    // And set the materails
    GL11.glMaterial(GL11.GL_FRONT, GL11.GL_SPECULAR, get(specular));
    GL11.glMaterial(GL11.GL_FRONT, GL11.GL_DIFFUSE, get(diffuse));
    GL11.glMaterial(GL11.GL_FRONT, GL11.GL_SHININESS, get(shininess));
}

From source file:se.angergard.engine.graphics.Texture.java

License:Apache License

private void loadTexture(ByteBuffer buffer, int textureID, int width, int height) {
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);

    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);

    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA,
            GL11.GL_UNSIGNED_BYTE, buffer);

    // Not all computer will support this, fix //TODO
    GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);

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

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