mouse handling on AWT and also NEWT

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

mouse handling on AWT and also NEWT

Cork
This post was updated on .
how are people handling 1st person fps type mouse control with JOGL2?

I'm using this to hide the mouse (will probably have to redo this on focus gained or something after tabbing about different apps):

       Image image = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(16, 16, pixels, 0, 16));
        Cursor transparentCursor = Toolkit.getDefaultToolkit().createCustomCursor(
            image, new Point(0, 0), "invisibleCursor");

But what about tracking mouse movement without the mouse leaving the frame? Robot to reset the position?
Or does JOGL include some utility methods for this type of thing?

How about drawing the static cross-hairs in the center of the screen? just some none rotated geometry? or something a bit fancier?

How does it compare when doing the same on NEWT? ie no AWT or probably toolkit??
Also is there a good NEWT starting point for this type of project? I installed git to dl the demos source but couldn't find a good reference for a NEWT desktop app.
Reply | Threaded
Open this post in threaded view
|

Re: mouse handling on AWT and also NEWT

gouessej
Administrator
Hi!

Look at the source code of TUER, especially the alpha branch that uses JOGL 1.1.1a, it should work with JOGL 2 too, it uses AWT, not NEWT.

Look at this class for the mouse control:
http://tuer.svn.sourceforge.net/viewvc/tuer/alpha/main/GameMouseMotionController.java?revision=269&view=markup

http://tuer.svn.sourceforge.net/viewvc/tuer/alpha/main/GameController.java?revision=269&content-type=text%2Fplain
//builds a transparent cursor
BufferedImage cursor=new BufferedImage(1,1,BufferedImage.TYPE_INT_ARGB);
cursor.setRGB(0,0,0);
frame.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(cursor,new Point(0,0),"empty cursor"));

The crosshair is drawn in this class somewhere:
http://tuer.svn.sourceforge.net/viewvc/tuer/alpha/main/GameGLView.java?revision=269&content-type=text%2Fplain

I hope it will be helpful.

N.B: The source code is under GPL version 2.

I know only a very few open source Java first person shooters using OpenGL. Tesseract is an open source Java first person shooter but it uses software rendering. Resistance Force uses LWJGL and is not open source. Sorry :(
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: mouse handling on AWT and also NEWT

Cork
Good to know I'm on the right track, thanks!

Next I'd like to get the same thing running in NEWT but could really do with a NEWT JOGLTetrahedron ...
Reply | Threaded
Open this post in threaded view
|

Re: mouse handling on AWT and also NEWT

Sven Gothel
Administrator
On Wednesday, November 24, 2010 17:00:48 Cork [via jogamp] wrote:
>
> Good to know I'm on the right track, thanks!
>
> Next I'd like to get the same thing running in NEWT but could really do with a NEWT JOGLTetrahedron ...

Looks like a request for enhancement,
please describe it well in a bug report and severity: enhancement!

Thank you.

~Sven
Reply | Threaded
Open this post in threaded view
|

Re: mouse handling on AWT and also NEWT

Cork
sorry, I mean I just need some sample code for using NEWT on desktop including keyboard and mouse handling.

background: I was looking at how to create a maven archetype to capture some 'best practice' project starting points.  I found the JOGLTetrahedron.java on wikipedia, but I haven't so far found anything for NEWT.  Ideally I'd also like to find an example of ES2 running on desktop, which it sounds like JOGL2 now supports?
Reply | Threaded
Open this post in threaded view
|

Re: mouse handling on AWT and also NEWT

Sven Gothel
Administrator
On Wednesday, November 24, 2010 20:01:47 Cork [via jogamp] wrote:
>
> sorry, I mean I just need some sample code for using NEWT on desktop including keyboard and mouse handling.
>
> background: I was looking at how to create a maven archetype to capture some 'best practice' project starting points.  I found the JOGLTetrahedron.java on wikipedia, but I haven't so far found anything for NEWT.  Ideally I'd also like to find an example of ES2 running on desktop, which it sounds like JOGL2 now supports?

we have tons of junit tests and jogl-demos around there incl GL2ES2 examples.

just have a look ..

~Sven

Reply | Threaded
Open this post in threaded view
|

Re: mouse handling on AWT and also NEWT

Cork
I checked the src/demos/newt
NEWTTest1.java
TaskManagerTest1.java
TaskManagerTest2.java

but none of these look like a good starting point.

I also found a 'GLNewtRun.java' which seems to wrap some other demo?  Again not ideal for a starting point.  Did I clone the wrong demos branch or something?  I seem to remember there used to be a NEWT desktop gears...

So imagine a new user is coming to look at JOGL2, which demo source code file best represents running NEWT on the desktop?  It only needs to be rotating triangle or something, but should clearly demonstrate the best practice for creating the display, threading, and tearing it down again.
Reply | Threaded
Open this post in threaded view
|

Re: mouse handling on AWT and also NEWT

Sven Gothel
Administrator
On Thursday, November 25, 2010 08:57:25 Cork [via jogamp] wrote:
>
> I checked the src/demos/newt
> NEWTTest1.java
> TaskManagerTest1.java
> TaskManagerTest2.java
>
> but none of these look like a good starting point.

jogl-demos repository

es2/RedSquare

or the es1 demos

could be more, sure, contribute to jogl-demos

~Sven
Reply | Threaded
Open this post in threaded view
|

Re: mouse handling on AWT and also NEWT

BrickFarmer
for anyone else looking for more background on 1st person mouse etc I came across this article:

http://www.gamedev.net/reference/programming/features/javainput/

and here is what I'm using it for:

http://www.youtube.com/watch?v=70XukqCm1aQ

This is a resurrected JOGL111 project that I'm now converting to JOGL2.  The terrain rendering needs fixing yet, and multi-player character movement is broken, since A-star no longer makes sense.  But the 1st person view already makes it feel far more playable :)
Reply | Threaded
Open this post in threaded view
|

Re: mouse handling on AWT and also NEWT

Demoscene Passivist
Administrator
Nice, just added the video to our streams section