GUI 输出如何从应用程序到硬件级别工作? [英] How does GUI output work from application to hardware level?

查看:19
本文介绍了GUI 输出如何从应用程序到硬件级别工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从事 GUI 编程并做了一些研究.现在对我来说并不是一切都清楚.如果我使用 GTK+ 作为工具包,它如何与显卡通信?

在 Linux 系统上,我想应该是 GTK --> X Server --(OpenGL)--> 显卡.对吗?

我读到一些 GUI 直接绘制 OpenGL(例如 Blender3D),那么其他应用程序如何绘制它们的 GUI?

如果显卡的唯一 API(我知道的)是 Direct3D 和 OpenGL,那么软件渲染和硬件加速之间有什么区别?

做软件渲染"的软件能不能直接写入显卡的framebuffer,让OpenGL不受影响?

PS:抱歉问了很多问题,但我真的不明白这一切是如何运作的,感谢您的每一个回答:)

解决方案

在 Linux 系统上,我想应该是 GTK --> X Server --(OpenGL)--> 显卡.对吗?

没有.Linux 上的 GTK+ 去

/-[ 如果直接上下文 ]---/-->OpenGL >-+---------//->GLX -+-------------- /  GTK+ -+->开罗 >-+--->XRender >--------+----+->Xlib/xcb >-+->X服务器>-+->内核模块 >->图形处理器 -->像素图缓冲区 >–//―---------------------------/

<块引用>

我读到一些 GUI 直接绘制 OpenGL(例如 Blender3D),那么其他应用程序如何绘制它们的 GUI?

它只是Blender"(没有尾随 3D).Blender 的 GUI 工具包使用 OpenGL 作为其唯一的后端,是的.但是 GUI 不是直接使用 OpenGL 绘制的,这只是使用起来很麻烦(使用 OpenGL 调用绘制每个按钮.Blender 有自己的工具包.GTK+ 是另一个工具包,但与 Blender 无关(实际上,一个我的一个宠物项目正在提取 Blender 的 GUI 工具包,以便它可以在独立项目中使用).

GTK+ 和 Qt 等工具包旨在实现最大的可移植性.Blender 知道将有 OpenGL 可用.为 GTK+ 或 Qt 开发的应用程序可能能够在不支持 3D 的系统上运行,因此 GTK+ 和 Qt 的设计允许在多个后端上运行.GTK+ 现在在第 3 版中使用 Cairo 图形引擎作为图形后端.Cairo 再次拥有自己的后端,即绘制到像素图(像素图像)中的软件光栅器,或将绘制命令代理到底层图形架构.对于 Linux 上的 Cairo,这可能是 OpenGL 或 X11(核心和 XRender 协议扩展).

<块引用>

如果显卡的唯一 API(我知道的)是 Direct3D 和 OpenGL,那么软件渲染和硬件加速之间有什么区别?

OpenGL 和 Direct3D 都不与显卡通信.它们与显卡的驱动程序对话.因此,您的选择是,自己与驱动程序交谈,绕过 OpenGL 和 Direct3D.但你为什么要这样做?很无聊.

此外,在 Windows 上,您还有用于绘图的 GDI 和/或 WPF(Windows Presentation Foundation)和 Direct2D.

在 Linux 上,您可以获得用于绘制精美图片的 X11 核心和 XRender 扩展协议.

另一个兴起的 API 是 OpenVG,旨在标准化所有这些 2D 绘图 API.至少在 Linux 中,OpenGL 和 OpenVG 已被选为长期唯一可用的抽象绘图 API,并带有一些用于管理帧缓冲区和用户输入的窗口系统.Wayland 正在开发中(我完全不喜欢这种设计)和 X11,我认为它的设计更好(它是一个面向网络的系统,允许分布式执行,我认为这在未来非常重要),但需要一个对一些X12"进行彻底改造——清除遗留的垃圾,使其在接触颜色空间中运行,使连接可转换(以便您可以在 X 服务器之间迁移客户端,这将允许以更优雅的方式锁定 X 会话,通过将所有连接移动到某个影子 X 服务器,而不是尝试使用锁定屏幕保护程序来阻止访问).

<块引用>

做软件渲染"的软件能不能直接写入显卡的framebuffer,让OpenGL不受影响?

不在现代操作系统上.但是,操作系统可能会通过某些帧缓冲区 API(Linux 上的/dev/fb0)为您提供对图形卡的抽象访问.然而,帧缓冲区是不受管理的,所以如果有 X 服务器或 Wayland 正在运行,那么它们中的任何一个都负责管理 FB,那么这与您无关.

I am getting into GUI programming and did some research. Now not everything is clear to me. If I would use GTK+ as toolkit, how does it communicate with the graphics card?

On a Linux system I suppose it would be GTK --> X Server --(OpenGL)--> graphics card. Is this right?

I read that some GUIs directly draw OpenGL (e.g. Blender3D), so how do other apps draw their GUIs?

If the only APIs (that i know of) for graphics cards is Direct3D and OpenGL, what is the distinction between software rendering and hardware acceleration?

Can software that does "software rendering" directly write to the framebuffer of the graphics card, so that OpenGL is untouched?

PS: sorry for the many questions, but i don't really get it how that all works, thanks for every answer :)

解决方案

On a Linux system I suppose it would be GTK --> X Server --(OpenGL)--> graphics card. Is this right?

No. GTK+ on Linux goes

                                              /-[ if direct context ]---
                     /--> OpenGL >-+---------/                           
                    /              -> GLX -+--------------              
                   /                                                     
GTK+ -+-> cairo >-+---> XRender >--------+----+-> Xlib/xcb >-+-> X server >-+-> Kernel Module >-> GPU
                  –-> pixmap buffer >–/
                                      /
         ―---------------------------/

I read that some GUIs directly draw OpenGL (e.g. Blender3D), so how do other apps draw their GUIs?

It's just "Blender" (no trailing 3D). Blender's GUI toolkit uses OpenGL as its only backend, yes. But the GUI is not directly drawn using OpenGL, that would be just to cumbersome to work with (draw each and every button using OpenGL calls. Blender has its very own toolkit. GTK+ is another toolkit but not tied to Blender (in fact, one of my pet projects is extracting Blender's GUI toolkit, so that it can be used in independent projects).

Toolkits like GTK+ and Qt are designed for maximum portability. Blender has the luxury of knowing, that there will be OpenGL available. Apps developed for GTK+ or Qt may be able to run on non 3D capable systems, so the design of GTK+ and Qt allow to run on a number of backends. GTK+ now in version 3 uses the Cairo graphics engine as graphics backend. Cairo again has its own backends, namely a software rasterizer drawing into pixmaps (pixel images), or proxying drawing commands to an underlying graphics architecture. In the case of Cairo on Linux this may be either OpenGL or X11 (core and XRender protocol extensions).

If the only APIs (that i know of) for graphics cards is Direct3D and OpenGL, what is the distinction between software rendering and hardware acceleration?

Neither OpenGL nor Direct3D talk to the graphics card. They talk to the graphics card's drivers. So the option you'd have would be, talking to the drivers youself, bypassing OpenGL and Direct3D. But why would you do this? It's tedious.

On Windows in addition you have the GDI and/or the WPF (Windows Presentation Foundation) for drawing stuff, and Direct2D.

On Linux you get the X11 core and XRender extension protocol for drawing nice pictures.

Another API in the rise is OpenVG, which aims to standardize all those 2D drawing APIs. And at least in Linux OpenGL and OpenVG have been selected to become the only available abstract drawing APIs in the long term, with some windowing system for managing the framebuffer and user input. There's Wayland in development (which design I completely dislike) and X11, which I think has the better design (it's a network oriented system, that allows for distributed execution, something I consider very important in the future), but is in need of a complete overhaul into some "X12" – cleaning out the legacy cruft, make it operate in a contact color space, make connections transitionable (so that you can migrate clients between X server, which would allow for a much more elegant way of locking X sessions, by moving all the connections into some shadow X server, instead of trying to block access using a locking screen saver).

Can software that does "software rendering" directly write to the framebuffer of the graphics card, so that OpenGL is untouched?

Not on a modern operating system. However the OS may give you an abstracted access to the graphics card through some framebuffer API (/dev/fb0 on Linux). However the framebuffer is unmanaged, so if there's a X server or Wayland running, either of those are in task of managing the FB, and it's none of your business then.

这篇关于GUI 输出如何从应用程序到硬件级别工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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