How on earth do you load a custom cursor??

Started by
7 comments, last by JakeM 17 years, 10 months ago
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
Advertisement
There is a LoadCursor function. You probably need that... I'm sure that if you'll look up the function, some examples will be available.
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.
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));
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...
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.

.::WARNING!::. Axesor is a total newb or n00b! Beware his lack ofintellegence of OpenGL. Feel sorry for him and keep him in your thoughts.~Leader of the phsychoward
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
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.
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.

This topic is closed to new replies.

Advertisement