Example usage for org.lwjgl.opengl GL11 nglGetIntegerv

List of usage examples for org.lwjgl.opengl GL11 nglGetIntegerv

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 nglGetIntegerv.

Prototype

public static void nglGetIntegerv(int pname, long params) 

Source Link

Document

Unsafe version of: #glGetIntegerv GetIntegerv

Usage

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.//  w  w w  . j  a v  a  2s  .c o  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;
}