List of usage examples for org.lwjgl.opengl GL11 glPixelStorei
public static void glPixelStorei(@NativeType("GLenum") int pname, @NativeType("GLint") int param)
From source file:org.voxels.platform.LWJGLOpenGLAdapter.java
License:Open Source License
@Override public void glPixelStorei(final int pname, final int param) { GL11.glPixelStorei(pname, param); }
From source file:playn.java.JavaGL20.java
License:Apache License
@Override public void glPixelStorei(int pname, int param) { GL11.glPixelStorei(pname, param); }
From source file:processing.opengl.PLWJGL.java
License:Open Source License
@Override public void pixelStorei(int pname, int param) { GL11.glPixelStorei(pname, param); }
From source file:se.angergard.engine.graphics.Texture.java
License:Apache License
private void loadTexture(ByteBuffer buffer, int textureID, int width, int height) { GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer); // Not all computer will support this, fix //TODO GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); 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); 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_LINEAR_MIPMAP_LINEAR); }
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glPixelStorei(int a, int b) { GL11.glPixelStorei(a, b); }
From source file:uk.codingbadgers.bUpload.bUpload.java
License:Open Source License
/** * Creates the screenshot./* w ww . j a v a2s . c o m*/ * @return */ public Screenshot createScreenshot() { Minecraft minecraft = ModLoader.getMinecraftInstance(); Screenshot shot = new Screenshot(); try { int screenSize = minecraft.displayWidth * minecraft.displayHeight; if (PIXEL_BUFFER == null || PIXEL_BUFFER.capacity() < screenSize) { PIXEL_BUFFER = BufferUtils.createIntBuffer(screenSize); PIXEL_ARRAY = new int[screenSize]; } GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1); GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); PIXEL_BUFFER.clear(); GL11.glReadPixels(0, 0, minecraft.displayWidth, minecraft.displayHeight, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, PIXEL_BUFFER); PIXEL_BUFFER.get(PIXEL_ARRAY); copyScreenBuffer(PIXEL_ARRAY, minecraft.displayWidth, minecraft.displayHeight); shot.image = new BufferedImage(minecraft.displayWidth, minecraft.displayHeight, 1); shot.image.setRGB(0, 0, minecraft.displayWidth, minecraft.displayHeight, PIXEL_ARRAY, 0, minecraft.displayWidth); shot.imageID = TextureUtil.func_110987_a(TextureUtil.func_110996_a(), shot.image); } catch (Exception ex) { ex.printStackTrace(); shot.image = null; shot.imageID = 0; } return shot; }
From source file:uk.kihira.tails.client.gui.TintPanel.java
License:Open Source License
private int getColourAtPoint(int x, int y) { int[] pixelData; int pixels = 1; if (pixelBuffer == null) { pixelBuffer = BufferUtils.createIntBuffer(pixels); }/*from w w w. ja v a2s.c om*/ pixelData = new int[pixels]; GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1); GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); pixelBuffer.clear(); GlStateManager.glReadPixels(x, y, 1, 1, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixelBuffer); pixelBuffer.get(pixelData); TextureUtil.processPixelValues(pixelData, 1, 1); return pixelData[0] & 0xFFFFFF; }
From source file:vazkii.botania.client.core.handler.MiscellaneousIcons.java
License:Open Source License
@SubscribeEvent public void dumpAtlas(ArrowLooseEvent evt) { if (!evt.getEntityPlayer().worldObj.isRemote || !((Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment")) || !evt.getEntityPlayer().isSneaking()) return;/*from w w w. j av a 2 s .co m*/ Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); int width = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH); int height = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_HEIGHT); Botania.LOGGER.debug("Dumped atlas %d wide by %d tall%n", width, height); int pixels = width * height; IntBuffer buffer = BufferUtils.createIntBuffer(pixels); int[] pixelValues = new int[pixels]; GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1); GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, buffer); buffer.get(pixelValues); BufferedImage bufferedimage = new BufferedImage(width, height, 2); for (int k = 0; k < height; ++k) { for (int l = 0; l < width; ++l) { bufferedimage.setRGB(l, k, pixelValues[k * width + l]); } } File mcFolder = Minecraft.getMinecraft().mcDataDir; File result = new File(mcFolder, "atlas.png"); try { ImageIO.write(bufferedimage, "png", result); } catch (IOException e) { Botania.LOGGER.warn("Failed to dump debug atlas"); } }
From source file:vazkii.psi.client.core.helper.SharingHelper.java
public static String takeScreenshot() throws Exception { Minecraft mc = Minecraft.getMinecraft(); ScaledResolution res = new ScaledResolution(mc); int screenWidth = mc.displayWidth; int screenHeight = mc.displayHeight; int scale = res.getScaleFactor(); int width = 380 * scale; int height = 200 * scale; int left = screenWidth / 2 - width / 2; int top = screenHeight / 2 - height / 2; int i = width * height; if (pixelBuffer == null || pixelBuffer.capacity() < i) { pixelBuffer = BufferUtils.createIntBuffer(i); pixelValues = new int[i]; }//ww w .java 2 s . co m GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1); GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); pixelBuffer.clear(); GL11.glReadPixels(left, top, width, height, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer) pixelBuffer); pixelBuffer.get(pixelValues); TextureUtil.processPixelValues(pixelValues, width, height); BufferedImage bufferedimage = null; bufferedimage = new BufferedImage(width, height, 1); bufferedimage.setRGB(0, 0, width, height, pixelValues, 0, width); ByteArrayOutputStream stream = new ByteArrayOutputStream(); ImageIO.write(bufferedimage, "png", stream); byte[] bArray = stream.toByteArray(); String base64 = Base64.getEncoder().encodeToString(bArray); return base64; }
From source file:yugecin.opsudance.options.Configuration.java
License:Open Source License
/** * @author http://wiki.lwjgl.org/index.php?title=Taking_Screen_Shots *//*w ww.j a v a 2 s. c o m*/ public void takeScreenShot() { // TODO: get a decent place for this // create the screenshot directory if (!screenshotDir.isDirectory() && !screenshotDir.mkdir()) { EventBus.post( new BubbleNotificationEvent(String.format("Failed to create screenshot directory at '%s'.", screenshotDir.getAbsolutePath()), BubbleNotificationEvent.COMMONCOLOR_RED)); return; } // create file name SimpleDateFormat date = new SimpleDateFormat("yyyyMMdd_HHmmss"); final String fileName = String.format("screenshot_%s.%s", date.format(new Date()), OPTION_SCREENSHOT_FORMAT.getValueString().toLowerCase()); final File file = new File(screenshotDir, fileName); SoundController.playSound(SoundEffect.SHUTTER); // copy the screen to file final int width = Display.getWidth(); final int height = Display.getHeight(); final int bpp = 3; // assuming a 32-bit display with a byte each for red, green, blue, and alpha final ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * bpp); GL11.glReadBuffer(GL11.GL_FRONT); GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1); GL11.glReadPixels(0, 0, width, height, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, buffer); new Thread() { @Override public void run() { try { BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { int i = (x + (width * y)) * bpp; int r = buffer.get(i) & 0xFF; int g = buffer.get(i + 1) & 0xFF; int b = buffer.get(i + 2) & 0xFF; image.setRGB(x, height - (y + 1), (0xFF << 24) | (r << 16) | (g << 8) | b); } } ImageIO.write(image, OPTION_SCREENSHOT_FORMAT.getValueString().toLowerCase(), file); EventBus.post(new BubbleNotificationEvent("Created " + fileName, BubbleNotificationEvent.COMMONCOLOR_PURPLE)); } catch (Exception e) { ErrorHandler.error("Failed to take a screenshot.", e).show(); } } }.start(); }