Example usage for org.lwjgl.opengl GL13 glActiveTexture

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

Introduction

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

Prototype

public static void glActiveTexture(@NativeType("GLenum") int texture) 

Source Link

Document

Selects which texture unit subsequent texture state calls will affect.

Usage

From source file:org.fenggui.binding.render.lwjgl.LWJGLOpenGL.java

License:Open Source License

public void activateTexture(int i) {
    try {//w  ww  .ja  va  2s.co m
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + i);
    } catch (java.lang.IllegalStateException e) {
        // Unsupported, ignore.
    }
}

From source file:org.free.jake2.render.lwjgl.Image.java

License:Open Source License

void GL_SelectTexture(int texture /* GLenum */) {
    int tmu;/*from  w  ww.  j  av a 2s.c o  m*/

    tmu = (texture == GL_TEXTURE0) ? 0 : 1;

    if (tmu == gl_state.currenttmu) {
        return;
    }

    gl_state.currenttmu = tmu;

    GL13.glActiveTexture(texture);
    GL13.glClientActiveTexture(texture);
}

From source file:org.jge.render.RenderEngine.java

License:Open Source License

public RenderEngine bindTexture(Texture texture, int samplerSlot) {
    assert (samplerSlot >= 0 && samplerSlot <= 31) : "Sampler slot must be >= 0 and <= 31";
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + samplerSlot);
    glBindTexture(texture.getResource().getTarget(), texture.getResource().getID());
    this.boundTexture = texture;
    return this;
}

From source file:org.jogamp.glg2d.impl.shader.GL2ES2ImageDrawer.java

License:Apache License

@Override
protected void begin(Texture texture, AffineTransform xform, Color bgcolor) {
    /*//from w  ww. ja  v  a  2s  .  c o  m
     * FIXME This is unexpected since we never disable blending, but in some
     * cases it interacts poorly with multiple split panes, scroll panes and the
     * text renderer to disable blending.
     */
    g2d.setComposite(g2d.getComposite());

    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    texture.bind();

    shader.use(true);

    if (bgcolor == null) {
        white.clear();
        white.put(white_static, 0, 3);
        white.put(g2d.getUniformsObject().colorHook.getAlpha());
        shader.setColor(white);
    } else {
        FloatBuffer rgba = g2d.getUniformsObject().colorHook.getRGBA();
        shader.setColor(rgba);
    }

    if (xform == null) {
        shader.setTransform(g2d.getUniformsObject().transformHook.getGLMatrixData());
    } else {
        shader.setTransform(g2d.getUniformsObject().transformHook.getGLMatrixData(xform));
    }

    shader.setTextureUnit(0);
}

From source file:org.oscim.gdx.LwjglGL20.java

License:Apache License

public void activeTexture(int texture) {
    GL13.glActiveTexture(texture);
}

From source file:org.spout.engine.renderer.shader.variables.TextureSamplerShaderVariable.java

License:Open Source License

public void bind(int unit) {
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + unit);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);

    if (((Client) Spout.getEngine()).getRenderMode() != RenderMode.GL30) {
        GL20.glUniform1i(location, textureID);

    } else {//  w  w w  . ja v  a  2  s  .  com
        GL30.glUniform1ui(location, textureID);
    }

}

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);
    }//  www .  j  a v a 2  s.  c  o m
}

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  ww. j a va 2  s.  c om

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