Mouse pointer flickering using JOGL

Hi.

I’m writing a simple game as a learning project for using JOGL, and have a problem with the mouse pointer - when the pointer is over the canvas, it flickers. It looks like it’s either only being drawn on one of the page buffers, or is only being drawn when it moves, or something like that.

I do want to use the pointer in the game, and want to use the standard pointers (the pointer and the hand) rather than create a custom pointer.

Everything else is working fine - it draws beautifully, recognises the mouse and keyboard events etc.

How can I stop the flickering ?

Cheers

Edit: just tried it with custom cursors instead - I get the same flickering, but also the cursors are then drawn noticeably larger than actual size

here’s the programme to show you what I mean, it’s a Rubik’s Cube running as an applet:

http://www.stupey.com/Rubik

Ignore the contents on the webpage round it, that’s all WIP.

drag the mouse or use the arrow keys to spin the cube, click/right click on a face to spin it clockwise/anti-clockwise

J key jumbles it, ESC peels all the stickers off and puts it back as new.

See how the cursors flicker and are much too big ? They are direct grabs of regular cursors, and so JOGL is growing them for some reason

When I tried the applet, everything ran very smoothly. I saw no flickering and the cursors were correctly sized. I was running Mac os X 10.5.5 in Firefox 3.0.

When you say you’re using custum cursors, are you creating textures of the cursor image and rendering it with jogl, or are you using Java’s cursor support?

On XP + Firefox 2:

  • no cursor flickering
  • yes, the cursors look oversized

works fine for me, no flicker and cursors don’t look large at all. Although when switching browser tabs, I could see the applet on all tabs, but I guess thats a FF bug rather than anything you are doing.

OSX 10.5.4 Firefox 3

i remember back in the days as java 3d was cool (;)) there was a problem with cursor shadows and 3d rendering which caused flickering on some configs. I know the early java 3d never used JOGL but maybe it has a similar reason…

I’ve got cursor flickering/wrong size on two machines, both Firefox and IE, in XP. I guess it’s to do with specific graphics cards - mine are probably rubbish

[quote=“lhkbob,post:3,topic:32622”]
Yeah - was thinking that. I’m using the standard Java cursor support at the moment, setCursor() and createCustomCursor(), but I will have a go at drawing a textured quad for a cursor instead and making the standard cursor invisible, that should at least fix the flickering, and sizing if I can get i right. Bear with me though, I’m a JOGL noob.

Couldn’t reproduce the applet showing on multiple FF tabs error, but have fixed a couple of things to do with navigating away and back to the applet now though.

fixed it - now has the cursors as textured quads, - no flickering and now the correct size

had a nightmare getting a texture with black, white and transparent areas to render onto a transparent quad and display everything correctly, but it does now

enjoy:

http://www.stupey.com/Rubik

I see two pointers in Safari, ie system and your textured pointer. And in FireFox I occasionally see two pointers, but what’s more strange is that it sometime feels like the pointer is stuck in the rendering window. eg system cursor is hidden, dragging outside the widow it remains hidden and you custom cursor is sat at the edge of the window. Sometimes it comes back, and other times I get a single cpu maxed out. I also re-tested the rendering into multi tabs and that still seems a problem. But I’ve been using a beta FF so maybe time to update that :slight_smile:

Hope the testing helps, I’m interested to see if you can get this right because I’d love to do the same thing with my game. But these kind of issues really put me off.

Cheers
Peter

[update] i check my FF and previously was running 303, just updated to 3.1b2 and see the same issues, ie multi tab behaviour, and the mouse thing seems to happen when you move the mouse around fast.

thanks for the feedback Peter,

Yeah, actually my code for trapping the mouse events to determine whether or not to draw the cursor was a little lazy, and I’d noticed a similar related bug myself last night. Have tightened it up now, so hopefully should look bit better ?

Regarding the two cursor problem - that may be due to supported cursor sizes in Safari, so I’ve put in checking for the getBestCursorSize(), and also made my invisible cursor gif a 16x16 rather than 1x1 now, so maybe that helps ?

Don’t like the sounds of the CPU maxed out though - do you have any more details of what happened there ?

Not too concerned about the multiple tab problem - anyone who’s not testing the game, but has a rubik’s cube open in more than one tab deserves all they get ;D

I have had similar problems with other applets I’ve written in the past though - I’m guessing it’s to do with one jvm with multiple instances of the applet all accessing the same static and single-instance variables.

Cheers,

Stu

mouse moving in/out of canvas works fine here now.

attached is the strange mouse issue under safari. Happens after first click and then remains that way. ie initial move mouse into canvas is rendering correctly.

http://mouse.jpg

I was keeping an eye on cpu, and things looked fine, although I’ve got lots running on my machine currently so could have been some other bg task.

Restarting Safari and only using your app is fine, but as soon as other broswer tabs are opened a number of things are possible:
safari totally crashes,
the new tab opens but the cube is rendering without color ie white in the original tab.

Anyway I forgot to mention it’s a nice app, you should port it down to Android :slight_smile:

Peter

ahh - you’re on Mac OSX… I couldn’t reproduce the problems with Safari on Windows.

I guess the cursor reappearing is the os overriding my setting of the cursor to invisible when there’s a mouse event. I’ve uploaded a work-around which will re-load the invisible cursor after every mouse button event - hopefully that fixes it ?

It seems there are known problems with JOGL in Applets under OSX, discussed here. Out of interest are you able to view these JOGL applets (not mine) without the same problems ?

Edit: just googled the Android thing - sounds like hard work - will do it if someone wants to pay me :wink:

Bad news, I see the double cursor with Firefox 3 on OS X, so it seems your fix didn’t work :-\

gah :’(

Maybe I should just disable the custom cursor for OSX

Edit:

By the way - just a random thought from me on the mutiple tab problem for a JOGL applet (and I might be talking total garbage, so feel free to ignore) -

Isn’t the GL object you get from calling GLAutoDrawable.getGL() a single-instance object, so if you have the same applet running in two tabs of the same browser, then you have one jvm, two instances of the applet class, both messing with the state of a single instance of the GL, so everything screws up ?

or… not ?

[quote=“genki,post:14,topic:32622”]
which leads me to another problem, trying to find out if it’s OSX or not.

Using a statement like

if(System.getProperty("mrj.version")!=null)isMacOS=true;

gives a security access violation

java.security.AccessControlException: access denied (java.util.PropertyPermission mrj.version read)

as does System.getenv(). It’ll be because the applet itself is an unsigned sub-applet running within a signed jnlpappletlauncher applet.

Seems silly to restrict the info on the operating system, since I could easily have the applet send an http request to a cgi script on my server, which can read the os, and could then send something back - but that seems to be rather overkill just for setting a cursor…

Any bright ideas how I can check the OS from within my applet ?