Changing the Mouse Cursor

How do you change the mouse cursor in lwjgl? I can’t seem to find it in the docs, and honestly I’m not even sure which object I should be looking through. (Mouse? GL? Display?)

I think you’re supposed to draw your own. If your using active rendering (I’m guessing yes :)) you’d simply draw your cursor texture last. This is actually pretty flexible since such a cursor could also be controlled by a joystick or game controller. (SimCity for the SNES anyone?)

I’m currently looking into enabling the hw cursor and using a custom (animated) icon for it. It’s worth the trouble, because mouse movement is much more sensitive to fps than the rest of a 3d game. I hope it can be done on MasOSX too.

I’ve seen C&C Generals and NWN do it, the latter having the linux users disgruntled exactly because the cursor is OpenGL rendered in the linux port - locking it to the frame rate.

  • elias

So currently I’ll have to render my own, but keep an eye out of Elias to have a stroke of brilliance? Sounds fair.

I have a feeling hardware cursors will turn out to be a major can of worms.

I also have a feeling that if you’re not running at monitor refresh rate you’re not running on a powerful enough system…

Cas :slight_smile:

I think he means that the software cursor is too fast/slow, not that it’s inconsistent on a time basis. People are used to their mice moving a certain speed and won’t like it if it suddenly starts zipping around like a mad-man or moving at a dog-slow rate.

I also have a feeling that if you’re not running at monitor refresh rate you’re not running on a powerful enough system…

I’m confused here. Why must a game run at refresh rate? Shouldn’t it be acceptable for it to run at a nice multiple?. For example, for the game I’m working on, 30/35fps should be a perfectly acceptable frame rate, and so I’d imagine we’d try to get a refresh rate of 60hz or 70hz.

Would a mouse cursor at 30fps be too slow?

God bless,
-Toby Reyelts

well… if u need the cursor only in your menus it shouldnt be a prob (as long as the menus arent tooooo flashy) :>

afair unreal tournament had used a s/w cursor wich moved quite jerkily(fps locked). dunno why it wasnt smooft - the ui itself was quite plain and unspecial.

games like C&C Generals and NWN, wich need a responsible interface would benefit from a h/w cursor for sure.

right now i don’t really need that but i think it would be a nice feature :wink:

Would a mouse cursor at 30fps be too slow?

imo yes.

-40hz(com) is really painfull (yes. even clicking around in the browser get’s an annoying task)
-60hz(ps2-default) is somewhat better. fortunatelly u can overclock the ps2 port(eg. 80,100 and 200hz).
-125hz(usb) is ok.

i use a logitech mx300 mouse… plugged into the ps2 port @200hz. that’s really nice this way. the mouse movement is pretty accurate and smooft. sure my screen doesnt run at 200hz but it’s nice to have the latest available position for the next screen refresh.

if i play a game running at 85fps@85hz i would get ~2.35 coords per frame. i can either use the latest (most up to date position) or interpolate the last 2 positions.

high cursor fps are a good thing if u want to correct your cursor position/your cursor movement. eg your cursor is 400 pixels away from 20x20pixel thingy u want to click on. if u now move the mouse within one second (that’s really slow) to the spot the cursor will make 10 pixel jumps. with 125hz the jumps are just bout 3-4 pixels; therefore the 20x20 pixel box is much easier to hit.

in addition a higher cursor fps rate delivers more data for the users brain. this way he/she/it will be able to get faster used to the mouse sensitivity of your game. after a short warmup time the user will be able to know how far he/she/it has to move the mouse to get to the desired position.

once the distracting factors (=getting used to something) are gone u can get into the zone :slight_smile:

I think it doesn’t really matter if a cursor is hw or sw as long as it’s polled at vsync.
I believe the reason why the windows mouse pointer is a bit jerky is because it’s polled at a low rate (iirc it was 25 or 30hz) and (more importantly) independant of the screen refresh rate or whatever connection you use to plug your mouse. Maybe things have changed in winxp, but I’m pretty shure this was still the case in win9x/nt.

Why must a game run at refresh rate?

It’s difficult to put forward a concrete case for it but it’s easy to give a very nice illustration.

In the Alien Flux alpha there’s a checkbox in the options screen to run the display at 30Hz. Try it and see the difference! I believe running at half refresh rate is a last-ditch attempt to get a game running on a computer that’s just plain too slow to do what you want to do, and it shows, right down to the mouse movement. A hardware mouse cursor is a kind of hack workaround to pretend you’re not stretching things a bit too much. I’ve got the checkbox in there just to let people with terribly slow computers play it but it’s not how it’s meant to look.

Cas :slight_smile:

Bearing in mind that its much more noticable on a 2d game compared to a 3d one - 60hz is glassy smooth for a 2d game, but if i ever ran windows at 60hz i’d be ill :stuck_out_tongue:

On the other hand, playing Black & White is pretty much perfectly acceptable at 30fps (which uses a game-drawn cursor) and still pretty playable at the 10 to 20fps my rig gets me on the later levels. (Whether you still find the game playable on later levels is a whole 'nother can o worms though…)

In any case I don’t think it can hurt to make the feature possible, and speaking of which - the linux implementation is done with full ARGB colors and animation but I’m having trouble finding the relevant cursor code for win32. Could someone more proficient with the win32 api show me the code? I far as I can tell, animated cursors are supported but I have yet to find a function to create one. And it also seems like full translucency isn’t supported (like on linux - hah), is that true? The C&C Generals cursor doesn’t seem to be alpha blended in any case.

  • elias

In the Alien Flux alpha there’s a checkbox in the options screen to run the display at 30Hz. Try it and see the difference!

First, when you say “run the display at 30Hz” you’re really setting the refresh rate to 60Hz and locking your frame rate to 30Hz right?

I tried the 30Hz option, and after a few minutes, the biggest difference I could tell was that things seemed less reactive. Not so much moving the mouse, but just the game in general.

I believe running at half refresh rate is a last-ditch attempt

I guess I’m just going to have to disagree right now. That may be truthful for a certain class of games - i.e. shooters like AF, but in my team’s case, we’re developing a turn-based strategy game. It just doesn’t require the same kind of responsiveness as a shooter. This has always been my stance before, but these postings about hardware cursors had me concerned.

A hardware mouse cursor is a kind of hack workaround to pretend you’re not stretching things a bit too much.

Well, the only reason I was considering a hardware mouse was if the mouse responsiveness was a problem. But, after playing AF at 30Hz, I’m almost positive it’s not.

God bless,
-Toby Reyelts

I believe running at half refresh rate is a last-ditch attempt

Let’s be precise about this. In reality, we’re dealing with absolute numbers that aren’t going to change, based on human physiology. If all of the sudden video adapters and monitors started supporting refresh rates at 350Hz, you would still lock your frame rate at something well below that (i.e. 80fps), because their would be no perceived benefit of running a higher frame rate.

So, the real issue at hand is what hard-constant frame rates and what hard-constant refresh rates are necessary for what kinds of applications (i.e. class of games). For example, I would guess that

a) you should run the refresh rate of a monitor at at least 60Hz regardless of application. The important part being that the minimal refresh rate will prevent flicker.

b) fmv should run at 10fps minimally This is the generally accepted number for the minimal frame rate required for humans to perceive smooth animation.

c) turn-based games should run at 30fps minimally

d) shooter games should run at 60fps minimally

God bless,
-Toby Reyelts

Well, absolutely, yes.

You probably don’t even notice but the animation is actually running at 30Hz or less on A.F. even at 60Hz refresh rate, although sprite positions and scrolling are still being updated at 60Hz.

For a turn-based strategy game I think you could get away with running the animation at 15Hz or even 10Hz and no-one would notice, simply because it’s probable that your sprite animations will be at that frequency anyway. The hardware mouse cursor would make it all feel really smooth though.

Our next game is a probably going to be a turn-based RPG, but everything is animated in between turns, and I think we can get away with it for sure.

Cas :slight_smile:

For a turn-based strategy game I think you could get away with running the animation at 15Hz or even 10Hz and no-one would notice, simply because it’s probable that your sprite animations will be at that frequency anyway.

That may be the case if you’re using sprites, but when you’re using 3D models, you interpolate the animation between keyframes, so higher frame rates result in smoother animation.

The hardware mouse cursor would make it all feel really smooth though.

My question here is really what is the minimum acceptable frame rate that a cursor can be done in software. From playing AF, I would have said that 30fps seems to be fine.

Our next game is a probably going to be a turn-based RPG, but everything is animated in between turns, and I think we can get away with it for sure.

Sounds like you’re planning on using sprites too. :slight_smile:

God bless,
-Toby Reyelts

30hz for the mouse, yak :o

reminds me of when I didn’t know any better, and used a Serial mouse :-[

[quote]30hz for the mouse, yak :o

reminds me of when I didn’t know any better, and used a Serial mouse :-[
[/quote]
serial is 40hz and it’s still painfull (as i already said) :>

Animated mouse cursor isn’t going to happen on OSX. You can get a hardware one, but it would be the standard system cursor. No biggie doing that - I just wouldn’t hide it. The HID system makes no distinction between a game or a word processor so the mouse pointer would be the same ol’ mouse pointer with the same performance.

Is there a real problem that’s leading to hardware cursors or is it ‘well there might be a case where’ that’s leading to that feature?