Slick Forums

Discuss the Slick 2D Library
It is currently Fri May 24, 2013 7:19 am

All times are UTC




Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject:
PostPosted: Mon Dec 20, 2010 11:35 pm 
Offline

Joined: Mon Dec 20, 2010 11:26 pm
Posts: 4
I keep getting a nullPointerException on line 7 of this code ( uFont.loadGlyphs() )
Code:
try{
      Font font=new Font( "Verdana", Font.PLAIN, 40 );
      UnicodeFont uFont = new UnicodeFont(font, 40, false, false);
      uFont.addAsciiGlyphs();
      uFont.getEffects().add(new ColorEffect(java.awt.Color.WHITE));
      uFont.loadGlyphs();
      uFont.drawString(100, 100, "generic test message");
   }catch(SlickException e){
      e.printStackTrace();
   }


could anyone point me in the direction of my mistake? Because for the life of me, I cannot find it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 21, 2010 10:38 am 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Post the exception?

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 21, 2010 12:25 pm 
Offline

Joined: Mon Dec 20, 2010 11:26 pm
Posts: 4
This is it:
Quote:
Exception in thread "main" java.lang.NullPointerException
at org.lwjgl.opengl.GL11.glGenTextures(GL11.java:1348)
at org.newdawn.slick.opengl.InternalTextureLoader.createTextureID(InternalTextureLoader.java:106)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:359)
at org.newdawn.slick.opengl.InternalTextureLoader.createTexture(InternalTextureLoader.java:343)
at org.newdawn.slick.opengl.InternalTextureLoader.createTexture(InternalTextureLoader.java:329)
at org.newdawn.slick.Image.<init>(Image.java:238)
at org.newdawn.slick.font.GlyphPage.<init>(GlyphPage.java:107)
at org.newdawn.slick.UnicodeFont.loadGlyphs(UnicodeFont.java:374)
at org.newdawn.slick.UnicodeFont.loadGlyphs(UnicodeFont.java:325)
at SlickApp1.FancyText.<init>(FancyText.java:43)
at SlickApp1.FancyText.main(FancyText.java:56)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 21, 2010 12:27 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
You trying to load the texture on a different thread?

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 21, 2010 1:10 pm 
Offline

Joined: Mon Dec 20, 2010 11:26 pm
Posts: 4
I just inserted that bit of code into the basic example code from the setup tutorial, nothing fancy. I wanted to try out some of the different effects.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 21, 2010 1:41 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Looks like you're trying to load the font in the constructor of FancyText, you can't do it there because the GL context hasn't been created there.

Move it into init() of the game implementation.

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 21, 2010 2:37 pm 
Offline

Joined: Mon Dec 20, 2010 11:26 pm
Posts: 4
Yes, that did the trick! Thank you :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


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