C++ 图形库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8545132/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 18:45:50  来源:igfitidea点击:

Graphics Library for C++

c++graphics2d

提问by MMS

I am working on a simulation project in C++ and I need to output some information graphically. I searched about it and found some libraries, but most of them just do plotting or something. There are also libraries like EasyBMP, which can be used to create bitmap images or similar image formats. There are also some libraries like OpenGL, DirectX and SDL which allow hardware-accelerated real time graphics. My problem is that I need a library for real time, hardware accelerated graphics. As a newbie in this field, I can't make head or tail of something like OpenGL or DirectX. I only need to do 2D graphics work, so I don't think it's necessary to spend my time for learning OpenGL or something. It'd better be cross-platform, but that's not a necessity. If you know some good source of information on SDL or OpenGL or DirectX, I'd be glad to know about it.

我正在用 C++ 进行一个模拟项目,我需要以图形方式输出一些信息。我搜索了它并找到了一些库,但其中大多数只是做绘图或其他东西。还有像 EasyBMP 这样的库,可以用来创建位图图像或类似的图像格式。还有一些库,如 OpenGL、DirectX 和 SDL,它们允许硬件加速实时图形。我的问题是我需要一个实时的、硬件加速的图形库。作为这个领域的新手,我无法对 OpenGL 或 DirectX 之类的东西产生兴趣。我只需要做2D图形工作,所以我认为没有必要花时间学习OpenGL什么的。最好是跨平台的,但这不是必需的。如果您知道有关 SDL 或 OpenGL 或 DirectX 的一些很好的信息来源,我会

PS: My target platform is windows.

PS:我的目标平台是windows。

采纳答案by Jessica Brown

Having learned the basics of OpenGL in a 10 week university course that was primarily focused on modeling statistical data, I would definitely think OpenGL would be a reasonable option for an easy to learn graphics package for 2D real time modeling.

在主要侧重于建模统计数据的 10 周大学课程中学习了 OpenGL 的基础知识后,我肯定会认为 OpenGL 是易于学习的用于 2D 实时建模的图形包的合理选择。

Although there's certainly complexity available to OpenGL you don't need to wrap your head around all these features you don't need, to make a basic project with a graphics screen is almost all boilerplate code that you don't need to understand well, you could practically copy and paste from a sample project. For example, here are some sample programsthat go with a textbook on OpenGL. Configuring the whole library to be part of your project is just a matter of adding a couple .lib files to a certain spot in the configuration settings, it doesn't take a lot to make it "do something" and then you will only need to familiarize yourself with a small subset of the features, to me it almost seemed easier than, say, drawing 2D stuff in Java.

尽管 OpenGL 确实有一些复杂性,但您不需要考虑所有这些不需要的功能,使用图形屏幕制作基本项目几乎是您不需要很好理解的所有样板代码,您几乎可以从示例项目中复制和粘贴。例如,这里有一些与 OpenGL 教科书配套的示例程序。将整个库配置为项目的一部分只是在配置设置中的某个位置添加几个 .lib 文件的问题,让它“做某事”不需要太多,然后你只需要熟悉一小部分功能,对我来说,这几乎比用 Java 绘制 2D 东西更容易。

I don't really know any of those other modeling tools well, just thought I'd throw out there that I wouldn't write that one off too quickly as being "too complex", it'd be reasonable to consider, even without a huge background in C++ or graphics, etc.

我真的不太了解任何其他建模工具,只是想我会扔掉那里我不会因为“太复杂”而过快地写下来,即使没有,考虑也是合理的C++ 或图形等方面的巨大背景。

回答by Lalaland

Let's create yet another list of 2D engines:

让我们创建另一个 2D 引擎列表:

All of these combinations support 2d graphics + input.

所有这些组合都支持 2d 图形 + 输入。

回答by bruziuz

If you need only to plot debug info then I created a tool to plot graphics and published it several hours ago.

如果您只需要绘制调试信息,那么我创建了一个绘制图形的工具,并在几个小时前发布了它。

https://www.youtube.com/watch?v=xD080qQVaD8&feature=youtu.be

https://www.youtube.com/watch?v=xD080qQVaD8&feature=youtu.be

https://github.com/burlachenkok/plotter_plusplus

https://github.com/burlachenkok/plotter_plusplus

To use this tool you can use desktop computer to show graphics.

要使用此工具,您可以使用台式计算机来显示图形。

But you target project(simulator) can be run anywhere in any language in any platform - to update graphics just send data over the network.

但是您的目标项目(模拟器)可以在任何平台上以任何语言在任何地方运行 - 更新图形只需通过网络发送数据。

回答by schlebe

You can program in C++ CLI/CLR and use Windows API as

您可以在 C++ CLI/CLR 中编程并使用 Windows API 作为

  1. Direct2D: on MSDN
  2. GDI+
  1. Direct2D:在 MSDN 上
  2. GDI+

Here is an interesting link on MSDN

这是MSDN 上的一个有趣链接

回答by Dobbo1989

There is quite a good tutorial on SDL that shows you how to capture input etc over at http://lazyfoo.net/SDL_tutorials/

http://lazyfoo.net/SDL_tutorials/上有一个关于 SDL 的很好的教程,向您展示了如何捕获输入等

It's based on game design but you could learn the concepts of an SDL program from it.

它基于游戏设计,但您可以从中学习 SDL 程序的概念。

Hope this is helpful for your question "If you know some good source of information on SDL or OpenGL or DirectX, I'd be glad to know about it."

希望这对您的问题“如果您知道有关 SDL 或 OpenGL 或 DirectX 的一些好的信息来源,我很高兴知道它”的问题有所帮助。

回答by user685684

For 2D, I recommend HGE, a game Engine use DX as graphic driver, which is easy to start with. It can only run under Windows, but hereis a port for MAC/UNIX

对于2D,我推荐HGE,一个使用DX作为图形驱动的游戏引擎,很容易上手。它只能在 Windows 下运行,但这里有一个适用于 MAC/UNIX 的端口

The problem you'll face when using SDL is that it is not hardware-accelerated. Yes, it support OpenGL, But if you want to use it with opengl, you must do every thing youself,

使用 SDL 时您将面临的问题是它不是硬件加速的。是的,它支持OpenGL,但是如果你想和opengl一起使用它,你必须自己做每件事,