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

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

问题描述

我正在进入GUI编程并做了一些研究。现在并非所有事情都清楚。
如果我将使用GTK +作为工具包,它如何与图形卡通信?



在Linux系统上,我认为它是GTK - > X服务器 - (OpenGL) - >图形卡。
这是正确的吗?



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

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



可以将软件渲染软件直接写入图形卡的帧缓冲区,以便OpenGL不受影响?



PS:很抱歉有很多问题,但我真的不知道它是如何工作的,感谢每一个答案:)

解决方案


在Linux系统上,我猜想它会是GTK - > X Server - (OpenGL) - >图形卡。这是正确的吗?


没有。在Linux上的GTK +转到

  /  -  [if direct context] --- \ 
/ - > OpenGL> - + --------- / \
/ \-> GLX - + -------------- \\
/ \\\
GTK + - + - > cairo> - + ---> XRender> -------- + ---- + - > Xlib / xcb> - + - > X服务器> - + - >内核模块> - > GPU
\ \ - > pixmap buffer> - /
\ /
\ ---------------------------- /




我读过一些GUI直接绘制OpenGL(例如Blender3D)其他应用程序绘制它们的图形用户界面?


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

像GTK +和Qt这样的工具包是为了最大的便携性而设计的。因为GTK +或Qt开发的应用程序可能能够在非3D功能的系统上运行,所以GTK +和Qt的设计允许在许多后端运行。开罗的图形引擎作为图形后端,开罗再次拥有自己的后端,即软件光栅绘制到像素图(像素图像),或代理绘图命令到底层的图形体系结构,在Linux上开罗的情况下,可能是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服务器上,而不是尝试使用锁定屏幕保护程序阻止访问)。


可以使用软件软件渲染直接写入图形卡的帧缓冲区,以便OpenGL保持原样?

不在现代操作系统上。但是操作系统可能会通过某些帧缓冲API(Linux上的/ dev / fb0)为您提供对图形卡的抽象访问。然而,framebuffer是非托管的,所以如果有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天全站免登陆