Example usage for org.lwjgl.opengl GL11 GL_TEXTURE_MAG_FILTER

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

Introduction

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

Prototype

int GL_TEXTURE_MAG_FILTER

To view the source code for org.lwjgl.opengl GL11 GL_TEXTURE_MAG_FILTER.

Click Source Link

Document

TextureParameterName

Usage

From source file:a1.gui.GUI_Map.java

License:Open Source License

public void DoCreate() {
    IntBuffer tt = BufferUtils.createIntBuffer(1);
    GL11.glGenTextures(tt);/*from  w w  w. j a va  2 s .  com*/
    LightMap = tt.get(0);

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, LightMap);
    ByteBuffer bb = BufferUtils.createByteBuffer(1024 * 1024 * 4);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, 1024, 1024, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE,
            bb);
    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
    Render2D.CheckError();
}

From source file:betterfonts.GlyphCache.java

License:Open Source 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 w  w .j av a  2 s.co m*/
 *
 * @todo use GL_ALPHA4 if anti-alias is turned off for even smaller textures
 */
private void allocateGlyphCacheTexture() {
    /* Initialize the background to all white but fully transparent. */
    glyphCacheGraphics.clearRect(0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT);

    /* Allocate new OpenGL texure */
    singleIntBuffer.clear();
    GL11.glGenTextures(singleIntBuffer);
    textureName = singleIntBuffer.get(0);

    /* Load imageBuffer with pixel data ready for transfer to OpenGL texture */
    updateImageBuffer(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, textureName);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_ALPHA8, TEXTURE_WIDTH, TEXTURE_HEIGHT, 0, GL11.GL_RGBA,
            GL11.GL_UNSIGNED_BYTE, imageBuffer);

    /* Explicitely disable mipmap support becuase 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);
}

From source file:com.adavr.player.globjects.Texture.java

License:Open Source License

public static Texture create(int internalFormat, int width, int height, int format, int type,
        ByteBuffer pixels) {/*from  w  w  w. ja va2 s  .  com*/
    int id = GL11.glGenTextures();
    int target = GL11.GL_TEXTURE_2D;

    GL11.glBindTexture(target, id);

    GL11.glTexImage2D(target, 0, internalFormat, width, height, 0, format, type, pixels);

    GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
    GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);

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

    return new Texture(id, target);
}

From source file:com.ardor3d.scene.state.lwjgl.LwjglTextureStateUtil.java

License:Open Source License

/**
 * Check if the filter settings of this particular texture have been changed and apply as needed.
 * //from w w w . ja v  a2  s. c o m
 * @param texture
 *            our texture object
 * @param texRecord
 *            our record of the last state of the texture in gl
 * @param record
 */
public static void applyFilter(final Texture texture, final TextureRecord texRecord, final int unit,
        final TextureStateRecord record, final ContextCapabilities caps) {
    final Type type = texture.getType();

    final int magFilter = LwjglTextureUtil.getGLMagFilter(texture.getMagnificationFilter());
    // set up magnification filter
    if (!texRecord.isValid() || texRecord.magFilter != magFilter) {
        checkAndSetUnit(unit, record, caps);
        GL11.glTexParameteri(getGLType(type), GL11.GL_TEXTURE_MAG_FILTER, magFilter);
        texRecord.magFilter = magFilter;
    }

    final int minFilter = LwjglTextureUtil.getGLMinFilter(texture.getMinificationFilter());
    // set up mipmap filter
    if (!texRecord.isValid() || texRecord.minFilter != minFilter) {
        checkAndSetUnit(unit, record, caps);
        GL11.glTexParameteri(getGLType(type), GL11.GL_TEXTURE_MIN_FILTER, minFilter);
        texRecord.minFilter = minFilter;
    }

    // set up aniso filter
    if (caps.isAnisoSupported()) {
        float aniso = texture.getAnisotropicFilterPercent() * (caps.getMaxAnisotropic() - 1.0f);
        aniso += 1.0f;
        if (!texRecord.isValid() || (texRecord.anisoLevel - aniso > MathUtils.ZERO_TOLERANCE)) {
            checkAndSetUnit(unit, record, caps);
            GL11.glTexParameterf(getGLType(type), EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT,
                    aniso);
            texRecord.anisoLevel = aniso;
        }
    }
}

From source file:com.auroraengine.opengl.GLTexture.java

License:Open Source License

@Override
public void update() throws GLException {
    if (tex_ref != 0) {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex_ref);

        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, min_filter);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, mag_filter);

        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, wrap_s);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, wrap_t);

        if (image_modified) {
            ByteBuffer bb = ByteBuffer.allocateDirect(4 * img.getWidth() * img.getHeight());
            GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL12.GL_BGRA, img.getWidth(), img.getHeight(), 0,
                    GL12.GL_BGRA, GL11.GL_UNSIGNED_BYTE, bb);
            // TODO: Redirect images to buffers
        }/*from ww w  .ja  v a  2s . c o  m*/
    }
}

From source file:com.damagedearth.Utilities.Components.TrueTypeFont.java

License:Open Source License

public static int loadImage(BufferedImage bufferedImage) {
    try {//from  w ww .j  av  a 2s .com
        short width = (short) bufferedImage.getWidth();
        short height = (short) bufferedImage.getHeight();
        //textureLoader.bpp = bufferedImage.getColorModel().hasAlpha() ? (byte)32 : (byte)24;
        int bpp = (byte) bufferedImage.getColorModel().getPixelSize();
        ByteBuffer byteBuffer;
        DataBuffer db = bufferedImage.getData().getDataBuffer();
        if (db instanceof DataBufferInt) {
            int intI[] = ((DataBufferInt) (bufferedImage.getData().getDataBuffer())).getData();
            byte newI[] = new byte[intI.length * 4];
            for (int i = 0; i < intI.length; i++) {
                byte b[] = intToByteArray(intI[i]);
                int newIndex = i * 4;

                newI[newIndex] = b[1];
                newI[newIndex + 1] = b[2];
                newI[newIndex + 2] = b[3];
                newI[newIndex + 3] = b[0];
            }

            byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder())
                    .put(newI);
        } else {
            byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder())
                    .put(((DataBufferByte) (bufferedImage.getData().getDataBuffer())).getData());
        }
        byteBuffer.flip();

        int internalFormat = GL11.GL_RGBA8, format = GL11.GL_RGBA;
        IntBuffer textureId = BufferUtils.createIntBuffer(1);
        ;
        GL11.glGenTextures(textureId);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId.get(0));

        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);

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

        GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);

        GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, internalFormat, width, height, format, GL11.GL_UNSIGNED_BYTE,
                byteBuffer);
        return textureId.get(0);

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

    return -1;
}

From source file:com.dinasgames.engine.graphics.Texture.java

public boolean create(int width, int height) {

    if (width == 0 && height == 0) {
        return false;
    }/*from  w ww.  j a  va 2 s.  c  om*/

    Vector2i actualSize = new Vector2i(getValidSize(width), getValidSize(height));

    int maxSize = getMaximumSize();
    if ((actualSize.x > maxSize) || (actualSize.y > maxSize)) {
        System.out.println("Failed to create texture, its internal size is too high (" + actualSize.x + ", "
                + actualSize.y + ") maximum is (" + maxSize + ", " + maxSize + ")");
        return false;
    }

    mWidth = width;
    mHeight = height;
    mActualWidth = actualSize.x;
    mActualHeight = actualSize.y;
    mPixelsFlipped = false;

    if (mTexture <= 0) {
        mTexture = GL11.glGenTextures();
    }

    int textureEdgeClamp = GL.clampToEdge();

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, mTexture);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, mActualWidth, mActualHeight, 0, GL11.GL_RGBA,
            GL11.GL_UNSIGNED_BYTE, 0);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S,
            (mRepeated ? GL11.GL_REPEAT : textureEdgeClamp));
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T,
            (mRepeated ? GL11.GL_REPEAT : textureEdgeClamp));
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER,
            (mSmooth ? GL11.GL_LINEAR : GL11.GL_NEAREST));
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER,
            (mSmooth ? GL11.GL_LINEAR : GL11.GL_NEAREST));
    mCacheId = getUniqueId();

    return true;

}

From source file:com.dinasgames.engine.graphics.Texture.java

public Texture setSmooth(boolean smooth) {

    if (smooth != mSmooth) {

        mSmooth = smooth;//from   w ww.jav a  2  s  .  co m

        if (mTexture > 0) {
            GL11.glBindTexture(GL11.GL_TEXTURE_2D, mTexture);
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER,
                    (mSmooth ? GL11.GL_LINEAR : GL11.GL_NEAREST));
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER,
                    (mSmooth ? GL11.GL_LINEAR : GL11.GL_NEAREST));
        }

    }

    return this;

}

From source file:com.dyonovan.tcnodetracker.lib.truetyper.TrueTypeFont.java

License:Open Source License

public static int loadImage(BufferedImage bufferedImage) {
    try {/*from   w  w  w .  j a  v  a 2  s  .  co m*/
        short width = (short) bufferedImage.getWidth();
        short height = (short) bufferedImage.getHeight();
        //textureLoader.bpp = bufferedImage.getColorModel().hasAlpha() ? (byte)32 : (byte)24;
        int bpp = (byte) bufferedImage.getColorModel().getPixelSize();
        ByteBuffer byteBuffer;
        DataBuffer db = bufferedImage.getData().getDataBuffer();
        if (db instanceof DataBufferInt) {
            int intI[] = ((DataBufferInt) (bufferedImage.getData().getDataBuffer())).getData();
            byte newI[] = new byte[intI.length * 4];
            for (int i = 0; i < intI.length; i++) {
                byte b[] = intToByteArray(intI[i]);
                int newIndex = i * 4;

                newI[newIndex] = b[1];
                newI[newIndex + 1] = b[2];
                newI[newIndex + 2] = b[3];
                newI[newIndex + 3] = b[0];
            }

            byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder())
                    .put(newI);
        } else {
            byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder())
                    .put(((DataBufferByte) (bufferedImage.getData().getDataBuffer())).getData());
        }
        byteBuffer.flip();

        int internalFormat = GL11.GL_RGBA8, format = GL11.GL_RGBA;
        IntBuffer textureId = BufferUtils.createIntBuffer(1);
        ;
        GL11.glGenTextures(textureId);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId.get(0));

        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);

        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_NEAREST);
        //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
        //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_NEAREST);

        //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
        //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);
        //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_NEAREST);

        GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);

        GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, internalFormat, width, height, format, GL11.GL_UNSIGNED_BYTE,
                byteBuffer);
        return textureId.get(0);

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

    return -1;
}

From source file:com.enderville.mod.client.gui.mainmenu.MenuBaseEnderVille.java

License:LGPL

/**
 * Renders the skybox in the main menu/*from  w w w. j  a v  a2  s  .  c om*/
 */
private void renderSkybox(int par1, int par2, float par3) {
    GL11.glViewport(0, 0, 256, 256);
    this.drawPanorama(par1, par2, par3);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    this.rotateAndBlurSkybox(par3);
    this.rotateAndBlurSkybox(par3);
    this.rotateAndBlurSkybox(par3);
    this.rotateAndBlurSkybox(par3);
    this.rotateAndBlurSkybox(par3);
    this.rotateAndBlurSkybox(par3);
    this.rotateAndBlurSkybox(par3);
    this.rotateAndBlurSkybox(par3);
    GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight);
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    float f1 = this.width > this.height ? 120.0F / (float) this.width : 120.0F / (float) this.height;
    float f2 = (float) this.height * f1 / 256.0F;
    float f3 = (float) this.width * f1 / 256.0F;
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
    //        tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F);
    int k = this.width;
    int l = this.height;
    tessellator.addVertexWithUV(0.0D, (double) l, (double) this.zLevel, (double) (0.5F - f2),
            (double) (0.5F + f3));
    tessellator.addVertexWithUV((double) k, (double) l, (double) this.zLevel, (double) (0.5F - f2),
            (double) (0.5F - f3));
    tessellator.addVertexWithUV((double) k, 0.0D, (double) this.zLevel, (double) (0.5F + f2),
            (double) (0.5F - f3));
    tessellator.addVertexWithUV(0.0D, 0.0D, (double) this.zLevel, (double) (0.5F + f2), (double) (0.5F + f3));
    tessellator.draw();
}