Example usage for org.lwjgl.opengl GL11 glTexParameteri

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

Introduction

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

Prototype

public static void glTexParameteri(@NativeType("GLenum") int target, @NativeType("GLenum") int pname,
        @NativeType("GLint") int param) 

Source Link

Document

Sets the integer value of a texture parameter, which controls how the texel array is treated when specified or changed, and when applied to a fragment.

Usage

From source file:org.terasology.logic.manager.TextureManager.java

License:Apache License

public Texture loadTexture(String path, String[] mipMapPaths) throws IOException {
    Texture texture = new Texture();

    texture.id = glGenTextures();/*from  w  w w.j  a  v  a2s .co m*/
    glBindTexture(GL11.GL_TEXTURE_2D, texture.id);

    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    GL11.glTexParameteri(GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    GL11.glTexParameteri(GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL_NEAREST);

    readTexture(path, texture);

    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 4);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, texture.width, texture.height, 0, GL11.GL_RGBA,
            GL11.GL_UNSIGNED_BYTE, texture.data);

    if (mipMapPaths != null) {
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, mipMapPaths.length);
        GL11.glTexParameteri(GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
        GL11.glTexParameteri(GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL_NEAREST_MIPMAP_NEAREST);

        for (int i = 0; i < mipMapPaths.length; i++) {
            Texture t = new Texture();
            readTexture(mipMapPaths[i], t);

            GL11.glTexImage2D(GL11.GL_TEXTURE_2D, i + 1, GL11.GL_RGBA, t.width, t.height, 0, GL11.GL_RGBA,
                    GL11.GL_UNSIGNED_BYTE, t.data);
        }
    }

    return texture;
}

From source file:org.terasology.rendering.assets.Texture.java

License:Apache License

public Texture(AssetUri uri, ByteBuffer[] data, int width, int height, WrapMode wrapMode,
        FilterMode filterMode) {/*from  ww w  . java2s .co  m*/
    if (data.length == 0)
        throw new IllegalArgumentException("Expected Data.length >= 1");
    this.uri = uri;
    this.width = width;
    this.height = height;
    this.wrapMode = wrapMode;
    this.filterMode = filterMode;
    this.data = data;

    id = glGenTextures();
    logger.debug("Bound texture '{}' - {}", uri, id);
    glBindTexture(GL11.GL_TEXTURE_2D, id);

    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapMode.getGLMode());
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapMode.getGLMode());
    GL11.glTexParameteri(GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filterMode.getGlMinFilter());
    GL11.glTexParameteri(GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filterMode.getGlMagFilter());
    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 4);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, data.length - 1);

    for (int i = 0; i < data.length; i++) {
        GL11.glTexImage2D(GL11.GL_TEXTURE_2D, i, GL11.GL_RGBA, width >> i, height >> i, 0, GL11.GL_RGBA,
                GL11.GL_UNSIGNED_BYTE, data[i]);
    }
}

From source file:org.terasology.rendering.opengl.OpenGLTexture.java

License:Apache License

@Override
public void reload(TextureData data) {
    this.width = data.getWidth();
    this.height = data.getHeight();
    this.depth = data.getDepth();
    this.wrapMode = data.getWrapMode();
    this.filterMode = data.getFilterMode();
    this.textureType = data.getType();
    this.textureData = data;

    if (id == 0) {
        id = glGenTextures();//from   w  w w  .j a v a2 s  .co  m
    }

    switch (textureType) {
    case TEXTURE2D:
        logger.debug("Bound texture '{}' - {}", getURI(), id);
        glBindTexture(GL11.GL_TEXTURE_2D, id);

        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, getGLMode(wrapMode));
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, getGLMode(wrapMode));
        GL11.glTexParameteri(GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, getGlMinFilter(filterMode));
        GL11.glTexParameteri(GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, getGlMagFilter(filterMode));
        GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 4);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, data.getBuffers().length - 1);

        if (data.getBuffers().length > 0) {
            for (int i = 0; i < data.getBuffers().length; i++) {
                GL11.glTexImage2D(GL11.GL_TEXTURE_2D, i, GL11.GL_RGBA, width >> i, height >> i, 0, GL11.GL_RGBA,
                        GL11.GL_UNSIGNED_BYTE, data.getBuffers()[i]);
            }
        } else {
            GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA,
                    GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);
        }
        break;
    case TEXTURE3D:
        logger.debug("Bound texture '{}' - {}", getURI(), id);
        glBindTexture(GL12.GL_TEXTURE_3D, id);

        glTexParameterf(GL12.GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, getGLMode(wrapMode));
        glTexParameterf(GL12.GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, getGLMode(wrapMode));
        glTexParameterf(GL12.GL_TEXTURE_3D, GL12.GL_TEXTURE_WRAP_R, getGLMode(wrapMode));

        GL11.glTexParameteri(GL12.GL_TEXTURE_3D, GL11.GL_TEXTURE_MIN_FILTER, getGlMinFilter(filterMode));
        GL11.glTexParameteri(GL12.GL_TEXTURE_3D, GL11.GL_TEXTURE_MAG_FILTER, getGlMagFilter(filterMode));

        GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 4);
        GL11.glTexParameteri(GL12.GL_TEXTURE_3D, GL12.GL_TEXTURE_MAX_LEVEL, data.getBuffers().length - 1);

        if (data.getBuffers().length > 0) {
            for (int i = 0; i < data.getBuffers().length; i++) {
                GL12.glTexImage3D(GL12.GL_TEXTURE_3D, i, GL11.GL_RGBA, width, height, depth, 0, GL11.GL_RGBA,
                        GL11.GL_UNSIGNED_BYTE, data.getBuffers()[i]);
            }
        } else {
            GL12.glTexImage3D(GL12.GL_TEXTURE_3D, 0, GL11.GL_RGBA, width, height, depth, 0, GL11.GL_RGBA,
                    GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);
        }

        break;
    }
}

From source file:org.voxels.platform.LWJGLOpenGLAdapter.java

License:Open Source License

@Override
public void glTexParameteri(final int target, final int pname, final int param) {
    GL11.glTexParameteri(target, pname, param);
}

From source file:org.xmlvm.iphone.gl.GL.java

License:Open Source License

public static void glTexParameteri(int t, int param, int value) {
    GL11.glTexParameteri(t, param, value);
}

From source file:processing.lwjgl.PGL.java

License:Open Source License

public void texParameteri(int target, int param, int value) {
    GL11.glTexParameteri(target, param, value);
}

From source file:processing.lwjgl.PLWJGL.java

License:Open Source License

public void texParameteriv(int target, int pname, IntBuffer params) {
    GL11.glTexParameteri(target, pname, params.get());
}

From source file:processing.opengl.PLWJGL.java

License:Open Source License

@Override
public void texParameteri(int target, int pname, int param) {
    GL11.glTexParameteri(target, pname, param);
}

From source file:processing.opengl.PLWJGL.java

License:Open Source License

@Override
public void texParameteriv(int target, int pname, IntBuffer params) {
    GL11.glTexParameteri(target, pname, params.get());
}

From source file:pw.knx.feather.font.FontCache.java

License:Apache License

/**
 * Allocate a new OpenGL texture for caching pre-rendered glyph images. The new texture is initialized to fully transparent
 * white so the individual glyphs images within can have a transparent border between them. The new texture remains bound
 * after returning from the function.//from  w  ww. j a  v a2s . c o m
 */
private void allocateTexture() {
    /* Initialize the background to all white but fully transparent. */
    glyphGraphics.clearRect(0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT);

    /* Allocate new OpenGL texure */
    texture = GL11.glGenTextures();

    /* Load imageBuffer with pixel data ready for transfer to OpenGL texture */
    updateBuffer(0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT);

    /*
       * Initialize texture with the now cleared BufferedImage. Using a texture with GL_ALPHA8 internal format may result in
       * faster rendering since the GPU has to only fetch 1 byte per texel instead of 4 with a regular RGBA texture.
       */
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_ALPHA8, TEXTURE_WIDTH, TEXTURE_HEIGHT, 0, GL11.GL_RGBA,
            GL11.GL_UNSIGNED_BYTE, imageBuffer);

    /* Explicitly disable mipmap support because updateTexture() will only update the base level 0 */
    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);
}