Best practices for only 2D basic shapes drawing and blending ?

Julien Bayle's icon

Hi there,
I'm just asking here what would be the best practices in the case you'd need "only" to draw/move/color/scale/handle multiple 2D shapes.

I think I know some ways with Max like:
- jit.gl rendering with 3D objects and layered (I mean moved on z-axis in order to make them further or closer, another way of scaling) (draw, erase on the renderer which is well handled)
- jit.gl rendering with jit.gl.sketch (draw, erase, draw, erase... I'm afraid of inaccuracy if I move things fast)
- pure matrix rendering "à la processing" with js (or even mgraphics which is more c++ engine under-the-hood) (means also draw, erase, stuff)

I need to handle my 2D geometry as fast as possible (like flashing colors, making shape moving very fast on the screen etc)

What would you do yourself?

Andro's icon

Hi Julien,

Draw erase happens with the jit.gl.render context anyway so it doesn't really matter compared to jit.gl.sketch.
For multiple geometry say 100 circles. Jit.gl.mutliple..very fast.
Jit.gl.sketch can be combined with jit.gl.multiple if im correct.
I've drawn pretty complex geometry with 9 instances of jit.gl.slab and i easily get 60fps.
Pure matrix ? Not sure. Never needed to use it.
Z axis i'd avoid.. For 2d just put jit.gl.camera in ortho mode and then scale works correctly and position is easy to program.

Julien Bayle's icon

sure jit.gl.sketch can be "multiplied" by jit.gl.multiple.
I'm probably asking myself to much questions ;-)
Indeed, jit.gl.render in ortho mode (= the default gl context camera in ortho mode) + scale works fine.

I was more asking about jit.gl.render or ... something else.
Anyway, everything is rendered as gl so..
Yes, I'm complicated =-/

Andro's icon

How many shapes are we talking about here ?

Julien Bayle's icon

not really useful to say how much as these will "sometimes" be basic quads (4 points) and sometimes more complex (polygons with N points, 4 < N < 64)
anyway, I'll let that thread going just to know if some have some other ideas.

Andro's icon

Well a simple way to test it is to use say a sphere dim 20 20.
Increase with jit.gl.multiple until your system chokes. Then you know the limit.
Culling back faces gives huge speed increases as well.