Graphics Library for C++

谁都会走 提交于 2019-12-20 14:56:43

问题


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.

PS: My target platform is windows.


回答1:


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.

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 programs that 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.

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.




回答2:


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

  • Qt Especially QtPainter
  • SFML
  • SDL
  • Allegro
  • Gtkmm Especially DrawingArea Uses Cairomm

All of these combinations support 2d graphics + input.




回答3:


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

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

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."




回答4:


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 here is a port for 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,




回答5:


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://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.




回答6:


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

  1. Direct2D: on MSDN
  2. GDI+

Here is an interesting link on MSDN



来源:https://stackoverflow.com/questions/8545132/graphics-library-for-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!