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.getspout.spout.config.MipMapUtils.java

License:Open Source License

public static void onTick(int texture, float targetFade, float currentFade) {
    GL11.glPushMatrix();/*from  www .  j  a  va 2 s. c om*/
    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 . j a v  a 2 s. c o  m
    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  2 s  .c om*/
    }
    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();// ww  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.jmangos.tools.openGL.TextureLoader.java

License:Open Source License

/**
 * Load a texture into OpenGL from a image reference on disk.
 * //  w  w w .java2s .c  o  m
 * @param resourceName
 *        The location of the resource to load
 * @param target
 *        The GL target to load the texture against
 * @param dstPixelFormat
 *        The pixel format of the screen
 * @param minFilter
 *        The minimising filter
 * @param magFilter
 *        The magnification filter
 * @return The loaded texture
 * @throws IOException
 *         Indicates a failure to access the resource
 */
public Texture getTexture(final String resourceName, final boolean injar, final int target,
        final int dstPixelFormat, final int minFilter, final int magFilter) throws IOException {

    int srcPixelFormat = 0;

    // create the texture ID for this texture
    final int textureID = createTextureID();
    final Texture texture = new Texture(target, textureID);

    // bind this texture
    GL11.glBindTexture(target, textureID);

    final BufferedImage bufferedImage = loadImage(resourceName, injar);
    texture.setWidth(bufferedImage.getWidth());
    texture.setHeight(bufferedImage.getHeight());

    if (bufferedImage.getColorModel().hasAlpha()) {
        srcPixelFormat = GL11.GL_RGBA;
    } else {
        srcPixelFormat = GL11.GL_RGB;
    }

    // convert that image into a byte buffer of texture data
    final ByteBuffer textureBuffer = convertImageData(bufferedImage, texture);

    if (target == GL11.GL_TEXTURE_2D) {
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_MIN_FILTER, minFilter);
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_MAG_FILTER, magFilter);
    }

    // produce a texture from the byte buffer
    /*
     * GL11.glTexImage2D(target, 0, dstPixelFormat,
     * get2Fold(bufferedImage.getWidth()),
     * get2Fold(bufferedImage.getHeight()), 0, srcPixelFormat,
     * GL11.GL_UNSIGNED_BYTE,
     * textureBuffer );
     */

    GLU.gluBuild2DMipmaps(target, dstPixelFormat, get2Fold(bufferedImage.getWidth()),
            get2Fold(bufferedImage.getHeight()), srcPixelFormat, GL11.GL_UNSIGNED_BYTE, textureBuffer);

    return texture;
}

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

License:Open Source License

/**
 * Load a texture into OpenGL from a BufferedImage
 * //from   w w  w .  j a v  a2  s .com
 * @param resourceName
 *        The location of the resource to load
 * @param target
 *        The GL target to load the texture against
 * @param dstPixelFormat
 *        The pixel format of the screen
 * @param minFilter
 *        The minimising filter
 * @param magFilter
 *        The magnification filter
 * @return The loaded texture
 * @throws IOException
 *         Indicates a failure to access the resource
 */
public Texture getTexture(final BufferedImage resourceimage, final int target, final int dstPixelFormat,
        final int minFilter, final int magFilter) throws IOException {

    int srcPixelFormat = 0;

    // create the texture ID for this texture
    final int textureID = createTextureID();
    final Texture texture = new Texture(target, textureID);

    // bind this texture
    GL11.glBindTexture(target, textureID);

    final BufferedImage bufferedImage = resourceimage;
    texture.setWidth(bufferedImage.getWidth());
    texture.setHeight(bufferedImage.getHeight());

    if (bufferedImage.getColorModel().hasAlpha()) {
        srcPixelFormat = GL11.GL_RGBA;
    } else {
        srcPixelFormat = GL11.GL_RGB;
    }

    // convert that image into a byte buffer of texture data
    final ByteBuffer textureBuffer = convertImageData(bufferedImage, texture);

    if (target == GL11.GL_TEXTURE_2D) {
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_MIN_FILTER, minFilter);
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_MAG_FILTER, magFilter);
    }

    // produce a texture from the byte buffer
    /*
     * GL11.glTexImage2D(target, 0, dstPixelFormat,
     * get2Fold(bufferedImage.getWidth()),
     * get2Fold(bufferedImage.getHeight()), 0, srcPixelFormat,
     * GL11.GL_UNSIGNED_BYTE,
     * textureBuffer );
     */

    GLU.gluBuild2DMipmaps(target, dstPixelFormat, get2Fold(bufferedImage.getWidth()),
            get2Fold(bufferedImage.getHeight()), srcPixelFormat, GL11.GL_UNSIGNED_BYTE, textureBuffer);

    return texture;
}

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

License:Open Source License

/**
 * Load a texture into OpenGL from a BufferedImage
 * /*from   w w w .j  a  v  a2s.  c  o m*/
 * @param resourceName
 *        The location of the resource to load
 * @param target
 *        The GL target to load the texture against
 * @param dstPixelFormat
 *        The pixel format of the screen
 * @param minFilter
 *        The minimising filter
 * @param magFilter
 *        The magnification filter
 * @return The loaded texture
 * @throws IOException
 *         Indicates a failure to access the resource
 */
public Texture getNMMTexture(final BufferedImage resourceimage, final int target, final int dstPixelFormat,
        final int minFilter, final int magFilter) throws IOException {

    int srcPixelFormat = 0;

    // create the texture ID for this texture
    final int textureID = createTextureID();
    final Texture texture = new Texture(target, textureID);

    // bind this texture
    GL11.glBindTexture(target, textureID);

    final BufferedImage bufferedImage = resourceimage;
    texture.setWidth(bufferedImage.getWidth());
    texture.setHeight(bufferedImage.getHeight());

    if (bufferedImage.getColorModel().hasAlpha()) {
        srcPixelFormat = GL11.GL_RGBA;
    } else {
        srcPixelFormat = GL11.GL_RGB;
    }

    // convert that image into a byte buffer of texture data
    final ByteBuffer textureBuffer = convertImageData(bufferedImage, texture);

    if (target == GL11.GL_TEXTURE_2D) {
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_MIN_FILTER, minFilter);
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_MAG_FILTER, magFilter);
    }

    // produce a texture from the byte buffer
    GL11.glTexImage2D(target, 0, dstPixelFormat, get2Fold(bufferedImage.getWidth()),
            get2Fold(bufferedImage.getHeight()), 0, srcPixelFormat, GL11.GL_UNSIGNED_BYTE, textureBuffer);

    return texture;
}

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 w w.j av a 2s  .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);
}

From source file:org.jtrfp.mtmx.internal.TextureLoader.java

License:Open Source License

@Override
public ITexture load(RawImage rawImage) throws EngineException {
    BufferedImage bufferedImage = null;

    try {/*from   ww  w . j  a v a2 s  .com*/
        bufferedImage = rawImage.toImage();
    } catch (FileStoreException e) {
        throw new EngineException("Could not convert texture image.", e);
    }

    final int type = GL11.GL_TEXTURE_2D;
    final int width = bufferedImage.getWidth();
    final int height = bufferedImage.getHeight();

    int textureId = createTextureId();
    Texture texture = new Texture(type, textureId, width, height);
    GL11.glBindTexture(type, textureId); // really neccessary here?

    ByteBuffer buffer = makeByteBuffer(bufferedImage, width, height);
    GL11.glTexParameteri(type, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    GL11.glTexParameteri(type, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
    GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);
    GL11.glTexImage2D(type, 0, GL11.GL_RGB, width, height, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, buffer);
    System.out.println("Created texture " + textureId);
    return texture;
}

From source file:org.oscim.gdx.LwjglGL20.java

License:Apache License

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