I'm trying to find a way to access the native window that gets created with the FrameBuffer.displayGLOnly() method. I need to change the title and icon of this window. I notice that the title is "http://www.jpct.net" so it seems that jPCT has access to this window and is modifying the title. Is it possible to get a reference to this window through jPCT?
I just found the API. It's in org.lwjgl.opengl.Display
public static void setTitle(java.lang.String newTitle);
public static int setIcon(java.nio.ByteBuffer[] icons);
Now all I need to find out is how to get a ByteBuffer out of an Image ???
This is taken directly from Paradroidz. It should be easy to adjust it to your needs:
private IntBuffer createBuffer(Image img) {
int len=img.getHeight(null)*img.getWidth(null);
ByteBuffer temp=ByteBuffer.allocateDirect(len<<2);;
temp.order(ByteOrder.LITTLE_ENDIAN);
int[] pixels=new int[len];
PixelGrabber pg=new PixelGrabber(img, 0, 0, img.getWidth(null), img.getHeight(null), pixels, 0, img.getWidth(null));
try {
pg.grabPixels();
} catch (InterruptedException e) {
Logger.log("Could not grab pixels from image!", Logger.ERROR);
}
for (int i=0; i<len; i++) {
int pos=i<<2;
int texel=pixels[i];
if (texel!=0) {
texel|=0xff000000;
}
temp.putInt(pos, texel);
}
return temp.asIntBuffer();
}
The Config class has what you need to change the title of the windows when using hardware rendering. For changing the icon, then I dont know.
for example.
Config.glWindowName="My own game";