free_ice_cream
free_ice_cream

Reputation: 85

OpenGL - Getting The Display Color Bits

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?

Upvotes: 0

Views: 274

Answers (1)

Quaggles
Quaggles

Reputation: 63

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

Upvotes: 2

Related Questions