Sign in to follow this  
Steve-B

How on earth do you load a custom cursor??

Recommended Posts

Steve-B    150
Hi guys & gals I know this isn't strictly an OpenGL issue but it's still games related. Basically I'm having trouble adding a custom mouse pointer to my OpenGL game. I don't want the standard windows mouse pointer as it just looks naff in a game. Plus I want the cursor to change when the mouse is positioned over certain objects in the game. I'll figure that part out myself though. Anyway I have created the cursor in Visual Studio 6 in the same way I created an icon for the program. I used the usual resource file creation method that worked for my program icon. Unfortunately when the program loads the mouse pointer just shows up as the hourglass cursor. I'm loading the cursor as a resource and I can't figure out why this doesn't work. Is there anything special you have to do for cursors? Do they have to be a certain size or number of colours? Are there any tutorials on the net?? Cheers, Steve

Share this post


Link to post
Share on other sites
Steve-B    150
I'm already using the LoadCursor function. I'm using it in the same way that I use the LoadIcon function. I use it like this:

winclass.hIcon = LoadIcon(NULL, "IDI_WATERDEEP");
winclass.hCursor = LoadCursor(NULL, "IDC_WATERDEEP");

Using this code the icon works great but the cursor just shows up as the standard windows hour glass cursor.

Share this post


Link to post
Share on other sites
lack the hack    110
hmm first of all, you don't need the quotes around the "IDC_WATERDEEP". its not required for win32
also, you should put in the hInstance of the other parameter, and try using MAKEINTRESOURCE( )...worked for me
so it should look something like this:

windowClass.hCursor = LoadCursor(hInstance, MAKEINTRESOURCE(IDC_RANDOM));

Share this post


Link to post
Share on other sites
Caste    973
i think lack tha hack's right,
but if you want to crate a cursor only for OpenGL(and if you're familiar with OpenGL), you might just save the mouse position by catching the WM_MOUSEMOVE event in WndProc (if you called it like this, Nehe does).
Then you draw a textured quad in gluOrtho-mode which looks like your cursor(alpha blending might be good) and switch of the Windows-Cursor via "ShowCursor(false);"...
But unfortunately needs much OpenGL knowledge...

Share this post


Link to post
Share on other sites
Axesor    100
I think both ideas would be useful and come out with the same (or better) results. Here's the question: Which one uses up more bytes? The one with the less bytes is the one I would go for.

Share this post


Link to post
Share on other sites
llvllatrix    340
Quote:
Original post by Axesor
I think both ideas would be useful and come out with the same (or better) results. Here's the question: Which one uses up more bytes? The one with the less bytes is the one I would go for.


I'm not so sure; disk and memory are fairly cheap. In terms of processing preformance, there probably would be very little difference if you drew your cursor using windows or OpenGL. There are however, two benefits to using GL over Windows. Firstly, it is cross platform so you dont have to port your cursors. Secondly, GL is more flexible than windows, so you could potentially do a 3d cursor if you had to (or perhaps more realisticly cross hairs). You also wont run into any drawing artifacts that may occur with your new cursor and the GL context.

Cheers,
- llvllatrix

Share this post


Link to post
Share on other sites
Steve-B    150
Thanks for the help. Looks like I'll have to take the OpenGL route as I still can't get the pointer working through the Windows functions. Not sure what I'm doing wrong. I've taken the advice 'lack' but still it doesn't work. I'll use the OpenGL method. Cheers.

Share this post


Link to post
Share on other sites
JakeM    168
I think it depends on whether you are making a windowed app or a full-screen app.
I personally would use the MS cursor for a windowed app. Full screen app you can draw
your own cursor.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this