c++ 中的直线
Windows 提供哪些库来绘制线条?我只对 2D 库感兴趣,而不是 OpenGL 或 DirectX。我正在 C++ 工作。
What libraries does Windows provide to draw lines? I am only interested in 2D libraries, not OpenGL or DirectX. I am working in C++.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
编辑:忘记了点。
编辑2:对角线:
EDIT: Forgot the dots.
EDIT 2: Diagonal:
取决于您的平台。
在 Windows 中,您可以使用 GDI 或 GDI+。
对于 Mac OS,我确信 Carbon 和 Cocoa 都提供了这个功能 - 尽管我承认对这两个 API 知之甚少。
Qt 提供跨平台绘图库,可在任何 Linux、Windows 或 Mac 上运行。
编辑:
Direct2D 是 Windows 的另一个 C++ 选项。它也是完全硬件加速的,这很酷。至于在全屏窗口上绘图,与在常规窗口中绘图没有什么不同。您只需要一些额外的代码即可最大化窗口并将其设置为全屏模式。
Depends on your platform.
In Windows you could use GDI or GDI+.
For Mac OS I'm sure both Carbon and Cocoa provide this feature - though I confess to having little knowledge of either API.
Qt provides cross-platform drawing libraries that will work on any of Linux, Windows or Mac.
EDIT:
Direct2D is another C++ option for Windows. It's fully hardware accelerated too which is cool. As for drawing on a fullscreen window, it's no different than drawing in a regular window. You'll just need some extra code to maximize the window and set it to fullscreen mode.
这取决于。你用的是什么系统?你想怎么画它? 3D 还是 2D?你想要全屏吗?
老实说,OpenGL 与 GLUT 这样的库一起使用非常容易。设置完成后,所需要的就是
(纯粹主义者会因为我使用 3.0 标准中不存在的 OpenGL 形式而对我大喊大叫,但我认为这不是一个需要长期向前兼容的主要项目)。
我想到的另外两个快速库:
听起来像您的库:它有快速设置、大量教程,而且是纯 C 语言。不幸的是,您必须使用另一个库(即 SDL_Draw)来实际绘制线条。
几年前我使用过这个库,但从那以后就没有使用过。我的记忆是它在形式和功能上很像SDL。它在 Windows 上运行良好,但不像 OS X 上的 SDL 那么容易。Allegro 确实(!)有一个内置的线条绘制函数,称为 line()(喜欢这个简洁性)。
It depends. What system are you on? How would you like to draw it? In 3D or 2D? Do you want fullscreen?
Honestly, OpenGL is pretty easy to use with a library like GLUT. After you set it up, all it takes is
(Purists will yell at me for using a form of OpenGL that isn't around in the 3.0 standard, but I assume this isn't a major project needing forward-compatibility for a long time).
Two other quick libraries that come to mind:
Sounds like your library: it has quick setup, lots of tutorials, and it's plain C. Unfortunately, you'll have to use another library (i.e. SDL_Draw) to actually draw the line.
I used this library a few years ago, but not since then. My recollection is that it's a lot like SDL in form and function. It works well on Windows, but is not as easy as SDL on OS X. Allegro does(!) have a built in line drawing function called line() (gotta love that brevity).