Example usage for org.lwjgl.opengl GL11 GL_NEAREST

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

Introduction

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

Prototype

int GL_NEAREST

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

Click Source Link

Document

TextureMagFilter

Usage

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

License:Open Source License

private static int translatePrismToGL(int value) {
    switch (value) {
    case GLContext.GL_FLOAT:
        return GL11.GL_FLOAT;
    case GLContext.GL_UNSIGNED_BYTE:
        return GL11.GL_UNSIGNED_BYTE;
    case GLContext.GL_UNSIGNED_INT_8_8_8_8_REV:
        return GL12.GL_UNSIGNED_INT_8_8_8_8_REV;
    case GLContext.GL_UNSIGNED_INT_8_8_8_8:
        return GL12.GL_UNSIGNED_INT_8_8_8_8;
    case GLContext.GL_UNSIGNED_SHORT_8_8_APPLE:
        return 0x85BA;

    case GLContext.GL_RGBA:
        return GL11.GL_RGBA;
    case GLContext.GL_BGRA:
        return GL12.GL_BGRA;
    case GLContext.GL_RGB:
        return GL11.GL_RGB;
    case GLContext.GL_LUMINANCE:
        return GL11.GL_LUMINANCE;
    case GLContext.GL_ALPHA:
        return GL11.GL_ALPHA;
    case GLContext.GL_RGBA32F:
        return GL30.GL_RGBA32F;
    case GLContext.GL_YCBCR_422_APPLE:
        return 0x85B9;

    case GLContext.GL_TEXTURE_2D:
        return GL11.GL_TEXTURE_2D;
    case GLContext.GL_TEXTURE_BINDING_2D:
        return GL11.GL_TEXTURE_BINDING_2D;
    case GLContext.GL_NEAREST:
        return GL11.GL_NEAREST;
    case GLContext.GL_LINEAR:
        return GL11.GL_LINEAR;
    case GLContext.GL_NEAREST_MIPMAP_NEAREST:
        return GL11.GL_NEAREST_MIPMAP_NEAREST;
    case GLContext.GL_LINEAR_MIPMAP_LINEAR:
        return GL11.GL_LINEAR_MIPMAP_LINEAR;

    case GLContext.WRAPMODE_REPEAT:
        return GL11.GL_REPEAT;
    case GLContext.WRAPMODE_CLAMP_TO_EDGE:
        return GL12.GL_CLAMP_TO_EDGE;
    case GLContext.WRAPMODE_CLAMP_TO_BORDER:
        return GL13.GL_CLAMP_TO_BORDER;

    case GLContext.GL_MAX_FRAGMENT_UNIFORM_COMPONENTS:
        return GL20.GL_MAX_FRAGMENT_UNIFORM_COMPONENTS;
    case GLContext.GL_MAX_FRAGMENT_UNIFORM_VECTORS:
        return GL41.GL_MAX_FRAGMENT_UNIFORM_VECTORS;
    case GLContext.GL_MAX_TEXTURE_IMAGE_UNITS:
        return GL20.GL_MAX_TEXTURE_IMAGE_UNITS;
    case GLContext.GL_MAX_TEXTURE_SIZE:
        return GL11.GL_MAX_TEXTURE_SIZE;
    case GLContext.GL_MAX_VARYING_COMPONENTS:
        return GL30.GL_MAX_VARYING_COMPONENTS;
    case GLContext.GL_MAX_VARYING_VECTORS:
        return GL41.GL_MAX_VARYING_VECTORS;
    case GLContext.GL_MAX_VERTEX_ATTRIBS:
        return GL20.GL_MAX_VERTEX_ATTRIBS;
    case GLContext.GL_MAX_VERTEX_UNIFORM_COMPONENTS:
        return GL20.GL_MAX_VERTEX_UNIFORM_COMPONENTS;
    case GLContext.GL_MAX_VERTEX_UNIFORM_VECTORS:
        return GL41.GL_MAX_VERTEX_UNIFORM_VECTORS;
    case GLContext.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:
        return GL20.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS;

    default:/*  www .j a v a2 s . co m*/
        // don't know how to translate, just hope for the best
        return value;
    }
}

From source file:de.kitsunealex.projectx.client.render.block.RenderHelper.java

License:Open Source License

protected int[] disableMipmap() {
    int min = GL11.glGetTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER);
    int mag = GL11.glGetTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER);
    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);
    return new int[] { min, mag };
}

From source file:edu.csun.ecs.cs.multitouchj.ui.graphic.image.TextureHandler.java

License:Apache License

public Texture generateTexture(Image image) {
    Integer textureId = generateTextureId();
    ByteBuffer imageData = prepareImage(image);

    GL11.glEnable(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT);
    GL11.glBindTexture(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT, textureId.intValue());

    GL11.glTexParameteri(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT, GL11.GL_TEXTURE_MIN_FILTER,
            GL11.GL_NEAREST);
    GL11.glTexParameteri(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT, GL11.GL_TEXTURE_MAG_FILTER,
            GL11.GL_NEAREST);/* w w w  .j  a v a  2  s .  co  m*/
    // GL11.glTexParameteri(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT,
    // GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
    // GL11.glTexParameteri(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT,
    // GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
    GL11.glTexImage2D(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT, 0,
            (image.hasAlpha()) ? GL11.GL_RGBA8 : GL11.GL_RGB8, image.getWidth(), image.getHeight(), 0,
            (image.hasAlpha()) ? GL11.GL_RGBA : GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, imageData);

    System.out.println("Texture generated: " + textureId);

    return new Texture(textureId, image);
}

From source file:eu.over9000.veya.rendering.Shadow.java

License:Open Source License

public void init() {
    depthMap = GL11.glGenTextures();//  w  w w.j a va2 s  .  c o m
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, depthMap);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_DEPTH_COMPONENT, SHADOW_WIDTH, SHADOW_HEIGHT, 0,
            GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, (ByteBuffer) null);
    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);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL13.GL_CLAMP_TO_BORDER);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL13.GL_CLAMP_TO_BORDER);

    shadowFBO = GL30.glGenFramebuffers();
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, shadowFBO);
    GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL11.GL_TEXTURE_2D, depthMap, 0);
    GL11.glDrawBuffer(GL11.GL_NONE);
    GL11.glReadBuffer(GL11.GL_NONE);
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
}

From source file:eu.over9000.veya.util.TextureLoader.java

License:Open Source License

public static int loadBlockTexture(final int textureUnit) {

    final InputStream in = TextureLoader.class.getResourceAsStream("/textures/blocks.png");
    ByteBuffer convertedBuffer = null;
    int sourceTexWidth = 0;
    int sourceTexHeight = 0;
    int texCount = 0;

    try {/*from  w  w w.  ja  v a 2 s . co  m*/
        // Link the PNG decoder to this stream
        final PNGDecoder decoder = new PNGDecoder(in);

        // Get the width and height of the texture
        sourceTexWidth = decoder.getWidth();
        sourceTexHeight = decoder.getHeight();

        texCount = sourceTexWidth / TextureLoader.TEXTURE_WIDTH
                * (sourceTexHeight / TextureLoader.TEXTURE_WIDTH);

        // Decode the PNG file in a ByteBuffer
        final ByteBuffer buf = ByteBuffer.allocateDirect(4 * decoder.getWidth() * decoder.getHeight());
        decoder.decode(buf, decoder.getWidth() * 4, Format.RGBA);
        buf.flip();

        convertedBuffer = TextureLoader.convertBuffer(buf, sourceTexWidth, sourceTexHeight);

        in.close();

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

    // Create a new texture object in memory and bind it
    final int texId = GL11.glGenTextures();
    GL13.glActiveTexture(textureUnit);
    GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, texId);

    // All RGB bytes are aligned to each other and each component is 1 byte
    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);

    // Upload the texture model and generate mip maps (for scaling)
    // GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, tWidth, tHeight, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buf);
    GL12.glTexImage3D(GL30.GL_TEXTURE_2D_ARRAY, 0, GL11.GL_RGBA, TextureLoader.TEXTURE_WIDTH,
            TextureLoader.TEXTURE_HEIGHT, texCount, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, convertedBuffer);
    GL30.glGenerateMipmap(GL30.GL_TEXTURE_2D_ARRAY);

    // Setup the ST coordinate system
    GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
    GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);

    // Setup what to do when the texture has to be scaled
    GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);

    org.lwjgl.opengl.Util.checkGLError();

    System.out
            .println("loading block texture, id=" + texId + ", w=" + sourceTexWidth + ", h=" + sourceTexHeight);

    GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, 0);

    return texId;
}

From source file:fi.conf.ae.gl.texture.GLTextureRoutines.java

License:LGPL

/**
 * Request unused OpenGL texture ID's.//from ww  w . j av  a2s.  co  m
 * 
 * @param count - How many texture IDs are being requested.
 * @return Requested texture ID's as integer array.
 */
public static int[] allocateGLTextureIDs(int count) {
    if (count > textureIDbuffer.capacity()) {
        allocateNewTextureIDBuffer(count);
    }

    textureIDbuffer.clear();
    textureIDbuffer.limit(count);

    GL11.glGenTextures(textureIDbuffer);

    int[] textureIDs = new int[count];

    for (int i = 0; i < count; i++) {
        if (!textureIDbuffer.hasRemaining())
            break;
        textureIDs[i] = textureIDbuffer.get();

        // preset this texture's minification and magnification filter
        int prevTextureID = bindTexture(textureIDs[i]);
        //         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);
        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_NEAREST);

        bindTexture(prevTextureID);
    }

    return textureIDs;
}

From source file:fr.guillaume.prive.viper.core.model.texture.PNGTextureLoader.java

public static int loadTexture(String filename, int textureUnit) {
    ByteBuffer buf = null;/*from www . ja v  a 2s .  c  o m*/
    int tWidth = 0;
    int tHeight = 0;

    try (InputStream in = new FileInputStream(filename)) {
        PNGDecoder decoder = new PNGDecoder(in);

        tWidth = decoder.getWidth();
        tHeight = decoder.getHeight();

        buf = ByteBuffer.allocateDirect(4 * decoder.getWidth() * decoder.getHeight());
        decoder.decode(buf, decoder.getWidth() * 4, Format.RGBA);
        buf.flip();
        in.close();
    } catch (IOException e) {
        throw new IllegalStateException("PNG file i/o error", e);
    }

    // Create a new texture object in memory and bind it
    int texId = GL11.glGenTextures();
    GL13.glActiveTexture(textureUnit);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId);

    // All RGB bytes are aligned to each other and each component is 1 byte
    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);

    // Upload the texture data and generate mip maps (for scaling)
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA16, tWidth, tHeight, 0, GL11.GL_RGBA,
            GL11.GL_UNSIGNED_BYTE, buf);
    GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);

    // Setup the ST coordinate system
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);

    // Setup what to do when the texture has to be scaled
    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_LINEAR_MIPMAP_LINEAR);

    GraphicMotor.exitOnGLError("loadPNGTexture");

    return texId;
}

From source file:fr.ign.cogit.geoxygene.appli.gl.ImageColormap.java

License:Open Source License

/**
 * @return the generated texture id//from   w  w  w. j a v  a  2 s.com
 */
@Override
public final Integer getTextureId() {
    if (this.textureId < 0) {
        // Declaration and initialization
        int target = GL_TEXTURE_2D;
        int levels = 0; // MipMap disabled

        // We generate a texture ID
        this.textureId = glGenTextures();

        // We bind the texture
        glBindTexture(target, this.textureId);

        // Give the buffer to the GPU
        ByteBuffer bufferColormap = ByteBuffer.allocateDirect(nbPoints * 2 * 4 * 4);
        bufferColormap.order(ByteOrder.nativeOrder());

        // In order, we send first colors and then associated values
        for (int i = 0; i < nbPoints; i++) {
            for (int j = 0; j < 4; j++) {
                bufferColormap.putFloat((float) color[i][j]);
            }
        }
        for (int i = 0; i < nbPoints; i++) {
            for (int j = 0; j < 4; j++) {
                bufferColormap.putFloat((float) value[i]);
            }
        }
        bufferColormap.rewind();

        glTexImage2D(target, levels, GL30.GL_RGBA32F, nbPoints, 2, 0, GL11.GL_RGBA, GL11.GL_FLOAT,
                bufferColormap);

        // TODO : useful ?
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);

        // TODO : unload buffer, is it working ?
        bufferColormap.clear();

    }

    // Return the texture ID so we can bind it later again
    return this.textureId;
}

From source file:game.engine.gfx.Texture.java

License:Open Source License

/**
 * Constructor.//from   w  w  w.  j a  v a  2s .c om
 * 
 * Note that this constructor changes the currently active texture unit
 * to GL_TEXTURE_2D to set the texture parameters.
 * 
 * @param slickTexture the wrapped Slick texture
 */
public Texture(final org.newdawn.slick.opengl.Texture slickTexture) {
    this.slickTexture = slickTexture;
    glBindTexture();
    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);
    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);
}

From source file:game.states.State_MENU_DEATHSCREEN.java

License:Open Source License

@Override
protected void Init() {
    int ButtonStartX = 930;
    int ButtonStartY = 224;
    int Spacing = 90;
    try {//ww w . ja va2 s  .c o  m
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        Texture button2 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/MenuButton.png"), false,
                GL11.GL_NEAREST);
        GUI.AddButton(ButtonStartX, ButtonStartY + Spacing * 1, button2.getImageWidth(),
                button2.getImageHeight(), button2);
        Texture button3 = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/QuitButton.png"), false,
                GL11.GL_NEAREST);
        GUI.AddButton(ButtonStartX, ButtonStartY + Spacing * 2, button3.getImageWidth(),
                button3.getImageHeight(), button3);
        BackGroundImage = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("res/Materials/GUI/Backgrounds/DeathScreen.png"));
    } catch (IOException e) {
        e.printStackTrace();
    }

}