How to Capture Mouse Cursor Similar to Sample Browser? Topic is solved

Problems building or running the engine, queries about how to use features etc.
niceprogrammer
Gnoblar
Posts: 23
Joined: Sat Nov 02, 2024 12:38 pm
x 2

How to Capture Mouse Cursor Similar to Sample Browser?

Post by niceprogrammer »

Ogre Version: v14.3.4
Operating System: Windows 10
Render System: RenderSystem_Direct3D11

ogre_log.txt

Good Day Everyone!,

I am trying to learn Ogre 3D from the Samples. I wanted hide the OS mouse cursor and capture the mouse to be inside the game similar to the Sample Browser.

I tried to find cursor related codes inside the Samples directory but I couldn't find any clues. I only see Tray related show/hide cursor but it does not hide the native cursor.

You do not have the required permissions to view the files attached to this post.
rpgplayerrobin
Orc Shaman
Posts: 736
Joined: Wed Mar 18, 2009 3:03 am
x 411

Re: How to Capture Mouse Cursor Similar to Sample Browser?

Post by rpgplayerrobin »

I would guess it has to do with this function:

Code: Select all

void ApplicationContextSDL::setWindowGrab(NativeWindowType* win, bool _grab)
{
    SDL_bool grab = SDL_bool(_grab);

SDL_SetWindowGrab(win, grab);
#if OGRE_PLATFORM != OGRE_PLATFORM_APPLE
    // osx workaround: mouse motion events are gone otherwise
    SDL_SetRelativeMouseMode(grab);
#else
    SDL_ShowCursor(!grab);
#endif
}
niceprogrammer
Gnoblar
Posts: 23
Joined: Sat Nov 02, 2024 12:38 pm
x 2

Re: How to Capture Mouse Cursor Similar to Sample Browser?

Post by niceprogrammer »

Sorry for the late reply. I got so busy with work :).

I tried this and seemed to work fine.

Code: Select all

SDL_SetRelativeMouseMode(SDL_TRUE);

Are the directives necessary? Does SDL not handle the cross platform feature in this case?

rpgplayerrobin
Orc Shaman
Posts: 736
Joined: Wed Mar 18, 2009 3:03 am
x 411

Re: How to Capture Mouse Cursor Similar to Sample Browser?

Post by rpgplayerrobin »

If someone specifically coded that, they must have had a reason to do so.
The comment in that function also explains why.

If you have a mac and a PC and be able to test it, you can check if it is needed or not.