sdl 1.2 mouse crosshair

Started by
8 comments, last by Acharis 9 years, 1 month ago

Hi

how to draw a mouse crosshair with sdl 1.2?

Thanks in advance

Advertisement

Read the documentation of the SDL on how to get the mouse position in a specific time;

Read the documentation of the SDL on how to draw an image;

Draw the image in the mouse position;

You'll get an x, y position that describes the mouse position in that specific time.

After that your image should be rendered at the center of the mouse position that you got.

If SDL has a function such: DrawImage(X, Y), you pass the x and y values of the mouse position to the function.

Another simple way of doing it is read the documentation of SDL and see how you can change the mouse cursor image and change that at initialization or run-time.

http://www.libsdl.org/release/SDL-1.2.15/docs/html/sdlcreatecursor.html

how to call? If I do alike I get a crash:

init_system_cursor(arrow);

Thanks

http://www.libsdl.org/release/SDL-1.2.15/docs/html/sdlcreatecursor.html

how to call? If I do alike I get a crash:

init_system_cursor(arrow);

Thanks

What kind of crash?

Looks like your SDL version is a little bit old. I quick googled it and this is the last version, you may want to download that.

No I'm using 1.2 and won't bother to change existing code. A runtime crash without any details (x-plane plugin dll)

Do I need to give something to the arrow array?

I don't use sdl for video only for some other stuff in my x-plane (opengl) dll, hence I need more code?

According to the docs your arrow array is just a bunch of monochrome\alpha pixel data.

If you're copy-pasting from the docs, and isn't working, I'd check the documentation more accurately to see if there's a problem with your initialization code.

Anyone doing alike in a crossplatform, already existing opengl context?

Anyone doing alike in a crossplatform, already existing opengl context?


There's nothing to do with a OpenGL context in this case. This is a OS specific problem, and that is what I told you about the initialization.

Your version of SDL is a little bit outdated, which means that things may be hard to solve and other things may be totally deprecated in current OSs.

My suggestion in that case is to check how you can change the mouse cursor directly using the OS API that SDL interface with primarely (for Windows that's the Win32 API).

I've found a solution in the x-plane sdk. As I don't init graphics/video with my sdl stuff, I can't do that with sdl.

Thanks

Upgrade to SDL2, 1.2 is known to have issues with custom mouse cursors (I have made the switch and many small strange problems disappeared).

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

This topic is closed to new replies.

Advertisement