List of usage examples for org.lwjgl.opengl GL11 nglReadPixels
public static void nglReadPixels(int x, int y, int width, int height, int format, int type, long pixels)
From source file:com.samrj.devil.gl.DGL.java
License:Open Source License
/** * Creates a new image from the current read framebuffer and viewport. * Useful for taking screenshots./*from w ww . j av a 2 s. co m*/ * * @return A newly allocated image. */ public static Image screenshotImage() { int x, y, w, h; { long xAddr = MemStack.push(4); long yAddr = MemStack.push(4); long wAddr = MemStack.push(4); long hAddr = MemStack.push(4); GL11.nglGetIntegerv(GL11.GL_VIEWPORT, xAddr); x = MemoryUtil.memGetInt(xAddr); y = MemoryUtil.memGetInt(yAddr); w = MemoryUtil.memGetInt(wAddr); h = MemoryUtil.memGetInt(hAddr); MemStack.pop(4); } Image out = genImage(w, h, 3, PrimType.BYTE); GL11.nglReadPixels(x, y, w, h, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, out.address()); return out; }