隐藏光标/变形鼠标 (SDL 1.3)

发布于 2024-10-17 13:22:22 字数 465 浏览 8 评论 0原文

我无法使用 SDL(正确)隐藏鼠标光标。我正在使用 Ubuntu 10.10,并且一直在使用以下内容:

SDL_ShowCursor( SDL_DISABLE ); 
SDL_WarpMouse( x, y ); 

两者都无法正常运行;它看起来没有视觉效果,但是正如文档所述,有一个触发的鼠标运动事件,但鼠标不会在屏幕上移动或消失。

SDL 窗口是使用标志 SDL_WINDOW_OPENGL | 创建的(通过 SDL_CreateWindow)。 SDL_WINDOW_SHOWN。全屏对结果没有影响。

在全屏模式下以低分辨率(例如 640x480)运行窗口,确实可以提供命令所需的效果;但光标会从下面的窗口中渗透出来。 在 1024x768 左右,它有一个完全不同的光标图标。 当我的分辨率越来越高时,它就不再渗透,就像一个窗口(Gnome 光标)一样。上述命令没有任何效果。

有什么想法吗?

I've been unable to hide the mouse cursor (properly) using SDL. I am using Ubuntu 10.10 and have been using the following:

SDL_ShowCursor( SDL_DISABLE ); 
SDL_WarpMouse( x, y ); 

Neither of which function properly at all; it would appear to have no visual effect, there is however a triggered mouse motion event as the documentation states, but the mouse does not move in any or disappear on screen.

The SDL Window is created (via SDL_CreateWindow) with the flags SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN. Fullscreen has no effect on the outcome.

Running the window at low resolutions in fullscreen mode (such as 640x480), does provide the desired effect of the commands; but the cursor bleeds through from the underlying windows.
Around 1024x768, it has a completely different cursor icon.
As I get higher in resolution, it stops bleeding through and just acts as though its a window (the Gnome cursor). With no effect of above commands.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

在梵高的星空下 2024-10-24 13:22:22

我知道这个问题很老了,但它仍然是现实的。

解决方法如下:

在你想隐藏光标的地方写下:

SDL_Cursor *cursor; /* Make this variable visible in the point
                       where you exit the program */
int32_t cursorData[2] = {0, 0};
cursor = SDL_CreateCursor((Uint8 *)cursorData, (Uint8 *)cursorData, 8, 8, 4, 4);
SDL_SetCursor(cursor);

在你退出程序的地方:

SDL_FreeCursor(cursor);

I know this question is old, but it's still actual.

Here's the solution:

Where you want to hide the cursor, write this:

SDL_Cursor *cursor; /* Make this variable visible in the point
                       where you exit the program */
int32_t cursorData[2] = {0, 0};
cursor = SDL_CreateCursor((Uint8 *)cursorData, (Uint8 *)cursorData, 8, 8, 4, 4);
SDL_SetCursor(cursor);

Where you exit the program:

SDL_FreeCursor(cursor);
心不设防 2024-10-24 13:22:22

*是的,SDL 1.3 中尚未实现游标。我故意让它们不被实现,以提醒人们 1.3 还没有准备好。 *

引自 SDL 开发人员 Sam Lantinga;因此这个问题只是一个 SDL bug(很快就会修复)。

*Yes, cursors are not yet implemented in SDL 1.3. I'm sort of intentionally leaving them unimplemented as a reminder that 1.3 isn't ready yet. *

Quote by Sam Lantinga, an SDL Developer; therefore this question is simply an SDL bug (soon to be fixed).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文