- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我想知道在使用 xlib 时如何使用 eglSwapBuffers
正确启用 vsync。似乎对 eglSwapInterval
的调用被简单地忽略了。
我在窗口模式和全屏模式下运行。是否有可能在窗口模式下根本不支持它?在这种情况下,什么是降低我渲染频率的好方法( sleep 往往会导致错误行为,因为无法保证何时醒来)。
最佳答案
经过大量谷歌搜索,我终于找到了这个:
http://lists.freedesktop.org/archives/mesa-commit/2010-May/021020.html
egl: Implement EGL_NOK_swap_region
This extension adds a new function which provides an alternative to eglSwapBuffers. eglSwapBuffersRegionNOK accepts two new parameters in addition to those in eglSwapBuffers. The new parameters consist of a pointer to a list of 4-integer blocks defining rectangles (x, y, width, height) and an integer specifying the number of rectangles in the list.
并且/usr/include/EGL/eglmesaext.h 声明
EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegionNOK(EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint* rects);
这里还有一些示例用法:
https://github.com/blazt/piglit/blob/master/tests/egl/egl-nok-swap-region.c
所以我尝试这样使用它:
EGLint dirtyRect[4] = { 0, 0, 0, 0 };
PFNEGLSWAPBUFFERSREGIONNOK swap_buffers_region = (PFNEGLSWAPBUFFERSREGIONNOK)
eglGetProcAddress("eglSwapBuffersRegionNOK");
在我的窗口大小调整回调中
dirtyRect[2] = windowWidth;
dirtyRect[3] = windowHeight;
在我的主循环中
if (swap_buffers_region)
swap_buffers_region(egl_dpy, egl_surf, 1, dirtyRect);
else
eglSwapBuffers(egl_dpy, egl_surf);
它确实看起来更流畅并降低了帧率,但仅降至 180-200 FPS 的范围;所以我仍然需要在帧之间做一个 sleep 。也许它只会在关键 GPU 操作的一些短时间间隔内阻止交换缓冲区?或者也许我做得不对。不确定。
关于linux - xlib/egl 如何在 eglSwapBuffers 上获取 VSync/swapInterval,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11971947/
xlib 还在用吗?我能找到的有用文档是 http://tronche.com/在我看来,它非常过时。谁使用 Xlib? GTK+ 和 QT 是基于它构建的吗?提前致谢,嗯。 最佳答案 是的,像 GT
有谁知道什么是用于 32/24 位图像/像素图的 XLib ZPixmap 格式。它是 RGB(A) 或 BGR(A) 等还是高度依赖于实现? 最佳答案 像素图没有颜色,句号。它们只是像素值的数组。
我是一个全新的 GUI 程序员,经验很少(除了一些 Java 小应用程序)。我正在考虑编写一个需要简单二维图形的小应用程序。我不知道我应该使用 Xlib 还是 cairo 来绘制这些图。 与 cair
我现在对 Xlib 编程有点困惑。几周前我开始使用 dwm(一个轻量级的窗口管理器),我想找一些 Xlib 编程书籍或在线资源来定制 dwm。 然而,在网上谷歌搜索后,我并没有看到很多关于 Xlib
有没有可靠的方法来获得顶部的内部和外部矩形 带有 XCB/Xlib 的级别窗口? (IOW 框架和客户端矩形)。 这是我尝试过的: xcb_get_geometry 始终返回初始尺寸,即使在 窗口被调
我正在创建一个在多个 xsession 中使用多个游标(指针)的系统。我的电脑有多个视频卡用于控制不同的显示器。我想在每个屏幕上有一个不同的光标并控制每个屏幕。每个监视器都是一个不同的 session
例如,foobar:0.1将在名为 foobar 的机器上指定显示 0 的屏幕 1 . 但是Xlib中X服务器的屏幕号和显示号是什么意思呢? 是不是说一个X服务器可以有很多显示器,一个显示器可以有很多
我从各种文档中看到,XCloseDisplay 返回一个整数,我怀疑这是一个错误代码。 我应该如何处理这个值?是错误代码吗?如果是这样,我该如何处理错误? 最佳答案 我查看了源代码(lib/X11/C
我有一个 ARGB 图像数据。我希望将我的窗口图标设置为该数据。经过几个小时的搜索后,我仍然处于起点,手头一无所有。我知道我需要为图像数据创建一个像素图和(可能是)另一个用于掩码的像素图,并使用提示来
我正在学习使用 xlib,但无法获得 XChangeProperty()为我工作。 我有一个简单的程序可以成功显示一个窗口。但调用 XChangeProperty()总是失败,错误代码 error 1
我正在遵循书中的示例,并且我有一个绘制线条的绘图函数。当我将其放置在 XFlush() 之前的事件循环之前时,不会绘制任何线条,但是如果我将其放置在事件循环中,如下所示,则会绘制线条。 while(1
我正在尝试学习如何使用 Cairo 2D drawing library与 xlib 曲面。 我编写了一个允许创建多个窗口的小测试程序。每个函数可能有一个自定义的paint()函数,定期调用该函数以向
我需要检查(在我的 C++ 应用程序中)应用程序的窗口是否被另一个窗口重叠(部分或完全)。我如何使用 xlib 获取此信息? 我尝试获取窗口的 WM_STATE 属性并将其与 NormalState
[已解决 - 提供的示例包含答案!]我正在尝试实现一个以全屏模式启动并且不允许任何用户输入(无论是鼠标还是键盘)的程序,因为它只会在插入 USB 棒或 CD 时对 UDEV 信号使用react。我想防
我有一个可以捕获X窗口并将其作为子窗口托管的应用程序。 它以某种方式实现了一个非常基本的窗口管理器。没有窗口管理器正在运行。 除Java应用程序外,效果很好。 例如,如果Java应用程序具有菜单或弹出
我正在用 c 编写一个应用程序,它将使用 Xlib、GTK。我想创建一个热键来中断应用程序的事件并将其置于休眠状态。 我已经阅读了一些资料,但我相信我不能使用:X抓取键因为窗口管理器正在运行并且已经在
我从文档中不清楚 http://python-xlib.sourceforge.net/doc/html/python-xlib_toc.html 我如何确定性地检查给定的显示输出(例如:HDMI-1
我正在尝试将屏幕复制到位图文件,我找到了这个 write XImage to .bmp file in C线。我尝试了自己提供的代码,但无法使代码正常工作。它可以保存 img 文件,但无法打开它。我在
我正在尝试使用 Xlib 控制 Xterm。为此,我正在制作一个标题奇怪的 Xterm。在我列出所有窗口并检查它们的名称之后。但是有些东西被窃听了,当它们被列出时,我的 Xterm 的名字没有出现。这
我正在使用 c 和 xlib 制作第一个应用程序,到目前为止它进展顺利并且正在做我想做的事!这是一个无边框窗口,在应用启动时会自动全屏显示。 我的应用程序将有一些实用程序,例如桌面上的时钟和当前天气。
我是一名优秀的程序员,十分优秀!