List of usage examples for org.lwjgl.opengl GL11 glReadPixels
public static void glReadPixels(@NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void *") float[] pixels)
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glReadPixels(int a, int b, int c, int d, int e, int f, ByteBuffer g) { GL11.glReadPixels(a, b, c, d, e, f, g); }
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glReadPixels(int a, int b, int c, int d, int e, int f, long g) { GL11.glReadPixels(a, b, c, d, e, f, g); }
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glReadPixels(int a, int b, int c, int d, int e, int f, ShortBuffer g) { GL11.glReadPixels(a, b, c, d, e, f, g); }
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glReadPixels(int a, int b, int c, int d, int e, int f, IntBuffer g) { GL11.glReadPixels(a, b, c, d, e, f, g); }
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glReadPixels(int a, int b, int c, int d, int e, int f, FloatBuffer g) { GL11.glReadPixels(a, b, c, d, e, f, g); }
From source file:uk.codingbadgers.bUpload.bUpload.java
License:Open Source License
/** * Creates the screenshot./*w w w . j av a2 s.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: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]; }/*from w w w . j av a 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 . ja v a 2 s.c om*/ 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(); }
From source file:zildo.platform.opengl.LwjglOpenGLGestion.java
License:Open Source License
@Override public ByteBuffer capture() { GL11.glReadBuffer(GL11.GL_FRONT);/*from w w w . j a va2s . co m*/ int width = Zildo.screenX; int height = Zildo.screenY; int bpp = 3; // Assuming a 32-bit display with a byte each for red, green, blue, and alpha. ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * bpp); GL11.glReadPixels(0, 0, width, height, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, buffer); return buffer; }
From source file:zsawyer.mods.stereoscopic3d.DebugUtil.java
License:Open Source License
public static void printStencilMap() { try {//from ww w .j a v a 2 s . c o m Minecraft mc = FMLClientHandler.instance().getClient(); int stencilWidth = mc.displayWidth; int stencilHeight = mc.displayHeight; IntBuffer stencilMap = ByteBuffer.allocateDirect(stencilWidth * stencilHeight * 4).asIntBuffer(); stencilMap.rewind(); // stencilMap.order(ByteOrder.nativeOrder()); GL11.glPixelStorei(GL11.GL_PACK_SWAP_BYTES, GL11.GL_TRUE); GL11.glReadPixels(0, 0, stencilWidth, stencilHeight, GL11.GL_STENCIL_INDEX, GL11.GL_INT, stencilMap); checkGLError(); stencilMap.rewind(); PrintWriter out = new PrintWriter("stencilMap.bitmap"); int yPos = 0; while (stencilMap.hasRemaining()) { // int c = Math.abs(stencilMap.get()) % 10; int c = stencilMap.get(); out.print((c & 1)); if (yPos >= stencilWidth - 1) { out.println(""); yPos = -1; } yPos++; } out.close(); } catch (Exception e) { e.printStackTrace(); } }