Is there a way to perform vector draws on low leve...
# korge
s
Is there a way to perform vector draws on low level, just by executing functions? The only way to draw I currently know is to create an object for every visible vector primitive I have and manage it. For example, I can do
val c = circle()
and then when I don't need it I must do
c.removeFromParent()
to avoid memory leaks. Can I just draw a circle without creating an object? Like in Canvas2D Web API, for example?
d
val c = graphics { circle(...) }
👀 1
misses a
clear
inside g.apply
🙏 1
before the fills
👀 1
but be aware that graphics rasterizes the graphics via software, generates a texture and uploads to the gpu. For complex graphics, if you can avoid it, might not be the best option to update graphics on each frame.
s
Great, thank you! It now works. AFAIR, LibGDX is more effective in terms of low-level graphics calls. The same code for painting there:
Copy code
Gdx.gl.glClearColor(0, 0, 0, 1)
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)

shapeRenderer.begin(ShapeType.Filled)
shapeRenderer.setColor(255 / 255.0f, 255 / 255.0f, 0 / 255.0f, 1f)
with(rect) { shapeRenderer.rect(x, y, width, height) }
shapeRenderer.end()
There I could easily draw many primitives at 144 FPS. I think there was no hacks with software rasterizing... Is it possible to optimize this in KorGE? Of course, there are many places where you can prealocate Views to draw, but also there are cases when you don't know which and how many primitives you need to draw, and it seems KorGE can't handle these cases effectively now.
d
just a rect?
you can paint rects as you wish, or if you have triangles, you can paint them also
but antialiased vectors with curve support currently is done via software and rasterized into a texture
👌 1
you can also convert the path into points + triangulate + render that mesh
but not straight forward
and that wouldn't be antialiased