List of usage examples for org.lwjgl.opengl GL11 GL_NEAREST
int GL_NEAREST
To view the source code for org.lwjgl.opengl GL11 GL_NEAREST.
Click Source Link
From source file:com.runescape.client.revised.editor.modelviewer.Generator.java
License:Open Source License
public void draw() { GL11.glBegin(GL11.GL_QUADS);/*from w w w . j av a2 s .co m*/ for (int i = 0; i < this.particleCount; i++) { if (this.particles[i] != null) { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, this.decParticle.getWidth(), this.decParticle.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, this.bufParticle); GL11.glBindTexture(GL11.GL_ADD, GL11.GL_LOAD); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 1); 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.glPushMatrix(); GL11.glTranslated(this.particles[i].x + (Main.getMain().getCanvas().getX() / 2), this.particles[i].y + (Main.getMain().getCanvas().getY() / 2), 0); this.particles[i].draw(); GL11.glPopMatrix(); } } GL11.glEnd(); }
From source file:com.samrj.devil.gl.DGL.java
License:Open Source License
/** * Blits the currently bound read buffer into the bound draw frame buffer. * Assumes the buffers are of equal dimensions and have compatible formats. * /*from w ww .ja v a 2s . c om*/ * @param width The width of both buffers. * @param height The height of both buffers. * @param mask The bitwise OR of the flags indicating which buffers are to * be copied. The allowed flags are GL_COLOR_BUFFER_BIT, * GL_DEPTH_BUFFER_BIT and GL_STENCIL_BUFFER_BIT. */ public static void blitFBO(int width, int height, int mask) { GL30.glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, mask, GL11.GL_NEAREST); }
From source file:com.samrj.devil.ui.AtlasFont.java
License:Open Source License
public AtlasFont(String directory, String fontFile) throws IOException { if (!directory.endsWith("/")) directory += "/"; InputStream inputStream = Resource.open(directory + fontFile); LittleEndianInputStream in = new LittleEndianInputStream(inputStream); //HEADER/*from ww w.j ava 2s . c o m*/ ensureByte(in, 66, MSG_ERROR_FORMAT); ensureByte(in, 77, MSG_ERROR_FORMAT); ensureByte(in, 70, MSG_ERROR_FORMAT); ensureByte(in, 3, MSG_ERROR_FORMAT); //INFO BLOCK ensureByte(in, 1, "Expected info block first."); skip(in, 18); //Skip rest of info block name = in.readNullTermStr(); //COMMON BLOCK ensureByte(in, 2, "Expected common block second."); skip(in, 4); //Skip info block size lineHeight = in.readLittleUnsignedShort(); baseHeight = lineHeight - in.readLittleUnsignedShort(); skip(in, 4); int pages = in.readLittleUnsignedShort(); if (pages != 1) throw new IOException("Only one page texture supported."); if ((in.read() & 128) != 0) throw new IOException("Channel-packed fonts not supported."); ensureByte(in, 0, "Alpha channel must contain glyph data."); skip(in, 3); //PAGES BLOCK ensureByte(in, 3, "Expected pages block third."); skip(in, 4); String texFile = in.readNullTermStr(); Image image = DGL.loadImage(directory + texFile); if (!Util.isPower2(image.width) || !Util.isPower2(image.height)) throw new IOException("Texture dimensions must be powers of two."); if (image.bands != 1) throw new IOException("Texture format must have one band."); texture = DGL.genTex2D(); texture.image(image, GL11.GL_ALPHA8); texture.bind(); texture.parami(GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); texture.parami(GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); DGL.delete(image); //CHARS BLOCK ensureByte(in, 4, "Expected chars block fourth."); int numChars = in.readLittleInt() / 20; List<Char> charList = new ArrayList<>(numChars); int minChar = Integer.MAX_VALUE, maxChar = -1; for (int i = 0; i < numChars; i++) { Char c = new Char(in, texture.getWidth(), texture.getHeight()); charList.add(c); if (c.id < minChar) minChar = c.id; if (c.id > maxChar) maxChar = c.id; } chars = new Char[maxChar - minChar + 1]; for (Char c : charList) chars[c.id - minChar] = c; firstCharID = minChar; in.close(); stream = DGL.genVertexStream(1024, -1); pos = stream.vec2("in_pos"); coord = stream.vec2("in_tex_coord"); stream.begin(); }
From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java
License:Mozilla Public License
private int bindTexture(Node node, String imageData) { int textureId = GL11.glGenTextures(); byte[] bitmap = Base64.decodeBase64(imageData); try {//from www . jav a 2 s . c o m PNGDecoder decoder = new PNGDecoder(new ByteArrayInputStream(bitmap)); int width = decoder.getWidth(); int height = decoder.getHeight(); ByteBuffer buffer = ByteBuffer.allocateDirect(4 * width * height); decoder.decode(buffer, width * 4, Format.RGBA); buffer.flip(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer); } catch (IOException e) { e.printStackTrace(); } return textureId; }
From source file:com.voxelplugineering.voxelsniper.util.TextureUtilities.java
License:Open Source License
public static int loadPNGTexture(File file, int textureUnit) { ByteBuffer buf = null;//from ww w .j a v a2 s. co m int tWidth = 0; int tHeight = 0; try { BufferedImage image = ImageIO.read(file); tWidth = image.getWidth(); tHeight = image.getHeight(); buf = imageToRGBABuffer(image); } catch (IOException e) { e.printStackTrace(); if (file.getName().endsWith("debug.png")) { System.exit(-1); } else { return debugTexture; } } // Create a new texture object in memory and bind it int texId = GL11.glGenTextures(); GL13.glActiveTexture(textureUnit); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId); // All RGB bytes are aligned to each other and each component is 1 byte GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); // Upload the texture data and generate mip maps (for scaling) GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, tWidth, tHeight, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buf); GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); // Setup the ST coordinate system GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); // Setup what to do when the texture has to be scaled 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_NEAREST); OpenGLUtilities.checkGLError("loadPNGTexture"); if (file.getName().endsWith("debug.png")) { debugTexture = texId; } return texId; }
From source file:com.xrbpowered.gl.res.buffers.OffscreenBuffers.java
License:Open Source License
protected void create(int w, int h, boolean depthBuffer, boolean hdr) { colorTexId = GL11.glGenTextures();/* w w w .j a v a 2 s . c o m*/ GL11.glBindTexture(GL11.GL_TEXTURE_2D, colorTexId); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, hdr ? GL30.GL_RGB16F : GL11.GL_RGB, w, h, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null); 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); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, colorTexId, 0); depthTexId = 0; if (depthBuffer) { depthTexId = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, depthTexId); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL14.GL_DEPTH_COMPONENT16, w, h, 0, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, (ByteBuffer) null); 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); 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.glBindTexture(GL11.GL_TEXTURE_2D, 0); GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL11.GL_TEXTURE_2D, depthTexId, 0); } checkStatus(); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0); }
From source file:com.xrbpowered.gl.res.buffers.RenderTarget.java
License:Open Source License
public static void blit(RenderTarget source, RenderTarget target, boolean filter) { GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, source.fbo); GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, target.fbo); // System.out.printf("[%d] %dx%d -> [%d] %dx%d\n", source.fbo, source.getWidth(), source.getHeight(), target.fbo, target.getWidth(), target.getHeight()); GL30.glBlitFramebuffer(0, 0, source.getWidth(), source.getHeight(), 0, 0, target.getWidth(), target.getHeight(), GL11.GL_COLOR_BUFFER_BIT, filter ? GL11.GL_LINEAR : GL11.GL_NEAREST); Client.checkError();/* w w w . ja v a 2 s .c om*/ }
From source file:com.xrbpowered.gl.res.textures.Texture.java
License:Open Source License
public static void setProperties(int textureType, boolean wrap, boolean filter, int anisotropy) { GL11.glTexParameteri(textureType, GL11.GL_TEXTURE_WRAP_S, wrap ? GL11.GL_REPEAT : GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(textureType, GL11.GL_TEXTURE_WRAP_T, wrap ? GL11.GL_REPEAT : GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(textureType, GL11.GL_TEXTURE_MAG_FILTER, filter ? GL11.GL_LINEAR : GL11.GL_NEAREST); GL11.glTexParameteri(textureType, GL11.GL_TEXTURE_MIN_FILTER, filter ? GL11.GL_LINEAR_MIPMAP_LINEAR : GL11.GL_NEAREST); if (filter) { GL30.glGenerateMipmap(textureType); if (anisotropy > 1) { GL11.glTexParameterf(textureType, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy);/*from w ww .j av a2s. com*/ } } }
From source file:cuchaz.jfxgl.prism.JFXGLContext.java
License:Open Source License
@Override public void blitFBO(int srcFboId, int dstFboId, int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1) { GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, srcFboId); GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, dstFboId); GL30.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST); }
From source file:cuchaz.jfxgl.prism.JFXGLContext.java
License:Open Source License
@Override public void updateFilterState(int texID, boolean linearFilter) { if (linearFilter) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); } else {// w ww. ja v a 2 s . com 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); } }