Example usage for org.lwjgl.opengl GL11 glBindTexture

List of usage examples for org.lwjgl.opengl GL11 glBindTexture

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glBindTexture.

Prototype

public static void glBindTexture(@NativeType("GLenum") int target, @NativeType("GLuint") int texture) 

Source Link

Document

Binds the a texture to a texture target.

Usage

From source file:com.xrbpowered.gl.res.textures.ArrayTexture.java

License:Open Source License

public ArrayTexture finish(boolean wrap, boolean filter) {
    intBuffer.flip();/*from w ww  . j a v  a  2s  .com*/
    GL12.glTexImage3D(GL30.GL_TEXTURE_2D_ARRAY, 0, GL11.GL_RGBA, width, height, layers, 0, GL12.GL_BGRA,
            GL12.GL_UNSIGNED_INT_8_8_8_8_REV, intBuffer);
    intBuffer = null;
    Texture.setProperties(GL30.GL_TEXTURE_2D_ARRAY, wrap, filter, Client.settings.anisotropy);
    GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, 0);
    Client.checkError();
    return this;
}

From source file:com.xrbpowered.gl.res.textures.ArrayTexture.java

License:Open Source License

public void bind(int index) {
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + index);
    GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, texId);
}

From source file:com.xrbpowered.gl.res.textures.BufferTexture.java

License:Open Source License

public void update() {
    if (this.imgBuffer == null)
        createBuffers();/*  w  w  w .ja  v a 2  s  . c o m*/

    if (updateBuffer((Graphics2D) imgBuffer.getGraphics(), width, height)) {
        pixels = imgBuffer.getRGB(0, 0, width, height, pixels, 0, width);
        intBuffer.put(pixels);
        intBuffer.flip();

        GL13.glActiveTexture(GL13.GL_TEXTURE0);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, getId());

        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);
        //         GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); // TODO needless mipmaps?
    }

    if (!staticBuffers)
        destroyBuffers();
}

From source file:com.xrbpowered.gl.res.textures.CubeTexture.java

License:Open Source License

public CubeTexture(String pathFormat) {
    try {/*from w  w  w.  ja  v  a 2 s .c  o  m*/
        texId = GL11.glGenTextures();
        GL13.glActiveTexture(GL13.GL_TEXTURE0);
        GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, texId);

        IntBuffer buf = null;

        for (int i = 0; i < 6; i++) {
            //            BufferedImage img = load(new FileInputStream(String.format("assets/"+pathFormat, FACE_NAMES[i])));
            BufferedImage img = AssetManager.defaultAssets.loadImage(String.format(pathFormat, FACE_NAMES[i]));
            buf = getPixels(img, buf);
            put(GL13.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, img.getWidth(), img.getHeight(), buf);
        }

        GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
        GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
        GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
        GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
        GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL12.GL_TEXTURE_WRAP_R, GL12.GL_CLAMP_TO_EDGE);
        GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, 0);

        Client.checkError();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(-1);
    }
}

From source file:com.xrbpowered.gl.res.textures.Texture.java

License:Open Source License

protected void create(int w, int h, IntBuffer buf, boolean wrap, boolean filter) {
    width = w;/*from   w ww  . j  a va  2  s . co m*/
    height = h;
    texId = GL11.glGenTextures();
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId);

    put(GL11.GL_TEXTURE_2D, w, h, buf);
    setProperties(GL11.GL_TEXTURE_2D, wrap, filter, Client.settings.anisotropy);
}

From source file:com.xrbpowered.gl.res.textures.Texture.java

License:Open Source License

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

From source file:com.xrbpowered.gl.res.textures.Texture.java

License:Open Source License

public static void unbind(int index) {
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + index);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
}

From source file:cpw.mods.fml.client.FMLClientHandler.java

License:Open Source License

public int getEffectTexture(TextureFX effect) {
    Integer id = effectTextures.get(effect);
    if (id != null) {
        return id;
    }/*from w  ww.  ja v a  2s. c  o  m*/

    int old = GL11.glGetInteger(GL_TEXTURE_BINDING_2D);

    effect.bindImage(client.renderEngine);

    id = GL11.glGetInteger(GL_TEXTURE_BINDING_2D);

    GL11.glBindTexture(GL_TEXTURE_2D, old);

    effectTextures.put(effect, id);

    return id;
}

From source file:cuchaz.jfxgl.prism.JFXGLContext.java

License:Open Source License

@Override
public void bindTexture(int texID) {
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID);
}

From source file:cuchaz.jfxgl.prism.JFXGLContext.java

License:Open Source License

@Override
public int createTexture(int width, int height) {

    int texId = GL11.glGenTextures();
    if (texId == 0) {
        return 0;
    }//from   w  w  w.  ja  v a  2s  . c  om

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId);

    // make the texture
    clearGLErrors();
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA,
            GL11.GL_UNSIGNED_BYTE, 0);

    // if something bad happened, delete the texture
    if (hasGLError()) {
        GL11.glDeleteTextures(texId);
        return 0;
    }

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

    return texId;
}