简体   繁体   English

第三方库怎么能做标准库做不到的事情呢?

[英]How can third-party libraries do things that the standard library can't do?

I read on multiple StackOverflow answers that C and C++ do not have graphics libraries as part of its Standard Library, then how do third party libraries implement Graphical User Interface?我在多个 StackOverflow 上阅读了 C 和 C++ 没有图形库作为其标准库的一部分的答案,那么第三方库如何实现图形用户界面?

Suppose I am a developer who wants to create a library that can draw shapes on the screen, how do I even make such a library without using any other third-party library?假设我是一名开发人员,想要创建一个可以在屏幕上绘制形状的库,我什至如何在不使用任何其他第三方库的情况下制作这样的库? Once you have a basic pixel drawing function, you can build on top of it many other functions like function for drawing squares, circles, etc with basic logic but how do you create that initial pixel drawing function that C and C++ do not understand? Once you have a basic pixel drawing function, you can build on top of it many other functions like function for drawing squares, circles, etc with basic logic but how do you create that initial pixel drawing function that C and C++ do not understand?

How can third-party libraries do things that the standard library can't do?第三方库怎么能做标准库做不到的事情呢?

At the lowest level, they use APIs provided by the operating system.在最低级别,它们使用操作系统提供的 API。

In most cases, there is typically a stack of libraries with increasing levels of abstraction.在大多数情况下,通常会有一堆抽象级别不断增加的库。 On top of operating system API, there is often a system libraries (such as glibc, libDRM).在操作系统 API 之上,通常有一个系统库(如 glibc、libDRM)。 On top of system libraries, there is often a portable cross-platform abstraction (such as libuv, Mesa3D).在系统库之上,通常有一个可移植的跨平台抽象(例如 libuv、Mesa3D)。 On top of those, there are more complex libraries and frameworks that combine multiple interfaces (such as a web server framework, SDL).除此之外,还有更复杂的库和框架组合了多个接口(例如 web 服务器框架,SDL)。

Suppose I am a developer who wants to create a library that can draw shapes on the screen, how do I even make such a library without using any other third-party library?假设我是一名开发人员,想要创建一个可以在屏幕上绘制形状的库,我什至如何在不使用任何其他第三方库的情况下制作这样的库?

Since using operating system API's is operating system specific, let's use Linux as an example.由于使用操作系统 API 是特定于操作系统的,因此我们以 Linux 为例。

You have a choice between multiple graphics API's.您可以在多个图形 API 之间进行选择。 Perhaps most commonly used are the framebuffer device, and direct rendering manager.也许最常用的是帧缓冲设备和直接渲染管理器。

However, if you want your program to be windowed with other graphical programs, then there must be co-ordination between the programs.但是,如果您希望您的程序与其他图形程序窗口化,那么程序之间必须有协调。 This is the job of a display server (typically Xorg).这是显示服务器(通常是 Xorg)的工作。 Most graphical Linux programs do not interact with the graphics APIs directly but instead through such server.大多数图形 Linux 程序不直接与图形 API 交互,而是通过此类服务器。 If you wish to not use a client library provided by the server, then you must re-implement their client side protocol.如果您不想使用服务器提供的客户端库,则必须重新实现其客户端协议。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 cmake 中构建参数化的第三方库? - How do I build a parameterized third-party library in cmake? 如何解决两个不使用命名空间的第三方库之间的类名冲突? - How to resolve class-name conflicts between two third-party libraries that do not use namespaces? 如何链接(或解决)两个定义相同符号的第三方静态库? - How can I link with (or work around) two third-party static libraries that define the same symbols? 不能包含与 CMake 第三方库链接的 - Can not include linked with CMake third-party library 如何在C ++中的线程中正确处理永久挂起的第三方库调用? - How do I correctly handle a permanently hung third-party library call in a thread in C++? 如何使第三方库对Boost线程使用是线程安全的? - How can I make a third-party library thread-safe for use with Boost threads? 当两个共享库依赖于以不同方式编译的第三方的相同版本时该怎么办? - What to do when two shared libraries depend on the same version of a third-party compiled differently? 我在哪里放置第三方库来设置C ++ Linux开发环境? - Where do I put third-party libraries to set up a C++ Linux development environment? 当两个Linux第三方库在枚举中使用相同的名称时在C ++中做什么 - What to do in C++ when two Linux third-party libraries are using the same names in their enumerations 使用第三方库(libusb),如何安装和使用? - Using third-party libraries (libusb), how to install and use?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM