I am trying to get the screen using glReadPixels() then converting that into an image.
I get an error saying image == null.
ByteBuffer _frame = ByteBuffer.allocate( 4 * Main.gui.glCanvas.getWidth() * Main.gui.glCanvas.getHeight() );
System.out.println( "Num Pixels " + Main.width * Main.height );
gl.glReadPixels(
0,
0,
Main.gui.glCanvas.getWidth(),
Main.gui.glCanvas.getHeight(),
GL3.GL_RGBA,
GL3.GL_UNSIGNED_BYTE,
_frame
);
try {
BufferedImage bi = ImageIO.read( new ByteArrayInputStream( _frame.array() ) );
ImageIO.write( bi, "png", new File( "Slices/slicu.png" ) );
} catch ( Exception e ) {
System.out.println( e.getMessage() + " @ Filler.draw()" );
e.printStackTrace();
}