Example usage for org.lwjgl.opengl GL11 glPixelStorei

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

Introduction

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

Prototype

public static void glPixelStorei(@NativeType("GLenum") int pname, @NativeType("GLint") int param) 

Source Link

Document

Sets the integer value of a pixel store parameter.

Usage

From source file:zsawyer.mods.stereoscopic3d.DebugUtil.java

License:Open Source License

public static void printStencilMap() {
    try {/*w  ww  .  j  ava2  s. co 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();
    }

}

From source file:zsawyer.mods.stereoscopic3d.renderers.StencilingRenderer.java

License:Open Source License

protected boolean isReinitRequired() {
    stencilMap.rewind();/*from   w w w.j  ava  2 s .  com*/

    GL11.glPixelStorei(GL11.GL_PACK_SWAP_BYTES, GL11.GL_TRUE);
    GL11.glReadPixels(0, 0, stencilTestWidth, stencilTestHeight, GL11.GL_STENCIL_INDEX, GL11.GL_INT,
            stencilMap);
    DebugUtil.checkGLError();

    return stencilMap.get(0) != 1;
}