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:com.redthirddivision.quad.rendering.renderers.TerrainRenderer.java

License:Apache License

private void bindTextures(Terrain terrain) {
    TerrainTexturePack texturePack = terrain.getTexturePack();
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texturePack.getBackgroundTexture().getTextureID());

    GL13.glActiveTexture(GL13.GL_TEXTURE1);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texturePack.getrTexture().getTextureID());

    GL13.glActiveTexture(GL13.GL_TEXTURE2);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texturePack.getgTexture().getTextureID());

    GL13.glActiveTexture(GL13.GL_TEXTURE3);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texturePack.getbTexture().getTextureID());

    GL13.glActiveTexture(GL13.GL_TEXTURE4);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, terrain.getBlendMap().getTextureID());
}

From source file:com.samrj.devil.gl.Texture.java

License:Open Source License

/**
 * Temporarily activates the given texture unit, binds this texture to it,
 * then activates whichever unit was active before this method was called.
 * //from w  w  w  . j a  va 2  s  . co m
 * @param texture The OpenGL texture unit enum to bind to.
 * @return This texture.
 */
public final T bind(int texture) {
    if (deleted)
        throw new IllegalStateException("Cannot bind deleted texture.");
    if (texture < GL13.GL_TEXTURE0)
        throw new IllegalArgumentException();
    int old = GL11.glGetInteger(GL13.GL_ACTIVE_TEXTURE);
    GL13.glActiveTexture(texture);
    bind();
    GL13.glActiveTexture(old);
    return getThis();
}

From source file:com.samrj.devil.ui.AtlasFont.java

License:Open Source License

public void draw(String text, Vec2 pos, Vec2 align) {
    pos = new Vec2(pos.x, pos.y - lineHeight + baseHeight);
    align = new Vec2(align.x - 1.0f, -align.y - 1.0f).mult(0.5f);
    align.x *= getWidth(text);//from   w w w.  j  a  va 2 s  .  co m
    align.y *= baseHeight - lineHeight;
    pos.add(align);

    int x = 0;
    for (int i = 0; i < text.length(); i++) {
        Char c = getChar(text.charAt(i));
        if (c == null)
            continue;

        int lf = Math.round(pos.x) + x + c.xOffset;
        int rt = lf + c.width;
        int bt = Math.round(pos.y) + c.yOffset;
        int tp = bt + c.height;

        coord.set(c.tx0, c.ty0);
        this.pos.set(lf, bt);
        stream.vertex();
        coord.set(c.tx0, c.ty1);
        this.pos.set(lf, tp);
        stream.vertex();
        coord.set(c.tx1, c.ty1);
        this.pos.set(rt, tp);
        stream.vertex();
        coord.set(c.tx1, c.ty0);
        this.pos.set(rt, bt);
        stream.vertex();

        x += c.xAdvance;
    }
    stream.upload();

    texture.bind(GL13.GL_TEXTURE0);
    DGL.draw(stream, GL11.GL_QUADS);
}

From source file:com.timvisee.voxeltex.module.material.Material.java

License:Open Source License

@Override
public void bind() {
    // Bind the shader
    this.shader.bind();

    // Bind the texture and normal if available
    if (hasTexture())
        this.texture.bind(GL13.GL_TEXTURE0);
    //        if(hasNormal())
    //            this.normal.bind(GL13.GL_TEXTURE1);
}

From source file:com.timvisee.voxeltex.module.texture.Texture.java

License:Open Source License

/**
 * Create a texture from a byte buffer.//from  w  w w  .j  av a2s. co  m
 *
 * @param buffer The byte buffer containing the texture data.
 * @param width Texture width.
 * @param height Texture height.
 * @param components Number of components in the texture buffer. Choose from COMPONENTS_RGBA or COMPONENTS_RGB.
 *
 * @return Texture.
 */
public static Texture fromByteBuffer(ByteBuffer buffer, int width, int height, int components) {
    // Create a new texture instance
    Texture texture = new Texture();

    // Bind the texture
    texture.bind(GL13.GL_TEXTURE0);

    // Set the texture parameters
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);

    // Configure the texture and write the buffer to the texture
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, components == 4 ? GL_RGBA : GL_RGB,
            GL_UNSIGNED_BYTE, buffer);

    // Done using the texture, unbind
    Texture.unbind();

    // Set the width and height
    texture.width = width;
    texture.height = height;

    // Return the created texture
    return texture;
}

From source file:com.voxelplugineering.voxelsniper.render.RenderMain.java

License:Open Source License

public void tick() {
    if (!setup) {
        return;//w ww  .  j a  va  2 s  .  c o  m
    }
    Camera camera = Standalone.system().getMainCamera();

    // reset view matrix
    viewMatrix.setIdentity();

    // Translate camera
    Vector3f rot = camera.getCameraRot();
    Matrix4f.rotate(rot.x, new Vector3f(1, 0, 0), viewMatrix, viewMatrix);
    Matrix4f.rotate(rot.y, new Vector3f(0, 1, 0), viewMatrix, viewMatrix);
    Matrix4f.rotate(rot.z, new Vector3f(0, 0, 1), viewMatrix, viewMatrix);
    Matrix4f.translate(camera.getCameraPos(), viewMatrix, viewMatrix);

    GL20.glUseProgram(pId);

    // push matrices
    viewMatrix.store(matrix44Buffer);
    matrix44Buffer.flip();
    GL20.glUniformMatrix4(viewMatrixLocation, false, matrix44Buffer);
    modelMatrix.store(matrix44Buffer);
    matrix44Buffer.flip();
    GL20.glUniformMatrix4(modelMatrixLocation, false, matrix44Buffer);
    projectionMatrix.store(matrix44Buffer);
    matrix44Buffer.flip();
    GL20.glUniformMatrix4(projectionMatrixLocation, false, matrix44Buffer);

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

    // bind textures
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.textures.get("block"));

    // render all buffer sections
    buffer.renderSections();

    GL20.glUseProgram(0);

    OpenGLUtilities.checkGLError("render main");

    Display.update();
}

From source file:com.voxelplugineering.voxelsniper.render.TextureManager.java

License:Open Source License

public int load(String name, File file) {
    int id = TextureUtilities.loadPNGTexture(file, GL13.GL_TEXTURE0);
    textures.put(name, id);/*  w  ww.jav a  2s. c  om*/
    if (name.equals("debug")) {
        this.debug = id;
    }
    return id;
}

From source file:com.xrbpowered.gl.examples.GLLife.java

License:Open Source License

private void resetBuffers(boolean fill) {
    if (buffers[0] != null)
        buffers[0].destroy();//from   w ww.  j  a va2 s.c o  m
    if (buffers[1] != null)
        buffers[1].destroy();

    int width = getTargetWidth();
    int height = getTargetHeight();
    buffers[0] = new OffscreenBuffers(width, height, false);
    buffers[1] = new OffscreenBuffers(width, height, false);
    targetBuffer = 1;
    turn = 0;

    IntBuffer intBuffer = ByteBuffer.allocateDirect(4 * width * height).order(ByteOrder.nativeOrder())
            .asIntBuffer();
    int[] pixels = new int[width * height];
    for (int x = 1; x < width; x++)
        for (int y = 1; y < height; y++) {
            int v = fill && random.nextInt(27) == 0 ? 0xffffffff : 0xff000000;
            pixels[y * width + x] = v;
        }
    intBuffer.put(pixels);
    intBuffer.flip();

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, buffers[0].getColorTexId());
    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL12.GL_BGRA,
            GL12.GL_UNSIGNED_INT_8_8_8_8_REV, intBuffer);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, buffers[1].getColorTexId());
    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL12.GL_BGRA,
            GL12.GL_UNSIGNED_INT_8_8_8_8_REV, intBuffer);
}

From source file:com.xrbpowered.gl.examples.GLLife.java

License:Open Source License

private void addGlider(int x, int y, int width, int height, int[] pixels) {
    IntBuffer intBuffer = ByteBuffer.allocateDirect(4 * width * height).order(ByteOrder.nativeOrder())
            .asIntBuffer();/*from w ww .  jav a  2 s .  c o  m*/
    intBuffer.put(pixels);
    intBuffer.flip();

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, buffers[1 - targetBuffer].getColorTexId());
    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
    GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, x, y, width, height, GL12.GL_BGRA,
            GL12.GL_UNSIGNED_INT_8_8_8_8_REV, intBuffer);
}

From source file:com.xrbpowered.gl.res.buffers.OffscreenBuffers.java

License:Open Source License

public void bindColorBuffer(int index) {
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + index);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, colorTexId);
}