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:org.fenggui.render.lwjgl.LWJGLOpenGL.java

License:Open Source License

public void setupStateVariables(boolean depthTestEnabled) {
    GL11.glEnable(GL11.GL_BLEND);/*from  w  ww .ja  v  a2  s .  com*/
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    if (depthTestEnabled)
        GL11.glDisable(GL11.GL_DEPTH_TEST);

    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_FOG);
    GL11.glDisable(GL11.GL_DITHER);

    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    //GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL);
    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
    GL11.glEnable(GL11.GL_NORMALIZE);
    GL11.glDisable(GL11.GL_LINE_STIPPLE);

    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.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_DECAL);

    //GL11.glDisable(GL11.GL_TEXTURE_GEN_S);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_NORMALIZE);
    GL11.glFrontFace(GL11.GL_CW);
    GL11.glCullFace(GL11.GL_BACK);
    // disabling textures after setting state values. They would
    // be ignored otherwise (i think)
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_TEXTURE_1D);

}

From source file:org.getspout.spout.config.MipMapUtils.java

License:Open Source License

public static void update(int texture) {
    GL11.glPushMatrix();/*from  w ww .ja  v a2  s. com*/
    if (MipMapUtils.mode == 3) {
        MipMapUtils.updateTerrain = ConfigReader.mipmapsPercent > 0F;
        GL11.glBindTexture(3553, texture);
        if (ConfigReader.mipmapsPercent > 0F) {
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);
        } else {
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
        }
        GL11.glPopMatrix();
        return;
    }

    if (ConfigReader.mipmapsPercent > 0F) {
        MipMapUtils.updateTerrain = true;

        GL11.glBindTexture(3553, texture);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);
    }
    GL11.glPopMatrix();
}

From source file:org.getspout.spout.config.MipMapUtils.java

License:Open Source License

public static void onTick(int texture, float targetFade, float currentFade) {
    GL11.glPushMatrix();//w w w  . j a  v a2s . c o m
    GL11.glBindTexture(3553, texture);

    if (targetFade != currentFade) {
        if (targetFade < currentFade) {
            currentFade -= 0.01f;
            if (currentFade <= targetFade) {
                currentFade = targetFade;
            }
        } else {
            currentFade += 0.01f;
            if (currentFade >= targetFade) {
                currentFade = targetFade;
            }
        }

        if (currentFade <= 0.0f) {
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
            GL11.glAlphaFunc(GL11.GL_GREATER, 0.01F); //default blend state

            updateTerrain = false;
            GL11.glPopMatrix();
            return;
        } else {
            GL11.glTexEnvf(GL14.GL_TEXTURE_FILTER_CONTROL, GL14.GL_TEXTURE_LOD_BIAS,
                    getMipmapLevels(texture) * (currentFade - 1.0f));
        }
    }

    switch (mode) {
    case 1:
        GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
        break;

    case 2:
        EXTFramebufferObject.glGenerateMipmapEXT(GL11.GL_TEXTURE_2D);
        break;
    }
    GL11.glAlphaFunc(GL11.GL_GEQUAL, 0.3F); //more strict blend state
    GL11.glPopMatrix();
}

From source file:org.getspout.spout.gui.about.GuiAbout.java

License:LGPL

@Override
public void drawScreen(int x, int y, float z) {
    super.drawBackground(0);
    GL11.glDisable(2896 /*GL_LIGHTING*/);
    GL11.glDisable(2912 /*GL_FOG*/);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    bg.setTopColor(background1);//  ww w .  ja va  2s.  c  om
    bg.setBottomColor(background2);
    bg.setY(30);
    bg.setHeight(this.height - 50);
    bg.setX(0);
    bg.setWidth(this.width - 12);
    bg.render();

    scrollArea.setY(30);
    scrollArea.setHeight(this.height - 50);
    scrollArea.setX(this.width - 12);
    scrollArea.setWidth(16);
    scrollArea.setTopColor(scrollBarColor);
    scrollArea.setBottomColor(scrollBarColor2);
    scrollArea.render();

    drawScaledString("What is Spoutcraft?", this.width / 2 - 200, this.height, 0xffffff);
    drawScaledString("Spoutcraft is a modified Minecraft client", this.width / 2 - 200, this.height + 10,
            0x808080);
    drawScaledString("that plays exactly like the official game.", this.width / 2 - 200, this.height + 20,
            0x808080);
    drawScaledString("Its goal is to give modders an easy to", this.width / 2 - 200, this.height + 30,
            0x808080);
    drawScaledString("use development platform for building", this.width / 2 - 200, this.height + 40, 0x808080);
    drawScaledString("and distributing mods, as well as a ", this.width / 2 - 200, this.height + 50, 0x808080);
    drawScaledString("providing a rich experience for players.", this.width / 2 - 200, this.height + 60,
            0x808080);

    drawScaledString("What is Spout?", this.width / 2 - 200, this.height + 90, 0xffffff);
    drawScaledString("Spout is a Bukkit plugin that gives ", this.width / 2 - 200, this.height + 100, 0x808080);
    drawScaledString("developers an advanced server", this.width / 2 - 200, this.height + 110, 0x808080);
    drawScaledString("development platform that allows previouly ", this.width / 2 - 200, this.height + 120,
            0x808080);
    drawScaledString("impossible tasks, such as custom items,", this.width / 2 - 200, this.height + 130,
            0x808080);
    drawScaledString("blocks, mobs, animals, and vehicles. ", this.width / 2 - 200, this.height + 140,
            0x808080);

    drawScaledString("Who is SpoutDev?", this.width / 2 - 200, this.height + 170, 0xffffff);
    drawScaledString("SpoutDev is the team behind Spout, ", this.width / 2 - 200, this.height + 180, 0x808080);
    drawScaledString("SpoutAPI, Spoutcraft and SpoutcraftAPI.", this.width / 2 - 200, this.height + 190,
            0x808080);

    drawScaledString("Sponsors", this.width / 2 + 30, this.height, 0xffffff);

    drawScaledString("Team", this.width / 2 + 30, this.height + 90, 0xffffff);
    drawScaledString("Afforess - Lead Developer", this.width / 2 + 30, this.height + 100, 0x808080);
    drawScaledString("Wulfspider - Co-Lead & Support", this.width / 2 + 30, this.height + 110, 0x808080);
    drawScaledString("alta189 - Co-Lead & Developer", this.width / 2 + 30, this.height + 120, 0x808080);
    drawScaledString("Top_Cat - Developer", this.width / 2 + 30, this.height + 130, 0x808080);
    drawScaledString("Raphfrk - Developer", this.width / 2 + 30, this.height + 140, 0x808080);
    drawScaledString("narrowtux - Developer", this.width / 2 + 30, this.height + 150, 0x808080);
    drawScaledString("Olloth - Developer", this.width / 2 + 30, this.height + 160, 0x808080);
    drawScaledString("Email: dev@getspout.org", this.width / 2 + 30, this.height + 170, 0x808080);
    drawScaledString("Website: getspout.org", this.width / 2 + 30, this.height + 180, 0x808080);
    drawScaledString("IRC: #spout in Esper.net", this.width / 2 + 30, this.height + 190, 0x808080);

    drawScaledString("Move along, nothing to see here.", 40, this.height * 5, 0x808080);

    GL11.glDisable(2896 /*GL_LIGHTING*/);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    int var11 = this.mc.renderEngine.getTexture("/gui/allitems.png");
    this.mc.renderEngine.bindTexture(var11);
    RenderUtil.drawTexturedModalRectangle(this.width - 14, getInvertedScaledHeight(this.height - 5), 0, 208, 16,
            16, 0f);

    GL11.glDisable(2912 /*GL_FOG*/);
    GL11.glDisable(2929 /*GL_DEPTH_TEST*/);
    this.overlayBackground(0, 30, 255, 255);
    this.overlayBackground(this.height - 50, this.height, 255, 255);

    drawCenteredString(this.fontRenderer, "About", this.width / 2, 16, 0xffffff);

    GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, this.mc.renderEngine.getTexture("/title/mclogo.png"));
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glScalef(0.4f, 0.4f, 0.4f);
    this.drawTexturedModalRect((int) (0.23f * this.width), (int) (this.height * 2.1f), 0, 0, 155, 44);
    this.drawTexturedModalRect((int) (0.23f * this.width) + 155, (int) (this.height * 2.1f), 0, 45, 155, 44);
    GL11.glScalef(1 / .4f, 1 / .4f, 1 / .4f); //undo scale above

    if (textureBinding != null) {
        GL11.glPushMatrix();
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glDepthMask(false);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glTranslatef((0.685f * this.width), (this.height * 0.83f), 0); // moves texture into place
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureBinding.getTextureID());
        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);
        Tessellator tessellator = Tessellator.instance;
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(0.0D, 32, -90, 0.0D, 0.0D); // draw corners
        tessellator.addVertexWithUV(128, 32, -90, textureBinding.getWidth(), 0.0D);
        tessellator.addVertexWithUV(128, 0.0D, -90, textureBinding.getWidth(), textureBinding.getHeight());
        tessellator.addVertexWithUV(0.0D, 0.0D, -90, 0.0D, textureBinding.getHeight());
        tessellator.draw();
        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glPopMatrix();
    }

    drawString(this.fontRenderer, "Beta 1.8.1", (int) (this.width * 0.097f), this.height - 20, 0xffffff);
    drawString(this.fontRenderer, "Copyright Mojang AB", (int) (this.width * 0.097f), this.height - 10,
            0x808080);

    drawString(this.fontRenderer, SpoutClient.getClientVersion().toString(), (int) (this.width * 0.8713f),
            this.height - 20, 0xffffff);
    drawString(this.fontRenderer, "Licensed under LGPLv3", (int) (this.width * 0.695f), this.height - 10,
            0x808080);

    getControlList().get(0).xPosition = this.width / 2 - 45;
    getControlList().get(0).yPosition = this.height - 25;
    getControlList().get(0).drawButton(this.mc, x, y);
    //super.drawScreen(x, x, z);

    //Shadow magic
    GL11.glEnable(3042 /*GL_BLEND*/);
    GL11.glBlendFunc(770, 771);
    GL11.glDisable(3008 /*GL_ALPHA_TEST*/);
    GL11.glShadeModel(7425 /*GL_SMOOTH*/);
    GL11.glDisable(3553 /*GL_TEXTURE_2D*/);
    Tessellator var16 = Tessellator.instance;
    byte var19 = 4;
    var16.startDrawingQuads();
    var16.setColorRGBA_I(0, 0);
    var16.addVertexWithUV(0, (double) (30 + var19), 0.0D, 0.0D, 1.0D);
    var16.addVertexWithUV(this.width - 12, (double) (30 + var19), 0.0D, 1.0D, 1.0D);
    var16.setColorRGBA_I(0, 255);
    var16.addVertexWithUV(this.width - 12, 30, 0.0D, 1.0D, 0.0D);
    var16.addVertexWithUV(0, 30, 0.0D, 0.0D, 0.0D);
    var16.draw();
    var16.startDrawingQuads();
    var16.setColorRGBA_I(0, 255);
    var16.addVertexWithUV(0, this.height - 50, 0.0D, 0.0D, 1.0D);
    var16.addVertexWithUV(this.width - 12, this.height - 50, 0.0D, 1.0D, 1.0D);
    var16.setColorRGBA_I(0, 0);
    var16.addVertexWithUV(this.width - 12, (double) (this.height - 50 - var19), 0.0D, 1.0D, 0.0D);
    var16.addVertexWithUV(0, (double) (this.height - 50 - var19), 0.0D, 0.0D, 0.0D);
    var16.draw();

}

From source file:org.getspout.spout.gui.GenericTexture.java

License:Open Source License

@Override
public void render() {
    String path = CustomTextureManager.getTextureFromUrl(getUrl());
    if (path == null) {
        return;/*from  w w  w .j a v  a  2s  .  co m*/
    }
    if (texture == null) {
        texture = CustomTextureManager.getTextureFromPath(path);
        if (texture == null) {
            return;
        }
    }
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(false);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glTranslatef((float) getScreenX(), (float) getScreenY(), 0); //moves texture into place
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getTextureID());
    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);
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(0.0D, getHeight(), -90, 0.0D, 0.0D); //draw corners
    tessellator.addVertexWithUV(getWidth(), getHeight(), -90, texture.getWidth(), 0.0D);
    tessellator.addVertexWithUV(getWidth(), 0.0D, -90, texture.getWidth(), texture.getHeight());
    tessellator.addVertexWithUV(0.0D, 0.0D, -90, 0.0D, texture.getHeight());
    tessellator.draw();
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}

From source file:org.getspout.spout.gui.server.GuiServerInfo.java

License:Open Source License

@Override
public void drawScreen(int var1, int var2, float var3) {
    this.drawDefaultBackground();

    if (flag != null) {
        GL11.glPushMatrix();//from w  w w .  j a  va  2  s.co  m
        GL11.glTranslatef(this.width / 2 + 150, this.height / 2 - 84, 0);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glDepthMask(false);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, flag.getTextureID());
        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);
        Tessellator tessellator = Tessellator.instance;
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(0.0D, 6, -90, 0.0D, 0.0D); // draw corners
        tessellator.addVertexWithUV(9, 6, -90, flag.getWidth(), 0.0D);
        tessellator.addVertexWithUV(9, 0.0D, -90, flag.getWidth(), flag.getHeight());
        tessellator.addVertexWithUV(0.0D, 0.0D, -90, 0.0D, flag.getHeight());
        tessellator.draw();
        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glPopMatrix();
    } else {
        flag = CustomTextureManager.getTextureFromUrl(
                "http://servers.getspout.org/images/flags/" + info.country.toLowerCase() + ".png");
    }

    if (image != null) {
        GL11.glPushMatrix();
        GL11.glTranslatef(this.width / 2 - 110 - (image.getImageWidth() / 4),
                this.height / 2 - 20 - (image.getImageHeight() / 4), 0);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glDepthMask(false);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, image.getTextureID());
        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);
        Tessellator tessellator = Tessellator.instance;
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(0.0D, image.getImageHeight() / 2, -90, 0.0D, 0.0D); // draw corners
        tessellator.addVertexWithUV(image.getImageWidth() / 2, image.getImageHeight() / 2, -90,
                image.getWidth(), 0.0D);
        tessellator.addVertexWithUV(image.getImageWidth() / 2, 0.0D, -90, image.getWidth(), image.getHeight());
        tessellator.addVertexWithUV(0.0D, 0.0D, -90, 0.0D, image.getHeight());
        tessellator.draw();
        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glPopMatrix();
    } else {
        image = CustomTextureManager.getTextureFromUrl(url);
    }

    this.drawString(SpoutClient.getHandle().fontRenderer, "Server IP:Port", this.width / 2 - 20,
            this.height / 2 - 95, 0xFFFFFF);
    this.drawString(SpoutClient.getHandle().fontRenderer, info.getFullIp(), this.width / 2 - 10,
            this.height / 2 - 85, 0xA0A0A0);

    this.drawString(SpoutClient.getHandle().fontRenderer, "Name", this.width / 2 - 20, this.height / 2 - 70,
            0xFFFFFF);
    this.drawString(SpoutClient.getHandle().fontRenderer, info.name, this.width / 2 - 10, this.height / 2 - 60,
            0xA0A0A0);

    this.drawString(SpoutClient.getHandle().fontRenderer, "Country", this.width / 2 + 120, this.height / 2 - 95,
            0xFFFFFF);
    this.drawString(SpoutClient.getHandle().fontRenderer, info.country, this.width / 2 + 130,
            this.height / 2 - 85, 0xA0A0A0);

    this.drawString(SpoutClient.getHandle().fontRenderer, "Players", this.width / 2 + 120, this.height / 2 - 70,
            0xFFFFFF);
    this.drawString(SpoutClient.getHandle().fontRenderer, info.players + "/" + info.maxPlayers,
            this.width / 2 + 130, this.height / 2 - 60, 0xA0A0A0);

    this.drawString(SpoutClient.getHandle().fontRenderer, "Response", this.width / 2 - 20, this.height / 2 - 45,
            0xFFFFFF);
    this.drawString(SpoutClient.getHandle().fontRenderer, info.msg + ChatColor.GRAY + " (" + info.ping + "ms)",
            this.width / 2 - 10, this.height / 2 - 35, 0xA0A0A0);

    this.drawString(SpoutClient.getHandle().fontRenderer, "Website", this.width / 2 - 20, this.height / 2 - 20,
            0xFFFFFF);
    this.drawString(SpoutClient.getHandle().fontRenderer, site, this.width / 2 - 10, this.height / 2 - 10,
            hoveringSite ? 0x0099FF : 0x40FFFF);

    this.drawString(SpoutClient.getHandle().fontRenderer, "Forum Post", this.width / 2 - 20,
            this.height / 2 + 5, 0xFFFFFF);
    this.drawString(SpoutClient.getHandle().fontRenderer, forum, this.width / 2 - 10, this.height / 2 + 15,
            hoveringForum ? 0x0099FF : 0x40FFFF);

    this.drawString(SpoutClient.getHandle().fontRenderer, "Description", this.width / 2 - 20,
            this.height / 2 + 30, 0xFFFFFF);
    this.drawString(SpoutClient.getHandle().fontRenderer, info.description, this.width / 2 - 10,
            this.height / 2 + 40, 0xA0A0A0);

    super.drawScreen(var1, var2, var3);
}

From source file:org.getspout.spout.io.CustomTextureManager.java

License:Open Source License

public static Texture getTextureFromPath(String path) {
    if (!textures.containsKey(path)) {
        Texture texture = null;/*w  w w. j av a2s.c om*/
        try {
            //System.out.println("Loading Texture: " + path);
            FileInputStream stream = new FileInputStream(path);
            texture = TextureLoader.getTexture("PNG", stream, true, GL11.GL_NEAREST);
            stream.close();
        } catch (IOException e) {
        }
        if (texture == null) {
            System.out.println("Error loading texture: " + path);
            return null;
        }
        textures.put(path, texture);
    }
    return textures.get(path);
}

From source file:org.getspout.spout.io.CustomTextureManager.java

License:Open Source License

public static Texture getTextureFromJar(String path) {
    if (!textures.containsKey(path)) {
        Texture texture = null;/*from  w  w w  .  java  2 s. c  om*/
        try {
            //System.out.println("Loading Texture: " + path);
            InputStream stream = Minecraft.class.getResourceAsStream(path);
            texture = TextureLoader.getTexture("PNG", stream, true, GL11.GL_NEAREST);
            stream.close();
        } catch (Exception e) {
        }
        if (texture == null) {
            System.out.println("Error loading texture: " + path);
            return null;
        }
        textures.put(path, texture);
    }
    return textures.get(path);
}

From source file:org.jmangos.tools.openGL.TextureLoader.java

License:Open Source License

/**
 * Load a texture/*from  w  w w.java2s  .c om*/
 * 
 * @param resourceName
 *        The location of the resource to load
 * @return The loaded texture
 * @throws IOException
 *         Indicates a failure to access the resource
 */
public Texture getNMMTexture(final String resourceName, final BufferedImage resourceImage) throws IOException {

    Texture tex = this.table.get(resourceName);

    if (tex != null) {
        return tex;
    }

    tex = getNMMTexture(resourceImage, this.target, // target
            this.dstPixelFormat, // dst pixel format
            GL11.GL_NEAREST, // min filter (unused)
            GL11.GL_LINEAR);

    this.table.put(resourceName, tex);

    return tex;
}

From source file:org.jogamp.glg2d.impl.shader.GL2ES2ImageDrawer.java

License:Apache License

@Override
protected void begin(Texture texture, AffineTransform xform, Color bgcolor) {
    /*/*from   w ww  .  ja va2 s  .  c o  m*/
     * FIXME This is unexpected since we never disable blending, but in some
     * cases it interacts poorly with multiple split panes, scroll panes and the
     * text renderer to disable blending.
     */
    g2d.setComposite(g2d.getComposite());

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

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    texture.bind();

    shader.use(true);

    if (bgcolor == null) {
        white.clear();
        white.put(white_static, 0, 3);
        white.put(g2d.getUniformsObject().colorHook.getAlpha());
        shader.setColor(white);
    } else {
        FloatBuffer rgba = g2d.getUniformsObject().colorHook.getRGBA();
        shader.setColor(rgba);
    }

    if (xform == null) {
        shader.setTransform(g2d.getUniformsObject().transformHook.getGLMatrixData());
    } else {
        shader.setTransform(g2d.getUniformsObject().transformHook.getGLMatrixData(xform));
    }

    shader.setTextureUnit(0);
}