画像を描画したいのですが、何をしても機能していないようです。レンダリングに使用されるコード:
BufferedImage bi = null;
int w = 0;
int h = 0;
try {
bi = ImageIO.read(new File("win.png"));
w = bi.getWidth();
h = bi.getHeight();
} catch (Exception e) {
System.out.println(e.getMessage());
}
final GL2 gl = gLDrawable.getGL().getGL2();
WritableRaster raster =
Raster.createInterleavedRaster (DataBuffer.TYPE_BYTE,
w,
h,
4,
null);
ComponentColorModel colorModel=
new ComponentColorModel (ColorSpace.getInstance(ColorSpace.CS_sRGB),
new int[] {8,8,8,8},
true,
false,
ComponentColorModel.TRANSLUCENT,
DataBuffer.TYPE_BYTE);
BufferedImage dukeImg =
new BufferedImage (colorModel,
raster,
false,
null);
Graphics2D g = dukeImg.createGraphics();
g.drawImage(bi, null, null);
DataBufferByte dukeBuf =
(DataBufferByte)raster.getDataBuffer();
byte[] dukeRGBA = dukeBuf.getData();
ByteBuffer bb = ByteBuffer.wrap(dukeRGBA);
bb.position(0);
bb.mark();
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR);
gl.glEnable(GL2.GL_TEXTURE_2D);
gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_DECAL);
gl.glBindTexture(GL2.GL_TEXTURE_2D, 13);
gl.glPixelStorei(GL2.GL_UNPACK_ALIGNMENT, 1);
gl.glTexImage2D (GL2.GL_TEXTURE_2D, 0, GL2.GL_RGBA, w, h, 0, GL2.GL_RGBA,
GL2.GL_UNSIGNED_BYTE, bb);
int left = 100;
int top = 100;
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2d (0, 0);
gl.glVertex3f (left,top, 0);
gl.glTexCoord2d(1,0);
gl.glVertex3f (left + w, top, 0);
gl.glTexCoord2d(1,1);
gl.glVertex3f (left + w, top + h, 0);
gl.glTexCoord2d(0,1);
gl.glVertex3f (left, top + h, 0);
gl.glEnd ();
gl.glFlush();