Author Topic: attach/add mouse listener  (Read 1097 times)

Offline jdwired

  • byte
  • *
  • Posts: 4
    • View Profile
attach/add mouse listener
« on: January 03, 2016, 02:30:52 pm »
Hello there,

I am trying to work on a simple gui with buttons (for that I use blit).
I am working with AWTRenderer.

My question:
How can I attach/add a mouse listener to the image(s) of the blit texture(s) ?

Thanks in advance for any help on that issue.

Regards


 

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: attach/add mouse listener
« Reply #1 on: January 03, 2016, 02:47:01 pm »
You have to do that yourself in your own code. jPCT is a 3D engine, not a GUI library. It has no concept of mouse pointers or listeners. The fact that it renders into an AWT Canvas doesn't mean that it has any knowledge of AWT components.
You have to query the mouse yourself (either by the means that AWT provides or by using the Mouse-class from lwjgl if you are rendering into a native window). You can then add a simple listener on top of that.
The Robombs source code contains some basic GUI classes that might show the idea.

Offline jdwired

  • byte
  • *
  • Posts: 4
    • View Profile
Re: attach/add mouse listener
« Reply #2 on: January 03, 2016, 03:09:22 pm »
Thanks Egon - makes sense anyway - however just was wondering because the engine already provides so many useful helper classes (including MouseMapper, etc)... thought maybe I missed something.

So with an eye on productivity, it probably makes sense using and customizing the existing awt components?

I will check out the source samples now.

So far thanks for you help!

 

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: attach/add mouse listener
« Reply #3 on: January 03, 2016, 04:43:36 pm »
So with an eye on productivity, it probably makes sense using and customizing the existing awt components?
No, it's almost impossible to mix GL and AWT components on the same canvas. Depending on your application, you might want to render the GUI in another frame or window and in that case, you can happily use AWT or Swing. But don't try to mix them, it won't turn out well.

Offline jdwired

  • byte
  • *
  • Posts: 4
    • View Profile
Re: attach/add mouse listener
« Reply #4 on: January 05, 2016, 09:57:55 pm »
Hi Egon,

used the time to check out the robombs source for building an ingame menu/gui.
The movement of the blit textures with mouse mapper is pretty forward and already working for me.

However I was especially interested in the text editing/ text input. If I click the TextField the cursor image appears,
but I am unable to edit the text. It seems I do not receive any key events...

For that I have checked (also I was interested in the input/edit performance) the robombs game itself.
I am running ubuntu 15.10 gnome shell / oracle 8 jdk

Fullscreen is not working properly on gnome shell - which I meanwhile found out is a bug of the gnome shell.
(The window is somehow shifted on the screen).
Then I switched to Unity , where full screen is working correctly.

But in both cases the keyboard input did not work. I was unable to add or edit text in any way - eg Player Name field.

Just to be sure , I started windows , and there everything is working properly - including the text input/edit.

enclosed shell start stuff

//bin  botnames.txt  data  lib  Robombs.cmd  Robombs.sh
wired@wired-notebook:~/Downloads/robombs$ sh ./Robombs.sh
Loading Texture...from Image
Loading Texture...from Image
Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /home/wired/Downloads/robombs/lib/lwjgl-2.7.1/native/linux/liblwjgl.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
NVIDIA Corporation-NVS 5200M/PCIe/SSE2/true/false/true/true/true
[5200]
Loading configuration...
Saving configuration...
Loading Texture...from InputStream
Loading Texture...from InputStream

....

Starting up SoundSystem...
Initializing LWJGL OpenAL
    (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
OpenAL initialized.

Java version is: 1.8.0_60
-> support for BufferedImage
Version helper for 1.5+ initialized!
-> using BufferedImage
Software renderer (OpenGL mode) initialized
Software renderer disposed
Current mode:640 x 480 x 24 @58Hz
Driver is: unknown OpenGL driver on NVIDIA Corporation / NVS 5200M/PCIe/SSE2
GL_ARB_texture_env_combine supported and used!
FBO supported and used!
VBO supported and used!
OpenGL renderer initialized (using 4 texture stages)
Loading Texture...from InputStream

 ...

Loading Texture...from InputStream
[ Tue Jan 05 21:52:46 CET 2016 ] - WARNING: Unsupported Texture width (200)...resizing to a width of 256 pixels!
Loading Texture...from InputStream
Loading Texture...from Image
Loading Texture...from Image

SoundSystem shutting down...
    Author: Paul Lamb, www.paulscode.com

Visibility lists disposed!
Game terminated!

///

I ll check out gfx drivers as well as alternative desktop managers.

Thanks for any help on that.

Regards

« Last Edit: January 05, 2016, 10:00:09 pm by jdwired »

Offline jdwired

  • byte
  • *
  • Posts: 4
    • View Profile
Re: attach/add mouse listener
« Reply #5 on: January 05, 2016, 10:52:59 pm »
switched drivers no success - standard linux drivers even made it worse

installed several windows/desktop environments

got it working under

- Cinnamon - but only in software mode
- Gnome flashback Metacity
- Gnome flashback Compiz

Are there any other Linux users that can confirm that behaviour - still not sure if it is the desktopn environment or the gfx drivers.

Regards

Offline ficticta

  • byte
  • *
  • Posts: 2
    • View Profile
Re: attach/add mouse listener
« Reply #6 on: October 22, 2016, 05:17:46 am »
I have the exact same problem. I'm using Ubuntu 16.10 and both machines one of them (with lowest specs) give this information at the beginning:

Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library ~./robombs/lib/lwjgl-2.7.1/native/linux/liblwjgl.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
Intel Open Source Technology Center-Mesa DRI Intel(R) Haswell Mobile /true/true/true/true/false

No input works once the game starts, no keyboard even to type the port or any other information to configure, and of course it is not playable. Only can see how robots play and how they kill you. The mouse works, but the character cannot be moved with it, only the camera and to put the bomb.

On the other machine

switched drivers no success - standard linux drivers even made it worse

installed several windows/desktop environments

got it working under

- Cinnamon - but only in software mode
- Gnome flashback Metacity
- Gnome flashback Compiz

Are there any other Linux users that can confirm that behaviour - still not sure if it is the desktopn environment or the gfx drivers.

Regards

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: attach/add mouse listener
« Reply #7 on: October 22, 2016, 02:05:00 pm »
You could try to download the latest LWJGL version (of the 2.x branch, not the new 3.x), replace the one that comes with the game  and see if that helps.

Offline ficticta

  • byte
  • *
  • Posts: 2
    • View Profile
Re: attach/add mouse listener
« Reply #8 on: October 23, 2016, 06:50:21 am »
Using the 3rd version stable and with everithing gives me this error:

ficticta@ubuntu:/home/ficticta/Games/robombs$ ./Robombs.sh
Loading Texture...from Image
Loading Texture...from Image
Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/opengl/DisplayMode
   at robombs.game.startup.ResolutionPanel.collectFeatures(ResolutionPanel.java:109)
   at robombs.game.startup.ResolutionPanel.<init>(ResolutionPanel.java:297)
   at robombs.game.startup.ResolutionFrame.<init>(ResolutionFrame.java:19)
   at robombs.game.startup.StartUp.main(StartUp.java:16)
Caused by: java.lang.ClassNotFoundException: org.lwjgl.opengl.DisplayMode
   at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
   ... 4 more

I also modified the linux launcher. the sh is:

java -Xmx768m -Xms256m -Djava.library.path=lib/lwjgl-3.0.0/native/linux -cp lib/jpct/jpct.jar:lib/lwjgl-3.0.0/jar/libjgl.jar:lib/lwjgl-2.7.1/jar/lwjgl_util.jar:bin/bin.jar:. robombs.game.startup.StartUp

The same result if I do not include the lwjgl_util.jar (because in the 3rd version is not present in the .zip.

Any other suggestion to try?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: attach/add mouse listener
« Reply #9 on: October 23, 2016, 07:01:59 pm »
Why did you use the 3.x branch? I wrote above that you shouldn't User the 3.x branch, but the latest 2.x version. Even worse, your modified start script mixes both version.
So... Download the latest 2.x version and modify the start script to point to that and only to that.