示例 SDL 程序给出一个空窗口 [英] Sample SDL program gives an empty window

查看:24
本文介绍了示例 SDL 程序给出一个空窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

config: archlinux 拥有超棒的桌面环境

config: archlinux with awesome desktop environment

我刚刚安装了 sdl2,并尝试运行此示例代码:https://github.com/xyproto/hello_sdl2/blob/master/c%2B%2B/main.cpp

I just installed sdl2, and tried to run this sample code: https://github.com/xyproto/hello_sdl2/blob/master/c%2B%2B/main.cpp

结果是屏幕中间有一个空窗口(我可以通过它看到我的控制台).即使我按下 mod4+Enter,它也不能很好地与其他人平铺.这是为什么?

The result is an empty window (I can see my console through it) in the middle of the screen. Even when I hit mod4+Enter, it doesn't tile up nicely with the others. Why is that?

(我更新了我的系统,重新安装了 sdl2.我也找不到任何相关的点击浏览谷歌.)

(I updated my system, reinstalled sdl2. I also couldn't find any relevant hit browsing google.)

推荐答案

所有窗口系统都要求您通过泵送消息队列来处理消息.请参阅本章了解一些 SDL 特定示例,但本质定期调用 SDL_PollEvent 或其他一些 SDL 函数来处理任何事件.您的代码只是延迟了一段时间.你不能让你的主线程休眠并期望窗口系统对此感到满意.他们运行事件.当窗口被映射时,有一个事件,然后另一个告诉窗口绘制自己或键盘输入.等待时抽事件队列.

All windowing systems require you to handle messages by pumping a message queue. See this chapter for some SDL specific examples but the essence is call SDL_PollEvent or some other SDL function regularly to process any events. Your code just delays for some time. You can't put your main thread to sleep and expect a window system to be happy with that. They run on events. When the window gets mapped, there is an event, then another to tell the window to paint itself or for keyboard input. Pump the event queue while waiting.

这篇关于示例 SDL 程序给出一个空窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆