Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (408)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Problem with FPSCounter  (Read 1223 times)
0 Members and 1 Guest are viewing this topic.
Offline rafa_es

Junior Member





« Posted 2006-10-03 02:41:49 »

Im trying to make a FPS window to my game but im getting a NullPointerException
Do you guys know why
The is the same from BSPTest

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
    private BranchGroup createHUD(ExtXith3DEnvironment env, RenderPassConfigProvider passConfig, Canvas3D canvas, Xith3DDemoFolder demoFolder) throws Exception
    {
        BranchGroup hudBranch = new BranchGroup();
       
        HUD hud = new HUD(canvas, 800, 600, this);
       
        Image crosshair = new Image(hud.getSizeOfPixels(32, 32), "src/Textures/CrosshairWhite.png", true);
        hud.addWidget(crosshair, (hud.getResolution().x - crosshair.getWidth()) / 2f, (hud.getResolution().y - crosshair.getHeight()) / 2f);

        FPSCounter fpsCounter = new FPSCounter(100, 30, "src/Textures/YellowBorder.png");
        fpsCounter.setFontColor( new Color3f(0.12f, 1.0f, 0.18f) );
        this.addFPSListener(fpsCounter);
        hud.addWidget(fpsCounter, 650, 520);        
       
        hudBranch.addChild(hud);
       
        env.addBranchGraph( hudBranch );        
        env.addRenderPass( new RenderPass(hudBranch, passConfig) );
       
        return( hudBranch );
    }


Whe i try to run i get this error

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
Exception in thread "main" java.lang.NullPointerException
        at org.xith3d.ui.hud.utils.WidgetTheme.<init>(WidgetTheme.java:473)
        at org.xith3d.ui.hud.utils.WidgetTheme.<init>(WidgetTheme.java:500)
        at org.xith3d.ui.hud.HUD.getTheme(HUD.java:172)
        at org.xith3d.ui.hud.widgets.Label.<init>(Label.java:639)
        at org.xith3d.ui.hud.widgets.Label.<init>(Label.java:657)
        at org.xith3d.ui.hud.widgets.FPSCounter.<init>(FPSCounter.java:160)
        at org.xith3d.ui.hud.widgets.FPSCounter.<init>(FPSCounter.java:221)
        at org.xith3d.ui.hud.widgets.FPSCounter.<init>(FPSCounter.java:281)
        at Project.game.createHUD(game.java:122)
        at Project.game.<init>(game.java:152)
        at Project.game.main(game.java:174)


I tryied to run the BSPTest and it runs well but it dosent appear the FPS window
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #1 - Posted 2006-10-03 14:38:44 »

There's a commented line:
1  
//createHUD(env, new RenderPassConfig(RenderPassConfig.PARALLEL_PROJECTION), canvas, demoFolder);


Uncomment it and the FPS window (and the crosshair) will appear. You'll have to use it the same or a similar way. Please tell me, if it worked for you.

Marvin
Offline rafa_es

Junior Member





« Reply #2 - Posted 2006-10-03 14:58:42 »

The line is already uncommented but in the BSPTest i get the same error that i get on my code

The NullPointerException on new FPSCOunter
Games published by our own members! Check 'em out!
Play the free demo of Revenge of the Titans!
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #3 - Posted 2006-10-03 15:54:18 »

The line is already uncommented but in the BSPTest i get the same error that i get on my code

The NullPointerException on new FPSCOunter

Hmm... I doublechecked the thing... No NullPointerException Huh Did you do a fresh CVS checkout? Maybe you last checked out while I was currently checking in.
Offline rafa_es

Junior Member





« Reply #4 - Posted 2006-10-03 19:04:38 »

Hmm... I doublechecked the thing... No NullPointerException Huh Did you do a fresh CVS checkout? Maybe you last checked out while I was currently checking in.

I´ll check my CVS again and reply if it has worked
Offline rafa_es

Junior Member





« Reply #5 - Posted 2006-10-03 22:23:23 »

Hmm... I doublechecked the thing... No NullPointerException Huh Did you do a fresh CVS checkout? Maybe you last checked out while I was currently checking in.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
Exception in thread "main" java.lang.NullPointerException
        at org.xith3d.ui.hud.utils.WidgetTheme.<init>(WidgetTheme.java:473)
        at org.xith3d.ui.hud.utils.WidgetTheme.<init>(WidgetTheme.java:500)
        at org.xith3d.ui.hud.HUD.getTheme(HUD.java:172)
        at org.xith3d.ui.hud.widgets.Label.<init>(Label.java:639)
        at org.xith3d.ui.hud.widgets.Label.<init>(Label.java:657)
        at org.xith3d.ui.hud.widgets.FPSCounter.<init>(FPSCounter.java:160)
        at org.xith3d.ui.hud.widgets.FPSCounter.<init>(FPSCounter.java:221)
        at org.xith3d.ui.hud.widgets.FPSCounter.<init>(FPSCounter.java:281)
        at javaapplication31.BSPLoaderTest.createHUD(BSPLoaderTest.java:217)
        at javaapplication31.BSPLoaderTest.<init>(BSPLoaderTest.java:248)
        at javaapplication31.BSPLoaderTest.main(BSPLoaderTest.java:276)
BUILD SUCCESSFUL (total time: 8 seconds)


I´ve downloaded de CVS again and still get the NullPointerException  on  this line of the createHud method
FPSCounter fpsCounter = new FPSCounter(100, 30, "YellowBorder.png");

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
    private BranchGroup createHUD(ExtXith3DEnvironment env, RenderPassConfigProvider passConfig, Canvas3D canvas, Xith3DDemoFolder demoFolder) throws Exception
    {
        TextureLoader.getInstance().addTextureStreamLocator(new TextureStreamLocatorFile(demoFolder.hud()));
       
        BranchGroup hudBranch = new BranchGroup();
       
        HUD hud = new HUD(canvas, 800, 600, this);
       
        Image crosshair = new Image(hud.getSizeOfPixels(64, 64), "CrosshairWhite.png", true);
        hud.addWidget(crosshair, (hud.getResolution().x - crosshair.getWidth()) / 2f, (hud.getResolution().y - crosshair.getHeight()) / 2f);
       
        FPSCounter fpsCounter = new FPSCounter(100, 30, "YellowBorder.png");
        fpsCounter.setFontColor( new Color3f(0.12f, 1.0f, 0.18f) );
        this.addFPSListener(fpsCounter);
        hud.addWidget(fpsCounter, 650, 520);
       
        hudBranch.addChild(hud);
       
        env.addBranchGraph( hudBranch );        
        env.addRenderPass( new RenderPass(hudBranch, passConfig) );
       
        return( hudBranch );
    }


Have any ideas why?
When you run this test with the uncommented line and you the the FPS window ?
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #6 - Posted 2006-10-03 22:37:15 »

Seems like the GTK theme file is missing. Please check, if the file org.xith3d.ui.hud.resources.themes.GTK.xwt exists in your source tree. If it doesn't, this is your error and please check, why your eclipse (or what ever you're using) doesn't checkout this file. If it does exist, please dig into the code (org.xith3d.ui.hud.util.WidgetTheme, line #500). This is where the error occurrs. Maybe I'm using getResourceAsStream in a wrong way.

Anyway the line
1  
HUD.class.getResourceAsStream("resources/themes/" + name + ".xwt")

returns null. Please check why. It doesn't on my system.

Marvin
Offline rafa_es

Junior Member





« Reply #7 - Posted 2006-10-03 23:29:46 »

Seems like the GTK theme file is missing. Please check, if the file org.xith3d.ui.hud.resources.themes.GTK.xwt exists in your source tree. If it doesn't, this is your error and please check, why your eclipse (or what ever you're using) doesn't checkout this file. If it does exist, please dig into the code (org.xith3d.ui.hud.util.WidgetTheme, line #500). This is where the error occurrs. Maybe I'm using getResourceAsStream in a wrong way.

Anyway the line
1  
HUD.class.getResourceAsStream("resources/themes/" + name + ".xwt")

returns null. Please check why. It doesn't on my system.

Marvin

Thanks Marvin,
The problem was that when i compiled the cvs it was not adding themes/GTK.xwt to the jar file or to class folder (Maybe a problem with Netbeans) so i added it manually and it worked
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #8 - Posted 2006-10-03 23:34:34 »

Thanks Marvin,
The problem was that when i compiled the cvs it was not adding themes/GTK.xwt to the jar file or to class folder (Maybe a problem with Netbeans) so i added it manually and it worked

Good to know Smiley.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (119 views)
2013-05-17 21:29:12

alaslipknot (126 views)
2013-05-16 21:24:48

gouessej (157 views)
2013-05-16 00:53:38

gouessej (147 views)
2013-05-16 00:17:58

theagentd (162 views)
2013-05-15 15:01:13

theagentd (147 views)
2013-05-15 15:00:54

StreetDoggy (191 views)
2013-05-14 15:56:26

kutucuk (215 views)
2013-05-12 17:10:36

kutucuk (214 views)
2013-05-12 15:36:09

UnluckyDevil (217 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.067 seconds with 22 queries.