So I am posting this here instead of on the lwjgl forums as a similar question was asked but no one answered. In the particle editor I am making I have it so you can export the effect into a sprite sheet using glReadPixels. Everything works fine except that the alpha seems off. When you have grayer images that are not colored it is like everything gets jacked up. I thought it had something to do with how opengl has unsigned and java does not but after printing the results back everything is fine no negatives.
here is how I am taking the screenshot or pixels from screen.
public static BufferedImage screenShot(int startX, int startY, int width, int height)
{
glReadBuffer(GL11.GL_FRONT);
ByteBuffer buffer = ByteBuffer.allocateDirect((width * height * 4 *4));
glReadPixels(startX, startY, width, height, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer);
BufferedImage image = BufferedImageUtils.getCompatibleImage(width, height);
image = new BufferedImage(width,height,BufferedImage.TYPE_INT_ARGB);
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
int i = (x + ( width * y)) * 4;
int r = buffer.get(i) & 0xff;
int g = buffer.get(i + 1) & 0xff ;
int b = buffer.get(i + 2) & 0xff ;
int a = buffer.get(i + 3) & 0xff;
// a *= 2;
//System.out.println("Alpha: "+a);
if(r > 0)
System.out.println("Alpha: " + a + " R: " + r + " G: " + g + " B: " + b + " A: " + a);
image.setRGB(x, height - (y + 1), ( a << 24) | (r << 16) | (g << 8) |b );
// image.setRGB(x, height - (y + 1), buff.get(x+(width*y)));
}
}
return image;
}
When I drop trying to get the alpha it looks fine so I have to be doing something wrong here.