Now I can get it to do glDrawPixels() perfectly, but it is very slow. When I use the exact same data to try to create a texture it doesn't happen. I just get a blank, white quad!img = viewport.CreateImage(null);
if(img != null)
{
int w = img.getWidth(null);
int h = img.getHeight(null);
int[] pixels = new int[w*h];
PixelGrabber pg = new PixelGrabber(img, 0, 0, w, h, pixels, 0, w);
try
{
pg.grabPixels();
}
catch (Exception e)
{
System.out.println("Pixel Grabbing interrupted!");
}
byte[] bytes = convertARGBtoRGBA(pixels);
pixelBuffer = ByteBuffer.allocateDirect(bytes.length).put(bytes);
pixelBuffer.flip();
texture = makeTexture(pixelBuffer, img.getWidth(null), img.getHeight(null));
}
else
{
System.err.println("Could not load Glg Data");
System.exit(-1);
}
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDrawPixels(img.getWidth(null), img.getHeight(null), GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, pixelBuffer);
GL11.glEnable(GL11.GL_DEPTH_TEST);
Works but...img = viewport.CreateImage(null);
if(img != null)
{
int w = img.getWidth(null);
int h = img.getHeight(null);
int[] pixels = new int[w*h];
PixelGrabber pg = new PixelGrabber(img, 0, 0, w, h, pixels, 0, w);
try
{
pg.grabPixels();
}
catch (Exception e)
{
System.out.println("Pixel Grabbing interrupted!");
}
byte[] bytes = convertARGBtoRGBA(pixels);
pixelBuffer = ByteBuffer.allocateDirect(bytes.length).put(bytes);
pixelBuffer.flip();
texture = makeTexture(pixelBuffer, img.getWidth(null), img.getHeight(null));
}
else
{
System.err.println("Could not load Glg Data");
System.exit(-1);
}
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
GL11.glFrontFace(GL11.GL_CW);
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f( 0.0f, 1.0f); GL11.glVertex3f(-(width/2f), -(height/2f), -0.01f);
GL11.glTexCoord2f( 0.0f, 0.0f); GL11.glVertex3f(-(width/2f), (height/2f), -0.01f);
GL11.glTexCoord2f( 1.0f, 0.0f); GL11.glVertex3f( (width/2f), (height/2f), -0.01f);
GL11.glTexCoord2f( 1.0f, 1.0f); GL11.glVertex3f( (width/2f), -(height/2f), -0.01f);
GL11.glEnd();
Does not! I used the code that napier posted, so it's got to be something that I am doing wrong somewhere else. :x