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:tectonicus.rasteriser.lwjgl.LwjglTextureUtils.java

License:BSD License

public static int createTexture(BufferedImage imageData, TextureFilter filterMode) {
    imageData = convertToGlFormat(imageData);

    IntBuffer buff = BufferUtils.createIntBuffer(16);
    buff.limit(1);/*from   w w  w  . j  av a 2 s  . com*/
    GL11.glGenTextures(buff);

    int textureId = buff.get();

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
    if (filterMode == TextureFilter.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_NEAREST);
    } else {
        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.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);

    ByteBuffer scratch = ByteBuffer.allocateDirect(4 * imageData.getWidth() * imageData.getHeight());

    Raster raster = imageData.getRaster();
    byte data[] = (byte[]) raster.getDataElements(0, 0, imageData.getWidth(), imageData.getHeight(), null);
    scratch.clear();
    scratch.put(data);
    scratch.rewind();

    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, // Mip level & Internal format
            imageData.getWidth(), imageData.getHeight(), 0, // width, height, border
            GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, // pixel data format
            scratch); // pixel data

    GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, imageData.getWidth(), imageData.getHeight(), GL11.GL_RGBA,
            GL11.GL_UNSIGNED_BYTE, // format, type
            scratch);

    return textureId;
}

From source file:tectonicus.rasteriser.lwjgl.LwjglTextureUtils.java

License:BSD License

public static int createTexture(BufferedImage[] mips, TextureFilter filterMode) {
    IntBuffer buff = BufferUtils.createIntBuffer(16);
    buff.limit(1);/* www.j  a v  a 2 s  .co m*/
    GL11.glGenTextures(buff);

    int textureId = buff.get();

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
    if (filterMode == TextureFilter.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_NEAREST_MIPMAP_LINEAR);
    } else {
        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_MIPMAP_LINEAR);
    }

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

    for (int mip = 0; mip < mips.length; mip++) {
        BufferedImage imageData = mips[mip];
        imageData = convertToGlFormat(imageData);

        ByteBuffer scratch = ByteBuffer.allocateDirect(4 * imageData.getWidth() * imageData.getHeight());

        Raster raster = imageData.getRaster();
        byte data[] = (byte[]) raster.getDataElements(0, 0, imageData.getWidth(), imageData.getHeight(), null);
        scratch.clear();
        scratch.put(data);
        scratch.rewind();

        GL11.glTexImage2D(GL11.GL_TEXTURE_2D, mip, GL11.GL_RGBA, // Mip level & Internal format
                imageData.getWidth(), imageData.getHeight(), 0, // width, height, border
                GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, // pixel data format
                scratch); // pixel data

        //   GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0,
        //         0, 0,
        //         imageData.getWidth(), imageData.getHeight(),
        //         GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE,         // format, type
        //         scratch);
    }

    return textureId;
}

From source file:v9t9.gui.client.swt.gl.TextureLoader.java

License:Open Source License

/**
 * Load a texture//w  w  w.  j  a  v a 2 s  . com
 *
 * @param resourceName The location of the resource to load
 * @return The loaded texture
 * @throws IOException Indicates a failure to access the resource
 */
public Texture getTexture(String resourceName) throws IOException {
    Texture tex = (Texture) table.get(resourceName);

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

    //System.out.println("Loading texture: " + resourceName);

    tex = getTexture(resourceName, GL11.GL_TEXTURE_2D, // target
            GL11.GL_RGBA, // dst pixel format
            GL11.GL_LINEAR, // min filter (unused)
            GL11.GL_NEAREST);

    table.put(resourceName, tex);

    return tex;
}

From source file:vendalenger.port.Command.java

License:Apache License

/**
 * Setup default commands and Editors for Fluffy Console
 *///  w  ww  . j  av a  2s .  co  m
public static void commandSetup() {

    Command.addCommand(new Command("calculate", "Do some math", "^calculate [MATH]" + "\nReturns zK,FVC  VC") {
        @Override
        public String action(String[] args) {
            double sum = 0;
            for (String s : args) {
                try {
                    sum += Double.parseDouble(s);
                } catch (NumberFormatException e) {
                    VD_FlConsole.println("addition: " + s + " is not a valid number.");
                }
            }
            return String.valueOf(sum);
        }
    }, false);

    Command.addCommand(new Command("clr", "Clear the console screen.", "I don't like that.") {
        @Override
        public String action(String[] args) {
            VD_FlConsole.clear();
            return "";
        }
    }, false);

    Command.addCommand(new Command("ef.regtex", "Register a texture",
            "^ef.regtex [id] [file]" + "\nid: Id - The Id the texture will be identified by. "
                    + "\nfile: path - Path to image data. gamename:dir/file"
                    + "\n\nThis command will replace a texture if the same id exists") {
        @Override
        public String action(String[] args) {

            KLoader.registerTexture(args[1], args[0], GL11.GL_NEAREST, GL11.GL_NEAREST, GL11.GL_CLAMP,
                    GL11.GL_CLAMP, true);
            return null;
        }
    }, false);

    Command.addCommand(new Command("f.copy", "Copy a files to the system clipboard",
            "^f.copy [file0] [file1] [file2] ..." + "\nfile: file(s) - Files to copy") {
        @Override
        public String action(final String[] args) {
            /*Platform.runLater(() -> {
               Clipboard sc = Clipboard.getSystemClipboard();
               ClipboardContent cbc = new ClipboardContent();
               ArrayList<String> files = new ArrayList<String>();
               for (int i = 0; i < args.length; i++) {
                  VD_FlConsole.println("Clipboard: " + args[i]);
                  files.add(args[i]);
               }
               cbc.putFilesByPath(files);
               sc.setContent(cbc);
            });*/
            return "";
        }
    }, false);

    Command.addCommand(new Command("fc.color", "Change the foreground and background",
            "\n^color [hex] [hex]" + "\nhex: The hex value of the desired background color."
                    + "\nhex: The hex value of the desired foreground color."
                    + "\n\nBoth can be left as null for no change." + "\nDo not include # or 0x") {
        @Override
        public String action(String[] args) {
            if (args[1].equals("null")) {
                VD_FlConsole.setColor(null, Color.decode("0x" + args[0]));
            } else if (args[0].equals("null")) {
                VD_FlConsole.setColor(Color.decode("0x" + args[1]), null);
            } else if (!args[0].equals("null") && !args[1].equals("null")) {
                VD_FlConsole.setColor(Color.decode("0x" + args[1]), Color.decode("0x" + args[0]));
            }
            return "";
        }
    }, false);

    Command.addCommand(new Command("fc.fcis", "Run an FCIS", "^fc.fcis [file] [arg#0] [arg#1] [arg#2] ..."
            + "\nfile: fcis - Path to the file containing commands"
            + "\nargs: arguments - Values to be passed on." + "\n\nPlease see FCIS help for more info.") {
        @Override
        public String action(String[] args) {
            return fcis(new File(args[0]), Arrays.copyOfRange(args, 1, args.length));
        }
    }, false);

    Command.addCommand(new Command("fc.testerror", "Cause an error",
            "Connect to the invalid port 235325 with a blank host.") {
        @Override
        public String action(String[] args) {
            VD_FlConsole.testError();
            return "";
        }
    }, false);

    Command.addCommand(new Command("fc.title", "Set or return the title of the Debvi screen or this.",
            "^title [string(console,debvi)] [bool] [string]"
                    + "\nstring console : Set mode to the title of this Console"
                    + "\nstring debvi : Set mode to the title of the Debvi screen"
                    + "\nbool: return Return the title of console or debvi"
                    + "\nstring: title The title to be set.") {
        @Override
        public String action(String[] args) {
            String re = "";
            if (Boolean.parseBoolean(args[1])) {
                if (args[0].equals("console")) {
                    re = VD_FlConsole.consoleWindow.consoleWindow.getTitle();
                }
                if (args[0].equals("debvi")) {
                    // re = DebviFrame..getTitle();
                }
            } else {
                if (args[0].equals("console")) {
                    VD_FlConsole.consoleWindow.consoleWindow.setTitle(args[2]);
                }
                if (args[0].equals("debvi")) {
                    // DebviFrame.mainWindow.setTitle(args[2]);
                }
            }
            return re;
        }
    }, false);

    Command.addCommand(new Command("help", "Show help.",
            "How to use this console." + "\nThis whole console is command based. Syntax follows:"
                    + "\n\n ^command arg0 arg1 arg2 arg3 arg4 and so on..."
                    + "\n\nSome commands like '^m.sum' have return values."
                    + "\nReturn values could be used in Commands with other commands"
                    + "\nin them using brackets as so. Think of your BEDMAS, brackets are first."
                    + "\n\n ^m.sum (^m.sum 1 4) 1 Returns 6"
                    + "\n\nA series of commands could be stored in a .fcis"
                    + "\n(Fluffy Console Isd.welcomenterpreted Script)"
                    + "\nAn fcis could be created by a simple text editor."
                    + "\nIn fact, Debvi has an fcis editor built in.") {
        @Override
        public String action(String[] args) {
            if (args[0].equalsIgnoreCase("null")) {
                VD_FlConsole.println("Showing list of commands: ");
                System.out.println("For more details, use help key\n");
                for (int i = 0; i < Command.commandList.size(); i++) {
                    if (!commandList.get(i).hidden) {
                        VD_FlConsole.println(
                                Command.commandList.get(i).key + " - " + Command.commandList.get(i).help);
                    }
                }
                System.out.println("Have no clue of what your doing? try \"^help help\"");
            } else {
                System.out.println("Showing long help for command: " + args[0] + "\n");
                for (int i = 0; i < Command.commandList.size(); i++) {
                    if (commandList.get(i).key.equalsIgnoreCase(args[0])) {
                        System.out.println(commandList.get(i).usage);
                    }
                }
            }
            return "";
        }
    }, false);

    Command.addCommand(new Command("jvm.exit", "System.exit() (WARNING)",
            "^jvm.exit [int]" + "\nint: status - 0 for normal. (default 0) see System.exit(); in Java.") {
        @Override
        public String action(String[] args) {
            if (args[0] != null) {
                System.exit(Integer.parseInt(args[0]));
            } else {
                System.exit(0);
            }
            return "";
        }
    }, false);

    Command.addCommand(new Command("jvm.gc", "Free memory from JVM", "Free memory from the JVM"
            + "\nIn java, System.gc(); is called." + "\njavaw will still use as much memory.") {
        @Override
        public String action(String[] args) {
            System.gc();
            return "";
        }
    }, false);

    Command.addCommand(new Command("jvm.tcount", "List the number of active threads",
            "In Java, Thread.activeCount();" + "\nIs called") {
        @Override
        public String action(String[] args) {
            VD_FlConsole.println(Thread.activeCount());
            return Thread.activeCount() + "";
        }
    }, false);

    Command.addCommand(new Command("kdion.js", "Run some javascript using Nashorn",
            "kdion.js [string]" + "\nstring: string - Javascript code") {
        @Override
        public String action(String[] args) {
            try {
                Kondion.getNashorn().eval(args[0]);
            } catch (ScriptException e) {
                e.printStackTrace();
            }
            return "";
        }
    }, false);

    Command.addCommand(new Command("kdion.rungamedir", "Run a game from a folder",
            "kdion.rungamefolder [file]" + "\nfile: json - Path to kondion.json") {
        @Override
        public String action(String[] args) {
            KHacker.runGame(args[0]);
            return "";
        }
    }, false);

    Command.addCommand(new Command("kdion.windowsize", "Set the size of the window. Call before rungame*",
            "kdion.windowsize [width] [height]") {
        @Override
        public String action(String[] args) {
            Kondion.setSize(Integer.parseInt(args[0]), Integer.parseInt(args[1]));
            return "";
        }
    }, false);

    Command.addCommand(new Command("pref.clear", "Removes all the entries",
            "^pref.clear" + "\nThis command will clear all pref entries in the memory."
                    + "\nIt will be saved to a file when write is called.") {
        @Override
        public String action(String[] args) {
            VD_Keydata.remove(args[0]);
            return "";
        }
    }, false);

    Command.addCommand(new Command("pref.list", "List all entries in Preferences", "A preferences operation.") {
        @Override
        public String action(String[] args) {
            String p = "Listing preference entries...";
            p += "\ntag :: key :: value";

            for (int i = 0; i < VD_Keydata.keys.size(); i++) {
                p += "\n" + VD_Keydata.tags.get(i) + " :: " + VD_Keydata.keys.get(i) + " :: "
                        + VD_Keydata.values.get(i).getText();
            }

            return p;
        }
    }, false);

    Command.addCommand(new Command("pref.load", "Load a preferences file.",
            "^pref.load [file]" + "\nfile: pref - Path to the desired pref file."
                    + "\n\nThe preferences file for this session is changed to this file.") {
        @Override
        public String action(String[] args) {
            VD_Keydata.load(new File(args[0]));
            return "";
        }
    }, false);

    Command.addCommand(new Command("pref.remove", "Remove an entry",
            "^pref.remove [string]" + "\nstring: key - The key of the entry to remove") {
        @Override
        public String action(String[] args) {
            VD_Keydata.remove(args[0]);
            return "";
        }
    }, false);

    Command.addCommand(new Command("pref.set", "Create or change an entry contained in preferences.",
            "^pref.set [string] [string] [string]" + "\nstring: key - The key of the entry to create or change."
                    + "\nstring: tag - The tag of the entry to create or change. see Pref tags."
                    + "\nstring: value - The value to be set to the entry.") {
        @Override
        public String action(String[] args) {
            VD_Keydata.set(args[0], args[2], args[1]);
            return "";
        }
    }, false);

    Command.addCommand(new Command("pref.write", "Write Preferences to a file",
            "^pref.write [file]" + "\nfile: pref - Path to overwrite or create a file."
                    + "\n\nPref files come in .pref and the Debvi default is debvi.pref"
                    + "\n^pref.write (debvi.pref)") {
        @Override
        public String action(String[] args) {
            VD_Keydata.write(new File(args[0]));
            return "";
        }
    }, false);

    /*
     * Command.addCommand(new Command("debvi.reset",
     * "Total Reset (WARNING)", "^debvi.reset [string]" +
     * "\nstring: confirm - Confirm the reset by typing CoNfirMthEREseT123455678912"
     * + "\n\nThis will erase Prefs ") {
     * 
     * @Override public String action(String[] args) { new
     * File("debvi.pref").delete(); System.exit(0); return ""; } }, false);
     */

    Command.addCommand(new Command("print", "Print a message.", "^print [string] " + "\nHELLO WORLD!!!!!") {
        @Override
        public String action(String[] args) {
            VD_FlConsole.println(args[0]);
            return args[0];
        }
    }, false);

    // Eggs

    Command.addCommand(new Command("eggs", "Show your eggs.", "Do you like eggs?") {
        @Override
        public String action(String[] args) {
            // The \u2588 character is the full block character.
            VD_FlConsole.println(
                    "\u2588\u2588\u2588\u2588  \u2588\u2588\u2588\u2588\u2588   \u2588   \u2588 \u2588\u2588\u2588\u2588\u2588 \u2588   \u2588   \u2588     \u2588\u2588\u2588\u2588\u2588 \u2588 \u2588   \u2588 \u2588\u2588\u2588\u2588\u2588");
            VD_FlConsole.println(
                    "\u2588   \u2588 \u2588   \u2588   \u2588   \u2588 \u2588   \u2588 \u2588   \u2588   \u2588     \u2588     \u2588 \u2588  \u2588  \u2588");
            VD_FlConsole.println(
                    "\u2588   \u2588 \u2588   \u2588    \u2588 \u2588  \u2588   \u2588 \u2588   \u2588   \u2588     \u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588   \u2588\u2588\u2588\u2588\u2588");
            VD_FlConsole.println(
                    "\u2588   \u2588 \u2588   \u2588     \u2588   \u2588   \u2588 \u2588   \u2588   \u2588     \u2588     \u2588 \u2588  \u2588  \u2588");
            VD_FlConsole.println(
                    "\u2588\u2588\u2588\u2588  \u2588\u2588\u2588\u2588\u2588     \u2588   \u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588   \u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588 \u2588   \u2588 \u2588\u2588\u2588\u2588\u2588");
            VD_FlConsole.println("");
            VD_FlConsole.println(
                    "\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588");
            VD_FlConsole.println("\u2588     \u2588     \u2588     \u2588         \u2588");
            VD_FlConsole.println(
                    "\u2588\u2588\u2588\u2588\u2588 \u2588  \u2588\u2588 \u2588  \u2588\u2588 \u2588\u2588\u2588\u2588\u2588    \u2588");
            VD_FlConsole.println("\u2588     \u2588   \u2588 \u2588   \u2588     \u2588   ");
            VD_FlConsole.println(
                    "\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588   \u2588");
            return "Eggs";
        }
    }, true);

    Command.addCommand(new Command("vendalenger", "Do you leike eggs?", "Do you leike eggs?") {
        @Override
        public String action(String[] args) {
            Command.issue("^fc.color 010101 67ff00", false);
            Command.issue("^clr", false);
            String vendalenger = "\n                   "
                    + "\n            "
                    + "\n           "
                    + "\n        "
                    + "\n       "
                    + "\n      "
                    + "\n     "
                    + "\n       "
                    + "\n       "
                    + "\n             "
                    + "\n"
                    + "\n          " + "\n              VENDALENGER 2014"
                    + "\n         ";
            return vendalenger;
        }
    }, true);
}

From source file:voxicity.TextureManager.java

License:Open Source License

public static int get_texture(String name) {
    if (name == null)
        return 0;

    if (textures.containsKey(name))
        return textures.get(name).getTextureID();

    try {//from   w w w . jav  a 2s .  com
        Texture new_tex = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream(name), true,
                GL11.GL_NEAREST);
        System.out.println("Loaded texture: " + new_tex);

        textures.put(name, new_tex);

        int tex_bak = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);

        GL11.glBindTexture(GL11.GL_TEXTURE_2D, new_tex.getTextureID());
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);

        GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex_bak);

        return new_tex.getTextureID();
    } catch (java.io.IOException e) {
        System.out.println("Failed to load texture " + name);
        e.printStackTrace();
        System.exit(0);
    }

    return 0;
}

From source file:wrath.client.graphics.Texture.java

License:Open Source License

/**
 * Constructor.//from   ww  w.j a  v a 2s. c om
 * @param textureFile The image {@link java.io.File} to load the texture from.
 */
protected Texture(File textureFile) {
    this.file = textureFile;
    this.texID = ClientUtils.getTexture(ClientUtils.loadImageFromFile(textureFile));
    Game.getCurrentInstance().getLogger()
            .println("Created texture ID '" + texID + "' from file '" + file.getName() + "'!");
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
    if (Game.getCurrentInstance().getConfig().getBoolean("TexureMipmapping", true))
        GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
    if (Game.getCurrentInstance().getConfig().getBoolean("AntiAliasingTexture", true)) {
        if (Game.getCurrentInstance().getConfig().getBoolean("TexureMipmapping", true)) {
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
        } else {
            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_NEAREST);
        }

    }
    Texture.unbindTextures();
    afterConstructor();
}

From source file:wrath.client.graphics.Texture.java

License:Open Source License

@Override
public void reload() {
    this.texID = ClientUtils.getTexture(ClientUtils.loadImageFromFile(file));
    GL11.glEnable(GL11.GL_TEXTURE_2D);/*from w  ww .  j a  v  a  2s. c  om*/
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
    if (Game.getCurrentInstance().getConfig().getBoolean("TexureMipmapping", true))
        GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
    if (Game.getCurrentInstance().getConfig().getBoolean("AntiAliasingTexture", true)) {
        if (Game.getCurrentInstance().getConfig().getBoolean("TexureMipmapping", true)) {
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
        } else {
            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_NEAREST);
        }

    }
    Texture.unbindTextures();
    Game.getCurrentInstance().getLogger()
            .println("Created texture ID '" + texID + "' from file '" + file.getName() + "'!");
}

From source file:zildo.fwk.gfx.engine.TextureEngine.java

License:Open Source License

public void generateTexture() {

    // Create A IntBuffer For Image Address In Memory
    IntBuffer buf = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
    GL11.glGenTextures(buf); // Create Texture In OpenGL

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, buf.get(0));
    // Typical Texture Generation Using Data From The Image

    int wrapping = GL11.GL_REPEAT; // Wrap texture (useful for cloud)
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, wrapping);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, wrapping);

    int filtering = GL11.GL_NEAREST;
    // Linear Filtering
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filtering);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filtering);
    // Generate The Texture
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, textureFormat, 256, 256, 0, textureFormat, GL11.GL_UNSIGNED_BYTE,
            scratch);/*from ww  w  .ja v  a2  s . co  m*/

    // Reset bytebuffer scratch
    scratch.clear();

    // Store texture id
    textureTab[n_Texture] = buf.get(0);

    // Ready for next one
    n_Texture++;
}

From source file:zildo.platform.engine.LwjglTextureEngine.java

License:Open Source License

@Override
public int doGenerateTexture() {
    scratch.position(0);/*from  w  w  w .j  a va  2  s  . c  om*/

    // Create A IntBuffer For Image Address In Memory
    IntBuffer buf = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
    GL11.glGenTextures(buf); // Create Texture In OpenGL

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, buf.get(0));
    // Typical Texture Generation Using Data From The Image

    int wrapping = GL11.GL_REPEAT; // Wrap texture (useful for cloud)
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, wrapping);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, wrapping);

    int filtering = GL11.GL_NEAREST;
    // Linear Filtering
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filtering);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filtering);
    // Generate The Texture
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, getTextureFormat(), 256, 256, 0, getTextureFormat(),
            GL11.GL_UNSIGNED_BYTE, scratch);

    return buf.get(0);
}

From source file:zildo.platform.engine.LwjglTextureEngine.java

License:Open Source License

@Override
public int loadTexture(String name) {
    try {//from  w ww.  j  a v  a  2s  .  com
        Texture tex = TextureLoader.getTexture("PNG",
                new FileInputStream(Constantes.DATA_PATH + "textures/" + name + ".png"));

        int id = tex.getTextureID();

        GL11.glBindTexture(GL11.GL_TEXTURE_2D, id);
        // Typical Texture Generation Using Data From The Image

        int wrapping = GL11.GL_REPEAT; // Wrap texture (useful for cloud)
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, wrapping);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, wrapping);

        int filtering = GL11.GL_NEAREST;
        // Linear Filtering
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filtering);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filtering);

        // Store texture id
        textureTab[n_Texture] = tex.getTextureID();
        alphaTab[n_Texture] = true;

        // Ready for next one
        n_Texture++;

        return tex.getTextureID();
    } catch (Exception e) {
        throw new RuntimeException("Can't load texture " + name, e.getCause());
    }

}