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:name.martingeisse.swtlib.canvas.OpenGlImageBlockCanvas.java
License:Open Source License
@Override protected void drawBlock(final int x, final int y) { palette.safeBind(getBlock(x, y));//from w w w. j a v a 2 s .c om GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); // glBegin/glEnd must be called per block because of changing textures GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex2i(x, y); GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex2i(x + 1, y); GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex2i(x + 1, y + 1); GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex2i(x, y + 1); GL11.glEnd(); }
From source file:net.BiggerOnTheInside.Binder.BlockRenderer.java
License:Open Source License
public static void renderBlock(Block b, float x, float y, float z) { GL11.glPushMatrix();//from w w w . j ava 2 s.c o m 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.glTranslatef(x * 2f, y * 2f, z * 2f); GL11.glBegin(GL11.GL_QUADS); GL11.glColor3f(1f, 1f, 1f); // Top face. GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Top).x(), b.getTextureCoordinates(BlockFace.Top).y()); GL11.glVertex3f(1.0f, 1.0f, -1.0f); GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Top).x() + Globals.TEXTURE_SIZE, b.getTextureCoordinates(BlockFace.Top).y()); GL11.glVertex3f(-1.0f, 1.0f, -1.0f); GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Top).x() + Globals.TEXTURE_SIZE, b.getTextureCoordinates(BlockFace.Top).y() + Globals.TEXTURE_SIZE); GL11.glVertex3f(-1.0f, 1.0f, 1.0f); GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Top).x(), b.getTextureCoordinates(BlockFace.Top).y() + Globals.TEXTURE_SIZE); GL11.glVertex3f(1.0f, 1.0f, 1.0f); // Bottom. GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Bottom).x(), b.getTextureCoordinates(BlockFace.Bottom).y()); GL11.glVertex3f(1.0f, -1.0f, 1.0f); GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Bottom).x() + Globals.TEXTURE_SIZE, b.getTextureCoordinates(BlockFace.Bottom).y()); GL11.glVertex3f(-1.0f, -1.0f, 1.0f); GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Bottom).x() + Globals.TEXTURE_SIZE, b.getTextureCoordinates(BlockFace.Bottom).y() + Globals.TEXTURE_SIZE); GL11.glVertex3f(-1.0f, -1.0f, -1.0f); GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Bottom).x(), b.getTextureCoordinates(BlockFace.Bottom).y() + Globals.TEXTURE_SIZE); GL11.glVertex3f(1.0f, -1.0f, -1.0f); // Front. GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Front).x(), b.getTextureCoordinates(BlockFace.Front).y()); GL11.glVertex3f(1.0f, 1.0f, 1.0f); GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Front).x() + Globals.TEXTURE_SIZE, b.getTextureCoordinates(BlockFace.Front).y()); GL11.glVertex3f(-1.0f, 1.0f, 1.0f); GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Front).x() + Globals.TEXTURE_SIZE, b.getTextureCoordinates(BlockFace.Front).y() + Globals.TEXTURE_SIZE); GL11.glVertex3f(-1.0f, -1.0f, 1.0f); GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Front).x(), b.getTextureCoordinates(BlockFace.Front).y() + Globals.TEXTURE_SIZE); GL11.glVertex3f(1.0f, -1.0f, 1.0f); // Back. GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Back).x(), b.getTextureCoordinates(BlockFace.Back).y()); GL11.glVertex3f(1.0f, -1.0f, -1.0f); GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Back).x() + Globals.TEXTURE_SIZE, b.getTextureCoordinates(BlockFace.Back).y()); GL11.glVertex3f(-1.0f, -1.0f, -1.0f); GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Back).x() + Globals.TEXTURE_SIZE, b.getTextureCoordinates(BlockFace.Back).y() + Globals.TEXTURE_SIZE); GL11.glVertex3f(-1.0f, 1.0f, -1.0f); GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Back).x(), b.getTextureCoordinates(BlockFace.Back).y() + Globals.TEXTURE_SIZE); GL11.glVertex3f(1.0f, 1.0f, -1.0f); // Left GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Left).x(), b.getTextureCoordinates(BlockFace.Left).y()); GL11.glVertex3f(-1.0f, 1.0f, 1.0f); GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Left).x() + Globals.TEXTURE_SIZE, b.getTextureCoordinates(BlockFace.Left).y()); GL11.glVertex3f(-1.0f, 1.0f, -1.0f); GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Left).x() + Globals.TEXTURE_SIZE, b.getTextureCoordinates(BlockFace.Left).y() + Globals.TEXTURE_SIZE); GL11.glVertex3f(-1.0f, -1.0f, -1.0f); GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Left).x(), b.getTextureCoordinates(BlockFace.Left).y() + Globals.TEXTURE_SIZE); GL11.glVertex3f(-1.0f, -1.0f, 1.0f); // Right. GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Right).x(), b.getTextureCoordinates(BlockFace.Right).y()); GL11.glVertex3f(1.0f, 1.0f, -1.0f); GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Right).x() + Globals.TEXTURE_SIZE, b.getTextureCoordinates(BlockFace.Right).y()); GL11.glVertex3f(1.0f, 1.0f, 1.0f); GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Right).x() + Globals.TEXTURE_SIZE, b.getTextureCoordinates(BlockFace.Right).y() + Globals.TEXTURE_SIZE); GL11.glVertex3f(1.0f, -1.0f, 1.0f); GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Right).x(), b.getTextureCoordinates(BlockFace.Right).y() + Globals.TEXTURE_SIZE); GL11.glVertex3f(1.0f, -1.0f, -1.0f); GL11.glEnd(); GL11.glTranslatef(0f, 0f, 0f); GL11.glPopMatrix(); }
From source file:net.minecraft.client.gui.fonts.GlyphCache.java
License:Open Source License
/** * Allocate a new OpenGL texture for caching pre-rendered glyph images. The * new texture is initialized to fully transparent white so the individual * glyphs images within can have a transparent border between them. The new * texture remains bound after returning from the function. * * @todo use GL_ALPHA4 if anti-alias is turned off for even smaller textures *///from w w w . j a va 2 s .c o m private void allocateGlyphCacheTexture() { /* Initialize the background to all white but fully transparent. */ glyphCacheGraphics.clearRect(0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT); /* Allocate new OpenGL texure */ singleIntBuffer.clear(); GLAllocation.generateTextureNames(singleIntBuffer); textureName = singleIntBuffer.get(0); /* Load imageBuffer with pixel data ready for transfer to OpenGL texture */ updateImageBuffer(0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT); /* * Initialize texture with the now cleared BufferedImage. Using a texture with GL_ALPHA8 internal format may result in * faster rendering since the GPU has to only fetch 1 byte per texel instead of 4 with a regular RGBA texture. */ GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureName); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_ALPHA8, TEXTURE_WIDTH, TEXTURE_HEIGHT, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, imageBuffer); /* Explicitely disable mipmap support becuase updateTexture() will only update the base level 0 */ 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:net.minecraft.src.PaintWorld.java
License:Open Source License
public void getTextureForFace(int face) { PaintFace pface = renderBlock.paintedFaces[face]; if (textureBuffer == null) { textureBuffer = ByteBuffer.allocateDirect(ARRAY_SIZE); textureBuffer.order(ByteOrder.nativeOrder()); }// ww w . ja v a 2s . com if (textureId <= 0) { textureId = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId); 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, textureId); textureBuffer.clear(); textureBuffer.put(pface.points); textureBuffer.flip(); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, ROW, ROW, 0, GL11.GL_RGBA, GL11.GL_BYTE, textureBuffer); }
From source file:net.phatcode.rel.multimedia.Graphics.java
License:Open Source License
public Graphics(int screenWidth, int screenHeight, int vsynch) { super(screenWidth, screenHeight); if (vsynch != 0) { Display.setVSyncEnabled(true);//from w w w .ja v a2 s. com } spriteFont = new SpriteFont(new ImageAtlas(new ImageTextureDataFont(), 32, 32, GL11.GL_NEAREST)); glowImages = new ImageAtlas(new ImageTextureDataGlowSprites(), GL11.GL_LINEAR, 0); }
From source file:nintendofan9797.core.textureengine.codechicken.render.TextureUtils.java
public static Texture createTextureObject(String textureFile) { BufferedImage img = loadBufferedImage(textureFile); if (img == null) CoreLoadingPlugin.log.warning("Texture is null."); return new Texture(textureFile, 2, img.getWidth(), img.getHeight(), GL11.GL_CLAMP, GL11.GL_RGBA, GL11.GL_NEAREST, GL11.GL_NEAREST, img); }
From source file:nintendofan9797.core.textureengine.codechicken.render.TextureUtils.java
public static Texture createTextureObject(String name, int w, int h) { return new Texture(name, 2, w, h, GL11.GL_CLAMP, GL11.GL_RGBA, GL11.GL_NEAREST, GL11.GL_NEAREST, null); }
From source file:okkapel.kkplglutil.util.TextureLoader.java
License:Open Source License
public static Texture loadTexture(File imgFile, boolean pixelated) // Needs rewriting { String fullFilePath = null;/*from www . j a v a 2s . c o m*/ try { fullFilePath = imgFile.getAbsolutePath(); // The image BufferedImage image = ImageIO.read(imgFile); // The image pixel data int[] pixels = new int[image.getWidth() * image.getHeight() * 4]; // Write the pixel data into the array image.getRGB(0, 0, image.getWidth(), image.getHeight(), pixels, 0, image.getWidth()); // Create a byte buffer for pixel data ByteBuffer pixelBuffer = BufferUtils.createByteBuffer(image.getWidth() * image.getHeight() * 4); // Put pixel data into the buffer for (int y = 0; y < image.getHeight(); y++) { for (int x = 0; x < image.getWidth(); x++) { // Get the pixel from the array int pixel = pixels[y * image.getWidth() + x]; // Red pixelBuffer.put((byte) ((pixel >> 16) & 255)); // Green pixelBuffer.put((byte) ((pixel >> 8) & 255)); // Blue pixelBuffer.put((byte) ((pixel) & 255)); // Alpha pixelBuffer.put((byte) ((pixel >> 24) & 255)); } } pixelBuffer.flip(); int id = GL11.glGenTextures(); Texture ret = new Texture(id, image.getWidth(), image.getHeight()); GL11.glBindTexture(GL11.GL_TEXTURE_2D, id); // Engine.out.debug(id); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, image.getWidth(), image.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, pixelBuffer); if (pixelated) { 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.glBindTexture(GL11.GL_TEXTURE_2D, 0); return ret; } catch (IOException e) { e.printStackTrace(); System.err.println("Failed to load texture from file: " + fullFilePath); } return null; // TODO: return missing texture }
From source file:org.agpu.oc.client.ClientProxy.java
@Override public int setup2DScreenTextureTarget(int w, int h) { //Generate Texture Space int texture = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture); //Generate Blank Texture GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, w, h, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_INT, (IntBuffer) null);//ww w. j a va 2s .c o m //Poor filtering. Needed! 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); System.out.println("Generated AGPU output texture"); return texture; }
From source file:org.fenggui.binding.render.lwjgl.LWJGLOpenGL.java
License:Open Source License
public void setupStateVariables(boolean depthTestEnabled) { GL11.glEnable(GL11.GL_BLEND);//from www . java 2s .c o m // GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); 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.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_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); }