COMMUNITY

A comparison of drawing primitives between pop interactive frameworks

I’m currently interested (and really always have been…) in drawing graphics, 2D first, then 3D. I tend to imagine in vector graphics, not raster. I see that most of the pop interactive frameworks (Heaps, Kha, OpenFL) all provide a class for doing just this in 2D (h2d/graphics, graphics2/graphics & graphicsExtension, graphics), with OpenFL and Heaps mimicing flash’s graphics class (fill, lineto, etc.). (Kha’s graphic2/graphic class appears quite incomplete with a bunch of empty drawing functions. Though, I found some in graphicsExtension. Or maybe it’s in the other 10 files titled graphics… :face_with_raised_eyebrow:)

My question is: is there much of a difference of what goes on underneath? Let’s just say for OpenGL / OpenGL ES (for iOS) implementation. Will they all perform about the same for drawing primitives via OpenGL (/ES)?

For example, ohhhh, let’s say you had a drawing iPad app, and you could use all 10 of your little fingers to draw stuff on it at the same time…and a kid went ballistic with it. [Implementation:] Not merely painting on a single bitmap, but actually dynamically creating a thick line (a 2d cylinder polygon) along the paths each finger took.

Or, another example: a shooter game with tons of lasers going every which way, but not instantly: the filled rectangles sort of grow.

I don’t know how graphics really work, so that’s why I ask. I don’t know what magic those graphic classes do. I only know that I can use the flash-like graphics-class drawing api to draw a thick line following the path of the touch-points, or, drawing a filled rectangle and increasing the size of that rectangle over time. I would hope they are just sorta drawn directly to the gpu (send the polygon’s verticies and fill)… but I am at my limits of knowledge here. :confused:

Is this some rare case where OpenFL actually does just as good as the other two (Heaps ‘n Kha), or even better because it has some magical vector graphics stuff underneath? Or is OpenFL ‘n Lime still and jsut generally slower because it tries to limit itself to WebGL?..

Or maybe I’m thinking of all of this entirely wrong, and it’s better to just sorta paint on / re-use bitmaps?..

Anyway, Godot seems to support both ways: with canvasItem (it’s base 2d class; rendering_server_canvas.cpp), which contains the straight drawing api (primitives, filled and not), and inherited classes (node2d) like polygon2d (and polygon2d colllision!), in which you can still choose to render(?) it a simple solid color (filled) instead of rendering(?) a standard texture!.. So maybe I should start with Godot first :sleeping:… then run back to Haxe when I can’t do something within Godot… :confused:

…but the dream was to use Haxe ‘n low-level exposed frameworks for everything damnnit!, not be stuck with another big tool. :frowning: Maybe Godot will stay simple ‘n clean…maybe.

(note: I’ve been out of the computer world for 10 years, so go easy. :slight_smile: This is my first post. )

(an aside: In the FlashPunk of 10 years ago, you could use Flash’s api to draw stuff, but it was completely independent of FlashPunk’s scene tree (world) which was sprite / texture based, so layering things became an issue… I vaguely have memories of having trouble with HaxePunk ‘n AIR, something to do with certain OpenGL functions not being supported on ES. I also still have nightmares about using Cocos2d, especially Obj-c :fearful:, and anyway, they were both terribly slow on the old iPads.)

I have some experiments, the triangles have hitTest so you can do collision on shapes, it’s quite low level and currently not user friendly or complete, gluon and webgl are likely the most complete.

OpenFL/NME mostly use a software rendererer internally for vectors so it’s easy to achieve better vector graphics than with GPU, triangulation can be heavy and complex to do well, so in theory GPU can do better in practice it’s very hard.

Interesting non haxe links.
https://github.com/servo/pathfinder ( Rust Open )
https://acegikmo.com/shapes/ ( Unity Closed )
http://www.theawayfoundation.org/about/awayfl/ ( Typescript Open in progress )

Hmm…

This trilateral project is crazy! Trying to create a drawing class that supports ALL of the Haxe media frameworks!?? That sounds like open-source hell. Got to choose just one framework and stick with it.

But it’s a very very good resource, as it shows the drawing api being used on every framework. Thanks so much! :slight_smile:

As for the other links… I’m just not that interested. :confused:
Pathfinder looks cool, and reminds me that with Haxe you could probably just use a C (or Rust?) library, no? The possibilities. :open_mouth: It would probably be easy to integrate into a simple 2d engine too… but I don’t want take that path… do I…? :face_with_raised_eyebrow: VectorPunk?

Shapes looks cool too, but…Unity. :disappointed:

AwayFL is an… open-source version of Flash Player? Uh… :face_with_raised_eyebrow:

It’s quite simple concept all shaders can easily be setup to use triangles, if you translate curve contours into triangles you can render them in any engine that provides low level access to shaders ( or triangles at a push ).

I have full support for svg path string parsing ( full svg is too much effort ). You can see quite a few older examples ( also check xperimental ). It can be hooked up to render hxTrueType. Old version examples here:

So it currently has resonable Lime, Kha ( when Kha uses haxe4.2 ), WebGL, Gluon ( OpenGL ) support. OpenFL in theory operate with Lime but implementation details are more tricky. NME works a bit but can be tricky to setup ( 32/64 and Float32Array issues ). Heaps I am only currently able to hook into triangles so it’s too slow, but could be nearly as fast as pure WebGL in theory. Canvas/Flash/SVG can work with different triangle drawing approach.

But it has many limitations, polygon triangulation for fills is too heavy to run every frame ( at least the algorthms/libraries I have tried ), I have had some problems getting textures to work so no support yet on current. If you render fonts you probably need to draw them to a bitmap and then draw the bitmap as it’s too slow to do more than a few letters there is an Iron demo somewher, but I do have some support for 2d extrusion for rendering in 3D via iron ( using older version ):

As I said it’s experimental could be used in limited use cases.

I think AwayFL may have some vector GPU support so theoretically it could be interesting since it could be back ported to haxe and work with openfl away3d. The openFL webgl and opengl shaders are setup to in theory work without changes in practice it can be more complex.

Pathfinder could be used by a haxe engine but no examples of mixing haxe c++ and rust, and webassembly rust and haxe, but would be cool if there were.

Shapes only interesting if you just want Vectors graphics and don’t care about language/platform and willing to go unity, it’s more of interest because I don’t think it relys on triangles heavily and has gpu magic, but yet to convince Freya to implement non unity solution in haxe!

1 Like

Luxe used to have a different contour triangle implementation ( so similar in theory to my approach maybe few more triangles per segment ). I am not sure it was released, and now he has switched to Wren so that may also be interesting, as you maybe able to target Luxe Wren with haxe in the future but currently latest Luxe is not released I think he intends to work hard on it this month so who knows?

Trilateral was designed with engine indifference, it purposefully keeps the differences in other mini libs. Geom my math library was created to provide matrix manipulation power again not connected to a lib or to trilateral directly.

Ah yeah, Luxe and that whole snowkit …movement(?) seemed cool, but alas closed source… for now. So, I couldn’t compare. The old one is still up on the ‘hub.

I am not sure his full curve vector renderer was released but certainly he had a demo I saw it made it easier to do lines with soft edges so expect that will be in the Wren version of Luxe, but it used more triangles than I do so maybe would be too heavy it’s hard to say.

Ah right, as you say, you have your own geometry class.

Yeah. I noticed that when looking at all of these engines… Haxe provides a standard (std) math class, but no geometry class. Flash really excelled because all of that stuff was standard. Heck, they’re still being used!

Without that, every framework had to create their own discrete math things, I mean, not even geometrical shapes, but 2d vectors, 3d vectors, various size matricies… Ugh.

…but I’m sure even there’s some optimization stuff going on in even those fundamental classes. I’ve seen some named PooledVector, FastVector, and so on…

Surely everyone can come together and make some standard graphics math classes? Haha.

My Geom library has some nicer more modern haxe features than hxMath, but I think Thomas library maybe better choice he is really hot on making it very robust. I have yet to get my DualQuaternions pull through his strict QC, whereas mine likely needs changes.

In theory trilateral can work easily with hxMath, for data types look at Polygonal, or check franco’s work?

Flash was bad at matrix, it was a mess and also vectors where a mess.

Hahah, what I meant was: Flash excelled at providing a standard library to everyone. Whether it was good or not… :shushing_face:

Ah right, the HxMath thing seems the perfect solution. Abstract classes. Cool! Now only if everyone used it… :stuck_out_tongue:

It’s quite simple concept all shaders can easily be setup to use triangles, if you translate curve contours into triangles you can render them in any engine that provides low level access to shaders ( or triangles at a push ).

This sorta makes sense to me, and sounds like a powerful concept…

Though this is all quite interesting, all of this talk is just a bit too low-level for me. :frowning:

So, let’s get down to business: Nanjizal, since you have much experience with all of the frameworks (esp. Kha, OpenFL/Lime, ‘n Heaps), especially their graphics drawing api, could you just share with me, which of these frameworks felt good for you? Made sense, structured in a way you like, clean code, performance, whatever. Whatever your gut answer is. Feelings shall be hurt. :face_with_hand_over_mouth: (absolutely subjective question)

Or did you make TriLateral because didn’t like any of them! :laughing:

I’ll probably just go with what you say. I believe ya.

Alongside Godot… I just saw Godot’s code. That things a beauty for an open-source project! Straight C++. No documentation in code files. That makes it really readable… which is quite the contradiciton! But who thought making ‘->’ a part of syntax was a good idea? :cry: …Good lord, making an engine with an editor is hard work!!! How the heck did the guy behind Heaps do that with so few people? And here I am crying about making something at the level of FlashPunk. :sob:

You can make a game in any of them, if you can make your general purpose utilities run in several it will likely be more useful code.

Why not create something that runs in all of them and see how they compare:

They all in reality have strengths and weaknesses, you will only find what fits you by experimenting.

You might want to add some text and any other feature like sound, video, 3D or anything that maybe important to you.

Yet to implement a hxFixel version feel free to pull one!

1 Like

ahhhhh, that polyomino test is the perfect example!! A simple graphics-drawn game in all of the frameworks. :open_mouth: Thanks.

Haha, so I failed to get an opinion from ya. Yeah, okay. I’ll just have to try a few.

Well, I think that project answers my question.

Thanks again!!