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:rainwarrior.mt100.client.PstFont.java

License:Open Source License

public void bindFontTexture() {
    GL11.glLoadIdentity();//from   www  . j a  va  2  s  .c om
    GL11.glScalef(1F / textureWidth, 1F / textureHeight, 1F);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.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_MIN_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
}

From source file:se.angergard.engine.graphics.FrameBuffer.java

License:Apache License

public FrameBuffer(int width, int height, boolean hasDepth, boolean hasStencil) {
    this.width = width;
    this.height = height;

    if ((width + height) % 4 != 0.0) {
        new Exception("Width + Height must be divisible by 4");
    }/* w  w  w.  j  a  v  a2s  . c  o m*/

    frameBufferID = GL30.glGenFramebuffers();
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, frameBufferID);

    if (hasDepth && hasStencil) {
        depthAndStencilBufferID = GL30.glGenRenderbuffers();
        GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, depthAndStencilBufferID);
        GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL30.GL_DEPTH24_STENCIL8, width, height);
        GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_STENCIL_ATTACHMENT,
                GL30.GL_RENDERBUFFER, depthAndStencilBufferID);
        GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, 0);
    }

    else if (hasDepth) {
        depthBufferID = GL30.glGenRenderbuffers();
        GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, depthBufferID);
        GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL30.GL_DEPTH_COMPONENT32F, width, height);
        GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL30.GL_RENDERBUFFER,
                depthBufferID);
        GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, 0);
    }

    else if (hasStencil) {
        stencilBufferID = GL30.glGenRenderbuffers();
        GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, stencilBufferID);
        GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL30.GL_STENCIL_INDEX16, width, height);
        GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_STENCIL_ATTACHMENT, GL30.GL_RENDERBUFFER,
                stencilBufferID);
        GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, 0);
    }

    colorTexture = GL11.glGenTextures();
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, colorTexture);
    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_MIN_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);

    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, width, height, 0, GL11.GL_RGBA,
            GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);

    GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D,
            colorTexture, 0);

    int result = GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER);
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
    if (result != GL30.GL_FRAMEBUFFER_COMPLETE) {
        if (result == GL30.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT) {
            new Exception("Frame Buffer Error: incomplete attachment").printStackTrace();
        }
        if (result == GL30.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER) {
            new Exception("Frame Buffer Error: incomplete draw buffer").printStackTrace();
        }
        if (result == GL30.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT) {
            new Exception("Frame Buffer Error: missing attachment").printStackTrace();
        }
        if (result == GL30.GL_FRAMEBUFFER_UNSUPPORTED) {
            new Exception("Frame Buffer Error: unsupported combination of formats").printStackTrace();
        }
        if (result == GL30.GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE) {
            new Exception("Frame Buffer Error: incomplete multisample").printStackTrace();
        }
        if (result == GL30.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER) {
            new Exception("Frame Buffer Error: incomplete read buffer").printStackTrace();
        }

        new Exception("frame buffer couldn't be constructed: unknown error " + result).printStackTrace();
    }
    RenderUtil.unbindFrameBuffer();
    RenderUtil.unbindTexture();

    frameBufferShader = new ShaderProgram().createDefault2DShader();
}

From source file:se.angergard.engine.graphics.Texture.java

License:Apache License

private void loadTexture(ByteBuffer buffer, int textureID, int width, int height) {
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);

    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);

    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA,
            GL11.GL_UNSIGNED_BYTE, buffer);

    // Not all computer will support this, fix //TODO
    GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);

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

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

From source file:shadowmage.meim.client.gui.GuiTextureElement.java

License:Open Source License

private void updateTextureContents(BufferedImage image) {
    bindTexture();/*from ww w .  j  a v a 2 s  .  c o m*/
    if (image != null) {
        int size = image.getWidth() * image.getHeight();
        if (bufferSize < size) {
            bufferSize = size;
            dataBuffer = BufferUtils.createIntBuffer(bufferSize);
            inBuff = new int[bufferSize];
            outBuff = new int[bufferSize];
        }
        dataBuffer.clear();
        fillImageArray(image, dataBuffer);
        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);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); //GL11.GL_NEAREST);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); //GL11.GL_NEAREST);
        uploadTextureRGBAInts(dataBuffer, image.getWidth(), image.getHeight());
    }
    resetBoundTexture();
}

From source file:shadowmage.meim.client.texture.TextureManager.java

License:Open Source License

public static void allocateTexture() {
    if (texNum >= 0) {
        GL11.glDeleteTextures(texNum);//from   w ww  . jav a2  s . com
    }
    texNum = GL11.glGenTextures();
    bindTexture();
    for (int i = 0; i < 256 * 256; i++) {
        dataBuffer.put(i, 0xfffffff);
    }
    dataBuffer.rewind();
    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.GL_NEAREST);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); //GL11.GL_NEAREST);
    uploadTextureRGBAInts(dataBuffer, 256, 256);//upload empty data to texture so that it is 'valid'?
    resetBoundTexture();
}

From source file:shadowmage.meim.client.texture.TextureManager.java

License:Open Source License

public static void updateTextureContents(BufferedImage image) {
    bindTexture();//  w ww.  ja v a  2s .c o  m
    if (image != null) {
        int size = image.getWidth() * image.getHeight();
        if (bufferSize < size) {
            bufferSize = size;
            dataBuffer = BufferUtils.createIntBuffer(bufferSize);
            inBuff = new int[bufferSize];
            outBuff = new int[bufferSize];
        }
        dataBuffer.clear();
        fillImageArray(image, dataBuffer);
        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);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); //GL11.GL_NEAREST);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); //GL11.GL_NEAREST);
        uploadTextureRGBAInts(dataBuffer, image.getWidth(), image.getHeight());
    }
    resetBoundTexture();
}

From source file:Src.Framework.Game.java

private void load() {
    //load splash screen and display it before loading everything else
    try {// w ww  .  j  a  va  2s.  co  m
        logo = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/LemonzapLogo.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    } catch (IOException e) {
        e.printStackTrace();
    }
    //bind white before binding any textures
    Color.white.bind();
    logo.bind();
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2d(0, 0);
    GL11.glVertex2i(0, 0);

    GL11.glTexCoord2d(1, 0);
    GL11.glVertex2i(1024, 0);

    GL11.glTexCoord2d(1, 1);
    GL11.glVertex2i(1024, 512);

    GL11.glTexCoord2d(0, 1);
    GL11.glVertex2i(0, 512);
    GL11.glEnd();
    glfwSwapBuffers(window.getWindowHandle());

    //loading resources for main menu
    Audio.loadOpenAL();
    MainMenu.load();
    OptionsMenu.load();
    OptionsAudioMenu.load();

}

From source file:Src.Framework.Menus.MainMenu.java

public static void load() {
    try {/*from  w w w . j  a v  a 2  s  .c om*/
        menuBackground = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/MainMenu.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        title = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/Title.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        singleplayer = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/Singleplayer.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        singleplayerSelected = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/SingleplayerSelected.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        multiplayer = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/Multiplayer.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        multiplayerSelected = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/MultiplayerSelected.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        stageCreator = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/StageCreator.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        stageCreatorSelected = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/StageCreatorSelected.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        options = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/Options.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        optionsSelected = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/OptionsSelected.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        exit = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/Exit.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        exitSelected = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/ExitSelected.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);

    } catch (IOException e) {
        e.printStackTrace();
    }

    //placeholder sounds
    menuMusic = new Audio("Src/Resources/Audio/Music/MMXTitleTheme.wav", true);
    menuChangeSelection = new Audio("Src/Resources/Audio/Sounds/Blip_Select.wav", false);
    menuSelect = new Audio("Src/Resources/Audio/Sounds/blipChoose.wav", false);
}

From source file:Src.Framework.Menus.OptionsAudioMenu.java

public static void load() {
    try {//from w  w w .  j  a  v a2  s .c  o  m
        audioTitle = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/AudioTitle.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        musicVolume = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/MusicVolume.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        musicVolumeSelected = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/MusicVolumeSelected.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        effectVolume = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/EffectVolume.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        effectVolumeSelected = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/EffectVolumeSelected.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        colon = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/Colon.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        colonSelected = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/ColonSelected.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        sliderTrack = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/SliderTrack.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        slider = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/Slider.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);

    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:Src.Framework.Menus.OptionsMenu.java

public static void load() {
    try {//  w w  w  .  ja va2  s .c o  m
        optionsTitle = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/OptionsTitle.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        general = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/General.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        generalSelected = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/GeneralSelected.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        controls = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/Controls.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        controlsSelected = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/ControlsSelected.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        video = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/Video.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        videoSelected = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/VideoSelected.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        audio = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/Audio.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        audioSelected = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/AudioSelected.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        back = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/Back.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        backSelected = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream("Src/Resources/Images/BackSelected.png"));
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);

    } catch (IOException e) {
        e.printStackTrace();
    }
}