简体   繁体   English

是否有针对C或C ++的高级形状绘制API?

[英]Is there a high level shape drawing API for C or C++?

I am starting a new project (Windows application), which needs a simple graphical interface. 我正在启动一个新项目(Windows应用程序),该项目需要一个简单的图形界面。 The graphics are not the main point of the application, the algorithms behind them are, so I'd like to spend as little time as possible thinking about graphics. 图形不是应用程序的重点,而是其背后的算法,因此我想花最少的时间考虑图形。

I need to draw simple shapes, connect them with lines, and label both the shapes and the edges. 我需要绘制简单的形状,将它们与线连接,并标记形状和边缘。 My ideal API would look something like 我理想的API看起来像

 n1 = Rectangle(width, height, center1);
 n1->label("Node1");
 n2 = Circle(radius, center2);
 l = Line(n1->rightEdge()->midpoint()), (n2->center()-Point(n2->radius,0));
 l->label("pathway",BELOW);

I know I could certainly use a low-level library to build up to this level of abstraction. 我知道我当然可以使用低层库来建立这种抽象层。 But I'd rather not, if it has already been done. 但我宁愿不这样做,如果它已经完成的话。 Does a graphics library with this level of abstraction exist? 具有这种抽象级别的图形库是否存在? I'd be equally happy with C/C++. 我对C / C ++同样满意。 C# would be an option too. C#也将是一个选择。

Due to the general ease of writing that kind of high-level system, given a low-level drawing API, you generally don't see this kind of 2D scene graph library. 由于一般编写这种高级系统的简便性,给定低级绘图API,因此通常看不到这种2D场景图形库。 The kind where there are explicit objects in the scene, and you move the objects around on the level of objects. 场景中存在显式对象的一种,您可以在对象级别上四处移动对象。

The closest I can think of is the way WPF handles drawing, where you create graphics objects and attach them to windows. 我能想到的最接近的是WPF处理图形的方式,您可以在其中创建图形对象并将其附加到窗口。 And that's .NET only. 那只是.NET。

Everything else, whether Cairo, AGG, Direct2D, etc are all immediate drawing APIs. 其他所有内容,无论是Cairo,AGG,Direct2D等都是即时绘图API。 There are no "objects" that you manipulate or attach labels to. 您没有操纵或粘贴标签的“对象”。 You simply draw stuff in a location. 您只需在某个位置绘制东西即可。 If you want to move something, you have to draw the stuff in that new location. 如果要移动某些东西,则必须在新位置绘制东西。

I use SDL for my graphics needs. 我将SDL用于我的图形需求。 I only use it for the OpenGL context (which it handles great) but it's quite friendly for getting efficient and portable graphics to work. 我只在OpenGL上下文中使用它(它处理起来很棒),但是它对于使高效且可移植的图形工作非常友好。 There are software drawing routines available if you don't want to deal with OpenGL. 如果您不想使用OpenGL,则可以使用软件绘图例程。

Microsoft提供了适用于Windows的新Direct2D API ,主要用于矢量图形。

perhaps AGG would work for you. 也许AGG会为您工作。 if you step back a few revs, you will also find a license which is better for commercial development. 如果您退后几转,您还将找到更适合商业开发的许可证。

您也可以尝试使用qt lib qt是一个很棒的工具包和多平台

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM