Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11855 Posts in 1569 Topics- by 3045 Members - Latest Member: lensreslai

10. February 2012, 05:08:01 AM
Xith3D CommunityGeneral CategorySupport (Moderator: Marvin Fröhlich)RenderLoop & HUD example
Pages: [1]
Print
Author Topic: RenderLoop & HUD example  (Read 386 times)
gbrinon
Just dropped in

Offline Offline

Posts: 19



View Profile
« on: 24. February 2010, 07:24:54 AM »

Hi,
I have a little question ?
Where can i find a little example of an HUD implementation with RenderLoop ?
Everywhere i look, this is with InputAdapterRenderLoop.

I can display Widgets but i can make them catch inputs without InputAdapterRenderLoop.
Logged

Guillaume
HEMERA project on XITH3D
Hervé Hager (Agrv)
Administrator
Enjoying the stay
*****
Offline Offline

Posts: 64



View Profile WWW
« Reply #1 on: 24. February 2010, 08:23:34 AM »

Hello,
did you register keyboard and mouse with your canvas ? This should be sufficient to get inputs into your HUD.
Code:
InputSystem.getInstance().registerNewKeyboardAndMouse(canvas.getPeer());

For other inputs you need to extend the InputAdapter class and add it to the InputSystem with the
Code:
InputSystem.getInstance().addInputListener()
method.
Logged

The cake is a lie.
gbrinon
Just dropped in

Offline Offline

Posts: 19



View Profile
« Reply #2 on: 24. February 2010, 11:31:39 AM »

Yes, I'm already doing that :

Code:
this._ISystem = InputSystem.getInstance();
try
{
this._ISystem.registerNewKeyboardAndMouse( this._GCore._canvas.getPeer() );
System.out.println("Keyboard and Mouse registered");
}
catch (InputSystemException e) {System.out.println("Warning, unable to register KB and Mouse");}

this._EAdapter = new EventAdapter(this);
this._ISystem.addInputListener(this._EAdapter);

I get the events on the window but the HUD seem freezed and Frame class method onMouseButtonPressed is never called

I even tried to create a class which implements a WidgetInputListener to make that
Code:
this._GCore._GUI.addGlobalInputListener(new GUIAdapter(this));
But it was ineffective.

All my problems are solved replacing
Code:
public class GraphicsCore extends RenderLoop
by
Code:
public class GraphicsCore extends InputAdapterRenderLoop

But i read that it was a bad idea for "real" games
Logged

Guillaume
HEMERA project on XITH3D
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4337


May the 4th, be with you...


View Profile
« Reply #3 on: 24. February 2010, 01:29:29 PM »

Please have a look at the InputAdapterRenderLoop's implementation. There are really just a few lines of code in it (apart from empty stubs).

But I guess, I know, what the problem is. Please call this method before you add the HUD to the environemnt.
Code:
InputSystem.getInstance();
It is sufficient to call this method in any way. So if you register a new keyboard and mouse, you will call this method automatically.

Marvin
Logged
gbrinon
Just dropped in

Offline Offline

Posts: 19



View Profile
« Reply #4 on: 24. February 2010, 09:52:49 PM »

It works !!
Thanks a lot
Logged

Guillaume
HEMERA project on XITH3D
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic