Author Topic: How to change frame title/icon on lwjgl?  (Read 6437 times)

Offline Mr.Marbles

  • int
  • **
  • Posts: 81
    • View Profile
How to change frame title/icon on lwjgl?
« 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?

Offline Mr.Marbles

  • int
  • **
  • Posts: 81
    • View Profile
Re: How to change frame title/icon on lwjgl?
« Reply #1 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  ???

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: How to change frame title/icon on lwjgl?
« Reply #2 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();
   }

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: How to change frame title/icon on lwjgl?
« Reply #3 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";
Nada por ahora