Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
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 1552 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!
Legends of Yore - The Casual Retro Roguelike
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.

 

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

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (25 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (43 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
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!