www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: Mr.Marbles on April 02, 2007, 07:34:03 pm

Title: How to change frame title/icon on lwjgl?
Post by: Mr.Marbles on April 02, 2007, 07:34:03 pm
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?
Title: Re: How to change frame title/icon on lwjgl?
Post by: Mr.Marbles on April 02, 2007, 07:54:10 pm
I just found the API. It's in org.lwjgl.opengl.Display
Code: [Select]
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  ???
Title: Re: How to change frame title/icon on lwjgl?
Post by: EgonOlsen on April 02, 2007, 10:43:14 pm
This is taken directly from Paradroidz. It should be easy to adjust it to your needs:

Code: [Select]
   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();
   }
Title: Re: How to change frame title/icon on lwjgl?
Post by: Melssj5 on April 03, 2007, 01:01:24 am
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";