SerVB
06/20/2020, 12:50 AMval 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?Deactivated User
06/20/2020, 1:07 AMSerVB
06/20/2020, 1:17 PMsuspend fun main() = Korge {
Logger.defaultLevel = Logger.Level.DEBUG
val rect = Rectangle(0, 10, 20, 20)
val g = graphics()
addHrUpdater { delta ->
log.debug { "FPS: ${ (1000 / delta.millisecondsDouble).roundToInt() }" }
++rect.x
if (rect.x > 100) {
rect.x = 0.0
}
g.apply {
fill(Colors.BLACK) {
rect(0.0, 0.0, this@Korge.width, this@Korge.height)
}
fill(Colors.YELLOW) {
with(rect) { rect(x, y, width, height) }
}
}
}
}
Deactivated User
06/20/2020, 1:18 PMclear
inside g.applySerVB
06/20/2020, 1:39 PMGdx.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.Deactivated User
06/20/2020, 1:40 PM