LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Toby on April 19, 2005, 13:11:44

Title: Bug in Mac OSX?
Post by: Toby on April 19, 2005, 13:11:44
Hi,

Ive been looking at some code which has the following:

   private void setupFont()
   {
       boolean fontLoaded = IL.ilLoadImage("font.png");
       if (!fontLoaded)
       {
           System.out.println ("Error loading font file:font.png");
           System.exit(1) ;                        
       }
       
       font_texture = ILUT.ilutGLBindMipmaps();
       
       font_dlist_base = GL11.glGenLists(256);  
       float textureDelta = 1.0f / 16.0f;
       for(int i=0;i<256;i++)
       {
           float u = ((float)(i % 16)) / 16.0f;
           float v = (((float)(i / 16)) / 16.0f);
           GL11.glNewList(font_dlist_base + i, GL11.GL_COMPILE);
           GL11.glBindTexture(GL11.GL_TEXTURE_2D, font_texture);
           GL11.glBegin(GL11.GL_QUADS);
           GL11.glTexCoord2f(u, v);
           GL11.glVertex2f(-0.0450f, -0.0450f);
           GL11.glTexCoord2f((u + textureDelta), v);
           GL11.glVertex2f(0.0450f, -0.0450f);
           GL11.glTexCoord2f((u + textureDelta), v + textureDelta);
           GL11.glVertex2f(0.0450f, 0.0450f);
           GL11.glTexCoord2f(u, v + textureDelta);
           GL11.glVertex2f(-0.0450f, 0.0450f);
           GL11.glEnd();
           GL11.glEndList();
       }
   }

   /*
    *
    */
   public void glPrint(String msg, float x, float y, float xscale, float yscale) {                                      // Custom GL "Print" Routine
       if(msg != null)
       {          
           GL11.glLoadIdentity();
           GL11.glEnable(GL11.GL_TEXTURE_2D);
           GL11.glTranslatef(x,y,0);
           GL11.glScalef(xscale,yscale,0);
           GL11.glTranslatef(0,-0.0450f,0);
           for(int i=0;i<msg.length();i++)
           {
                GL11.glCallList(font_dlist_base + msg.charAt(i));
                //System.out.print(font_dlist_base + msg.charAt(i)+" ") ;
                GL11.glTranslatef(0.05f, 0.0f, 0.0f);
           }
           //System.out.println();
           GL11.glDisable(GL11.GL_TEXTURE_2D);
           GL11.glLoadIdentity();
       }
   }


Now when you use glPrint you on the PC you get the text you would expect, however on Mac it gives complete random text. Anyone got any ideas?