Double buffering and libgdx(双缓冲和 libgdx)
问题描述
我在 libgdx 中有一个非常简单的应用程序.它目前应该用粉红色的纹理覆盖一半的屏幕.它确实做到了,但是纹理在闪烁.基于我自己对主题的理解,以及这个线程:LibGDX 闪烁我需要启用双缓冲.或者,写入我的缓冲区.问题是,要么我对 google 无能,要么很难找到任何关于如何在 libgdx 中操作缓冲区的信息.如果有人可以为我提供资源,解释如何操作缓冲区,以及如何创建缓冲区,如何将它们与当前显示交换等.我将非常感激.
I have a very simple application in libgdx. It currently is supposed to cover half of the screen with pink texture. And it does that, the texture however is blinking. Basing on my own understanding of subject, as well as this thread: LibGDX blinking I need to enable double buffering. Or alternatively, write to my buffer. The thing is, either I am inept with google or it's very difficult to find any information how to manipulate buffers in libgdx. If someone could provide me with resources, explaining how to manipulate buffers, and how to create one, how to swap them with current display etc. I would be very grateful.
在网上搜索了一些之后,我在 badlogic 论坛上找到了帖子,声称 libgdx 默认设置了双缓冲.问题是,它是如何工作的?缓冲区何时交换?
After searching the web some more, I found post on badlogic forum, claiming that libgdx has double buffering set by default. The question is, how does it work? When are the buffers swapped?
推荐答案
Libgdx 默认启用双缓冲(它实际上是底层 OpenGL 基础架构的一部分,而不是 Libgdx).我不认为 Libgdx 公开了对双缓冲的任何控制.有一些控件可以禁用垂直同步,这可能会造成一些撕裂,但不太可能相关.
Libgdx has double buffering enabled by default (its really part of the underlying OpenGL infrastructure, not Libgdx). I don't think Libgdx exposes any controls over double buffering. There are some controls to disable vsync which might create some tearing, but are unlikely to be related.
获得这种行为的更可能的方法是,如果您的 render
方法仅被调用一次.这将绘制到一个缓冲区中.然后,假设 render
已成为无操作,没有任何内容被绘制到另一个缓冲区中,它们被切换,没有任何内容被绘制到原始缓冲区中,它们被切换等等.这可能导致您看到的闪烁行为.
The more likely way to get this behavior is if, somehow, your render
method is only invoked once. This will draw into one buffer. Then, assuming render
has become a no-op, nothing is drawn into the other buffer, they're switched, nothing is drawn into the original buffer, they're switched, etc. This can lead to the blinking behavior you're seeing.
如果该猜测没有涵盖它,您将不得不提供更多详细信息.你在哪个平台上运行?您是在运行稳定版本的 Libgdx 还是每晚构建的版本之一?您如何设置 libgdx 应用程序配置?您的 render
方法实际上是什么样的?
If that guess doesn't cover it you'll have to provide more details. Which platform are you running on? Are you running a stable version of Libgdx or one of the nightly builds? How are you setting up the libgdx app configuration? What does your render
method actually look like?
这篇关于双缓冲和 libgdx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:双缓冲和 libgdx
基础教程推荐
- 如何对 HashSet 进行排序? 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- 在螺旋中写一个字符串 2022-01-01