List of usage examples for org.lwjgl.opengl GL11 GL_CLAMP
int GL_CLAMP
To view the source code for org.lwjgl.opengl GL11 GL_CLAMP.
Click Source Link
From source file:rainwarrior.mt100.client.PstFont.java
License:Open Source License
public void bindFontTexture() { GL11.glLoadIdentity();/*from www . j av a 2 s . c o m*/ 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 . ja va 2s . 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:shadowmage.meim.client.texture.TextureManager.java
License:Open Source License
public static void allocateTexture() { if (texNum >= 0) { GL11.glDeleteTextures(texNum);//from w w w .j a v a 2s . c o m } 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:src.graphics.common.Texture.java
License:Open Source License
public static void setDefaultTexParams(int target) { GL11.glTexParameteri(target, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(target, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); }
From source file:terminal.gld.TrueTypeFont.java
License:Open Source License
public static int loadImage(BufferedImage bufferedImage) { try {//from w w w. ja v a 2 s.co m short width = (short) bufferedImage.getWidth(); short height = (short) bufferedImage.getHeight(); // textureLoader.bpp = // bufferedImage.getColorModel().hasAlpha() ? (byte)32 : // (byte)24; int bpp = (byte) bufferedImage.getColorModel().getPixelSize(); ByteBuffer byteBuffer; DataBuffer db = bufferedImage.getData().getDataBuffer(); if (db instanceof DataBufferInt) { int intI[] = ((DataBufferInt) (bufferedImage.getData().getDataBuffer())).getData(); byte newI[] = new byte[intI.length * 4]; for (int i = 0; i < intI.length; i++) { byte b[] = intToByteArray(intI[i]); int newIndex = i * 4; newI[newIndex] = b[1]; newI[newIndex + 1] = b[2]; newI[newIndex + 2] = b[3]; newI[newIndex + 3] = b[0]; } byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder()) .put(newI); } else { byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder()) .put(((DataBufferByte) (bufferedImage.getData().getDataBuffer())).getData()); } byteBuffer.flip(); int internalFormat = GL11.GL_RGBA8, format = GL11.GL_RGBA; IntBuffer textureId = BufferUtils.createIntBuffer(1); ; GL11.glGenTextures(textureId); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId.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_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE); GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, internalFormat, width, height, format, GL11.GL_UNSIGNED_BYTE, byteBuffer); return textureId.get(0); } catch (Exception e) { e.printStackTrace(); System.exit(-1); } return -1; }
From source file:vendalenger.port.Command.java
License:Apache License
/** * Setup default commands and Editors for Fluffy Console *//*from ww w . j a v a 2 s. c o 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); }