0

I'm looking at the LWJGL wiki for taking a screenshot (found here) and I noticed the comment Assuming a 32-bit display with a byte each for red, green, blue, and alpha. in this code:

GL11.glReadBuffer(GL11.GL_FRONT);
int width = Display.getDisplayMode().getWidth();
int height= Display.getDisplayMode().getHeight();
int bpp = 4; // 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_RGBA, GL11.GL_UNSIGNED_BYTE, buffer );

How would I change the var bpp based off of the current system?

2
  • What do you mean by 'current system'? Commented May 19, 2013 at 8:40
  • OpenGL should not be abused for creating screenshots of the system display. You can use it to store the contents of a OpenGL drawable's contents, but the sometimes found technique of creating a fullscreen, bottom layer window to grab a screenshot is highly unreliable. Commented May 19, 2013 at 9:36

1 Answer 1

2

In case you're still looking for an answer:

You can get the bytes per pixel of the current display mode by getting it from LWJGL's Display class. It would look something like this:

int bpp = Display.getDisplayMode().getBitsPerPixel()/4
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.