raylib: [rcore] `ShowCursor()` is not working properly
Please, before submitting a new issue verify and check:
- I tested it on latest raylib version from master branch
- I checked there is no similar issue already reported
- I checked the documentation on the wiki
- My code has no errors or misuse of raylib
Issue description
ShowCursor
is not working properly, The cursor stays hidden.
Environment
Platform: Windows 11 22H2 (64-bit) IDE: Microsoft Visual Studio 2022 Raylib: 5.0 from vcpkg
Code Example
#include "raylib.h"
int main()
{
InitWindow(500, 500, "Cursor");
HideCursor();
ShowCursor();
//EnableCursor(); // This works
while(!WindowShouldClose()) {
BeginDrawing();
ClearBackground(DARKBLUE);
EndDrawing();
}
CloseWindow();
return 0;
}
About this issue
- Original URL
- State: closed
- Created 7 months ago
- Comments: 15 (5 by maintainers)
I compiled both of @justgo97 examples using raylib 5.1-dev, VS 2022 17.8.2 Build Tools, the x64 Developer Command Prompt, and the VCrayApp-0.1.0 beta kit.
I confirm that all works as expected with the cursor toggling only inside the app window and not impacted elsewhere on the Windows 10 display. VCrayApp compiles raylib modules from raylib src/ and only links a few windows *.lib files besides the compiled raylib *.obj files and that seems to be consistent with the success that @justgo97 has achieved.
@justgo97 @ubkp Ok, I think I know where could be the issue.
Are you including
windows.h
in some module? In what order are you linking the program libraries in Visual Studio?Check in VS for your project:
Properties
>Linker
>Input
:Additional Dependencies
I got the following list in the following order:
raylib.lib
should be linked beforeuser32.lib
.@justgo97 I’m afraid I did not maintain the vcpkg, actually, never use it. Feel free to report the issue to the maintainers of the package. You can link with this issue.
Oh that’s definitely related to the problem. I’m not including
windows.h
anywhere. So it’s a linking issue, I don’t addraylib.lib
to the linker input since vcpkg takes care of that I guess? But I’m not using a project from the examples folder from Raylib, I started an empty project in VS 2022 which it seems uses this list of libs:Now I manually added the list of libraries after looking at an example project and everything is working fine:
raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;
I thought using vcpkg doesn’t need doing any manual setup but I guess I should use
core_basic_window.vcxproj
as a template next time@justgo97 @raysan5 I was about to comment exactly that. I think if you’re including
winuser.h
it has aShowCursor()
which would be conflicting.@justgo97
EnableCursor()
is the exact same call ofShowCursor()
. See L1002 and L988.Can you compile
raylib
yourself with VS?@justgo97 @raysan5 Cross-compiled it here for Win64 using
Mingw
. Sent the.exe
to a friend which tested it onWindows 11 22H2
(64-bit). Everything worked correctly.