LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: chriddel on June 09, 2004, 00:00:04

Title: How to disable/hide mouse pointer
Post by: chriddel on June 09, 2004, 00:00:04
I am almost afraid to ask... but is there a way to disable or hide the mouse pointer in java/lwjgl? its always flickering so i would prefer it to disappear. or maybe its just very easy to make it stop flickering??

:oops:
sorry if thats a very stupid question, but i searched google for solution but didnt find anything but c++ code.

thanks,

chris
Title: How to disable/hide mouse pointer
Post by: Matzon on June 09, 2004, 05:18:08
QuotesetGrabbed

public static void setGrabbed(boolean grab)

   Sets whether or not the mouse has grabbed the cursor (and thus hidden).
on Mouse.

The flickering however, is odd - whats your OS and drivers?
Title: How to disable/hide mouse pointer
Post by: chriddel on June 09, 2004, 09:14:25
thank you matzon,

i use win xp and s3 twister - it might be the driver because i just owe a notebook with a "normal" graphic-card  :cry:  it also happens to the nehe tutorial examples in c++. but its strange because alienflux shows the mouse pointer without flickering.

btw: i cant find the public static void setGrabbed(boolean grab) in the 0.8 distribution. is it new in 0.9?

thanks + bye,

chris
Title: How to disable/hide mouse pointer
Post by: Matzon on June 09, 2004, 09:50:10
Quote from: "chriddel"i use win xp and s3 twister - it might be the driver because i just owe a notebook with a "normal" graphic-card  :cry:  it also happens to the nehe tutorial examples in c++. but its strange because alienflux shows the mouse pointer without flickering.
Hmm, might be something else than drivers then - just don't know where to start...
Quote from: "chriddel"
btw: i cant find the public static void setGrabbed(boolean grab) in the 0.8 distribution. is it new in 0.9?
Yup
Title: hmmmmmmmm
Post by: Fool Running on June 09, 2004, 13:00:51
If you are using 0.8 and don't want to change all of your code to 0.9, I think you can just call Mouse.create() and that will hide the mouse cursor.
(Just remember to call Mouse.destroy() afterwards.  :roll: )
Title: How to disable/hide mouse pointer
Post by: chriddel on June 09, 2004, 14:30:13
:D thanx! that worked great!
I just hope I won´t need the mouse pointer again  :shock:

Actually I am not stick with 0.8 but I had the feeling that its slightly faster than 0.9 (just a feeling - I didnt do any benchmarks)

chris
Title: How to disable/hide mouse pointer
Post by: oNyx on June 18, 2004, 16:17:25
>I just hope I won´t need the mouse pointer again

Hehe :)

Well, it sounds like a driver issue with hardware cursors. Btw AF's mouse cursor is/was done in software. So if you ever need a cursor and your driver is still broken you can just use a software cursor instead (just draw a quad with a cursor texture aligned to the mouse position - that's it).
Title: How to disable/hide mouse pointer
Post by: chriddel on June 22, 2004, 22:39:40
:D Thanx for the good hint!

No more headache with my mouse!  8)

Chris
Title: Re: How to disable/hide mouse pointer
Post by: n4pgamer on December 22, 2011, 15:09:30
How can I hide the Cursor AND let it leave the Display window ? I'm using window mode and want to hide the cursor only when it is over the game window.
Title: Re: How to disable/hide mouse pointer
Post by: princec on December 22, 2011, 16:21:15
That behaviour sounds entirely wrong.

Cas :)
Title: Re: How to disable/hide mouse pointer
Post by: n4pgamer on December 22, 2011, 19:10:36
Quote from: princec on December 22, 2011, 16:21:15That behaviour sounds entirely wrong.

I can't believe I'm reading this ....
It is a very common behaviour in windowed games.
Not everything is in first-person-perspective.
Title: Re: How to disable/hide mouse pointer
Post by: CodeBunny on December 23, 2011, 01:46:55
I can vouch. I've seen games do this before.

It's mainly for games that are windowed, so they don't want to lock the cursor; but they don't want to have the mouse cursor in the way of gameplay. Usually it's either a game that doesn't need the cursor at all, or it has a cursor it draws on its own.

I think a hackish way of doing this would be to simply set the cursor to a transparent image.
Title: Re: How to disable/hide mouse pointer
Post by: n4pgamer on December 23, 2011, 06:22:56
Quote from: CodeBunny on December 23, 2011, 01:46:55I think a hackish way of doing this would be to simply set the cursor to a transparent image.
Sorry if I'm too lazy right now. But what functions do I use to do that ? That sounds good.
Title: Re: How to disable/hide mouse pointer
Post by: princec on December 23, 2011, 21:05:03
Oh, I think I've just understood what you are trying to achieve - you want an invisible mouse, but you don't want to grab the mouse. Just set the mouse to a single invisible image:

emptyCursor = new Cursor(1, 1, 0, 0, 1, BufferUtils.createIntBuffer(1), null);
Mouse.setNativeCursor(emptyCursor);


Cas :)
Title: Re: How to disable/hide mouse pointer
Post by: CodeBunny on December 24, 2011, 15:55:50
That's an ugly way to do it, though. The most sensible thing to do would be to have some sort of call such as: Mouse.showNativeCursor(false).

Any chance this could get added to the API at some point? It seems like an easy enough change.
Title: Re: How to disable/hide mouse pointer
Post by: n4pgamer on December 28, 2011, 23:33:08
Quote from: princec on December 23, 2011, 21:05:03
emptyCursor = new Cursor(1, 1, 0, 0, 1, BufferUtils.createIntBuffer(1), null);
Mouse.setNativeCursor(emptyCursor);
Well, that works. Thanks!

Any idea how to undo that ? I tried Mouse.getNativeCursor(); to retrieve the default cursor before hiding the cursor but it doesn't work. Seems to deal only with custom cursors.

I need to change the cursor visibility between menu and game (pretty often).
Title: Re: How to disable/hide mouse pointer
Post by: princec on December 29, 2011, 09:54:13
Set it to null.

Cas :)