Slick Forums

Discuss the Slick 2D Library
It is currently Wed May 22, 2013 7:46 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Hello TWL example
PostPosted: Fri Aug 31, 2012 7:29 am 
Offline

Joined: Tue Mar 06, 2012 1:15 am
Posts: 25
Hi all,

im having problem setting up TWL.. i followed this thread on getting started with TWL http://slick.javaunlimited.net/viewtopic.php?f=18&t=5398.

I could now load the theme.xml but there's an error when i run the code.

here's the stacktrace

Code:
Fri Aug 31 15:22:08 CST 2012 INFO:Slick Build #274
Fri Aug 31 15:22:08 CST 2012 INFO:LWJGL Version: 2.0b1
Fri Aug 31 15:22:08 CST 2012 INFO:OriginalDisplayMode: 1600 x 900 x 32 @50Hz
Fri Aug 31 15:22:08 CST 2012 INFO:TargetDisplayMode: 600 x 600 x 0 @0Hz
Fri Aug 31 15:22:09 CST 2012 INFO:Starting display 600x600
Fri Aug 31 15:22:09 CST 2012 INFO:Use Java PNG Loader = true
Fri Aug 31 15:22:09 CST 2012 INFO:Controllers not available
Fri Aug 31 15:22:09 CST 2012 ERROR:Could not initialize TWL GUI
org.newdawn.slick.SlickException: Could not initialize TWL GUI
   at TWLSlick.TWLStateBasedGame.initGUI(TWLStateBasedGame.java:145)
   at TWLSlick.TWLStateBasedGame.setRootPane(TWLStateBasedGame.java:125)
   at TWLSlick.BasicTWLGameState.enter(BasicTWLGameState.java:80)
   at com.xxx.game.HelloState.enter(HelloState.java:23)
   at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:175)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
   at com.wakkana.game.TestTWL.main(TestTWL.java:26)
Caused by: java.lang.NoSuchMethodError: org/lwjgl/opengl/GL11.glGenTextures()I
   at de.matthiasmann.twl.renderer.lwjgl.LWJGLTexture.<init>(LWJGLTexture.java:112)
   at de.matthiasmann.twl.renderer.lwjgl.LWJGLCacheContext.createTexture(LWJGLCacheContext.java:106)
   at de.matthiasmann.twl.renderer.lwjgl.LWJGLCacheContext.loadTexture(LWJGLCacheContext.java:67)
   at de.matthiasmann.twl.renderer.lwjgl.LWJGLRenderer.load(LWJGLRenderer.java:519)
   at de.matthiasmann.twl.renderer.lwjgl.LWJGLRenderer.load(LWJGLRenderer.java:508)
   at de.matthiasmann.twl.renderer.lwjgl.LWJGLRenderer.loadTexture(LWJGLRenderer.java:379)
   at de.matthiasmann.twl.theme.ImageManager.parseImages(ImageManager.java:131)
   at de.matthiasmann.twl.theme.ThemeManager.parseThemeFile(ThemeManager.java:292)
   at de.matthiasmann.twl.theme.ThemeManager.parseThemeFile(ThemeManager.java:271)
   at de.matthiasmann.twl.theme.ThemeManager.createThemeManager(ThemeManager.java:190)
   at de.matthiasmann.twl.theme.ThemeManager.createThemeManager(ThemeManager.java:155)
   at TWLSlick.TWLStateBasedGame.loadTheme(TWLStateBasedGame.java:119)
   at TWLSlick.TWLStateBasedGame.initGUI(TWLStateBasedGame.java:136)
   ... 7 more


here's the code for my statebasegame class

Code:
package com.wakkana.game;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.SlickException;

import TWLSlick.TWLStateBasedGame;

public class TestTWL extends TWLStateBasedGame{

   protected TestTWL() {
      super("HelloSlickTWL");
   }

   public static void main(String[] args) {
         try {
            AppGameContainer app = new AppGameContainer(new TestTWL());
            app.setTargetFrameRate(60);
            app.setMaximumLogicUpdateInterval(16);
            app.setMinimumLogicUpdateInterval(16);
            app.setDisplayMode(600,600,false);
            app.start();
         } catch (SlickException e) {
            e.printStackTrace();
         }
      }

      @Override
      protected URL getThemeURL() {
//         System.out.println(TestTWL.class.getResource("/assets/theme/theme.xml").toString());
//         return TestTWL.class.getResource("/assets/theme/theme.xml");
         try {
         URL applicationPath = new java.io.File("assets/theme/theme.xml").toURI().toURL();
         return applicationPath;
      } catch (MalformedURLException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }
//         try {
//           
//         //return new java.io.File("").getAbsolutePath();//new File("/assets/theme/theme.xml").toURI().toURL();
//      } catch (MalformedURLException e) {
//         // TODO Auto-generated catch block
//         e.printStackTrace();
//      }
      return null;

      }

      @Override
      public void initStatesList(GameContainer arg0) throws SlickException {
         addState(new HelloState());
      }

}



and here's the code for my HelloState class:
Code:
package com.wakkana.game;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.StateBasedGame;

import TWLSlick.BasicTWLGameState;

import de.matthiasmann.twl.Button;

public class HelloState extends BasicTWLGameState {

   @Override
   public int getID() {
      return 1;
   }
   
  @Override
   public void enter(GameContainer container, StateBasedGame game)
         throws SlickException {
      // TODO Auto-generated method stub
super.enter(container, game);
     
      Button btn = new Button("Hello world");
      btn.setSize(100,50);
      btn.setPosition(300, 300);
      btn.addCallback(new Runnable() {
         @Override
         public void run() {
            System.out.println("Hello Slick world! This button works!");
         }
      });
      getRootPane().add(btn);
   }
   
   @Override
   public void init(GameContainer container, StateBasedGame game)
         throws SlickException {}   
   @Override
   public void render(GameContainer container, StateBasedGame game, Graphics g)
         throws SlickException {}
   @Override
   public void update(GameContainer container, StateBasedGame game, int delta)
         throws SlickException {}
}


help.. someone? thanks..


Top
 Profile  
 
 Post subject: Re: Hello TWL example
PostPosted: Fri Aug 31, 2012 7:37 am 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
are you using lastest twl.jar?

I bet it can't find your theme file, look at 3rd question down: viewtopic.php?f=18&t=2470


Top
 Profile  
 
 Post subject: Re: Hello TWL example
PostPosted: Fri Aug 31, 2012 10:11 am 
Offline

Joined: Tue Mar 06, 2012 1:15 am
Posts: 25
dime wrote:
are you using lastest twl.jar?

I bet it can't find your theme file, look at 3rd question down: viewtopic.php?f=18&t=2470



yes.. im currently using the latest twl.jar.. also i think my application has the correct path for the theme file.. i had a
Code:
url is null
error awhile ago and fixed it. but after fixing it i got the error stated above. i think its cause is
Code:
Caused by: java.lang.NoSuchMethodError: org/lwjgl/opengl/GL11.glGenTextures()I
but i dont have any idea how to fix it.


Top
 Profile  
 
 Post subject: Re: Hello TWL example
PostPosted: Fri Aug 31, 2012 4:55 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1172
Your LWJGL version is way too old - download the latest version from http://www.lwjgl.org

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject: Re: Hello TWL example
PostPosted: Mon Sep 03, 2012 3:40 am 
Offline

Joined: Tue Mar 06, 2012 1:15 am
Posts: 25
MatthiasM wrote:
Your LWJGL version is way too old - download the latest version from http://www.lwjgl.org


great! thanks.. it works now..


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

All times are UTC


Who is online

Users browsing this forum: No registered users 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