除非清除其他表面,否则 SDL 渲染文本不会显示
我有一个
timer = TTF_RenderText_Solid( tfont, timeStr.str().c_str(), txtColor );
applySurface(500, 30, timer, screen);
,在“屏幕”表面上我也应用了我的角色和我的墙。但由于某种原因,除非我已经将“地板表面”和“炭表面”设为 NULL,否则我似乎看不到计时器。我做错了什么吗?
I have a
timer = TTF_RenderText_Solid( tfont, timeStr.str().c_str(), txtColor );
applySurface(500, 30, timer, screen);
and on the 'screen' surface I have also applied my character, and my wall. But for some reason I can't seem to see the timer unless I have already NULL the 'floorsurface' and the 'charsurface'. Am I doing something wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将timerUpdate()放在SDL_Flip(screen)之前。您正在调用SDL_Flip,然后调用timerUpdate()。所以你想,好吧,没关系,下次翻转屏幕时,我会看到文本。但发生的情况是,在屏幕再次翻转之前,您在顶部复制了更多表面,然后您看不到文本,因为您在其顶部复制了表面。您所需要做的就是更改顺序,因此
应该可以工作。
Try putting timerUpdate() before SDL_Flip(screen). You are calling SDL_Flip, then you call timerUpdate(). So you think, OK, that's fine, next time the screen is flipped, I'll see the text. But what is happening is that you are blitting more surfaces on top before the screen is flipped again, and then you can't see the text because you blitted surfaces on top of it. All you need to do is change the order, so
should work.