Slick Forums

Discuss the Slick 2D Library
It is currently Wed Jun 19, 2013 6:58 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Jun 08, 2012 8:39 pm 
Offline

Joined: Fri Jun 08, 2012 8:22 pm
Posts: 1
I started looking into slick and LWJGL this morning but I can't get spritesheetfonts to work. Here is my code:
Code:
public class MainDisplay {
   public static int WIDTH = 448;
   public static int HEIGHT = 224;
   SpriteSheetFont font;
   
   public void start() {
      try {
         Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
         Display.create();
      } catch (LWJGLException e) {
         e.printStackTrace();
         System.exit(0);
      }
      
      // Initialize
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      glOrtho(0, WIDTH, HEIGHT, 0, 1, -1);
      glMatrixMode(GL_MODELVIEW);
      
      init();
      
      while (!Display.isCloseRequested()) {
         // render
         paint();
         
         Display.update();
         Display.sync(30);
      }
      
      Display.destroy();
   }
   
   private void paint() {
      glClear(GL_COLOR_BUFFER_BIT);
      font.drawString(0, 0, "This is a test string");
      glDisable(GL_TEXTURE_2D);
   }
   
   public void init() {
      try {
         font = new SpriteSheetFont(new SpriteSheet("Spritesheet.png", 8, 8, Color.white), (char) 0);
      } catch (SlickException e) {
         e.printStackTrace();
      }
   }

   public static void main(String[] args) {
      MainDisplay display = new MainDisplay();
      display.start();
   }
}

But all that shows up are 8x8 white squares. Here is my sprite sheet:

Image

What am I doing wrong/missing?


Top
 Profile  
 
PostPosted: Sun Jun 10, 2012 10:34 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1477
Don't disable textures every frame. Instead, do this before drawing fonts or images:
Code:
GL11.glEnable(GL11.GL_TEXTURE_2D);


Why not use Slick's game loop (BasicGame, AppGameContainer, etc) instead?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group