korlibs / korlibs/korge

[Important] Hugely simplify GameWindow and rendering

Open
#1,924 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Kotlin
Stars
3k
Forks
148
Avg merge
13h 44m
Merged PRs (30d)
1

Description

Right now GameWindow and rendering is super complicated on the korgw side.

We should simplificate it as much as possible, specially now that we have less targets.

On JS?
* setInterval(60ms): update
* requestAnimationFrame: render

On JVM / Android / Native:
* Thread handling the event loop with a timer every 60 fps: so we have consisent updating. In that thread we don't sleep while we are handling events. Updating the game grabs a lock. After updating if something change, we request a frame update. We can prepare a frame on this thread in a renderbuffer when required.
* On the UI thread, handle frame render requests and just blit the generated renderbuffer in the current frame, do vsync here. Handle also events here. We should either create a shared opengl context, or use a locking mechanism to grab the opengl context.

This should also avoid I/O delays because events are only handled in the event loop and right now that event loop is in a thread that is sleeping on vsync.
This should alos fix flickering on windows JVM When not rendering in continuous mode.

This is a long-standing issue, so this task is important. It should also make the code more mainteintable for the long run.

Might worth exploring and create a new simpler API, and then migrate to the old one once we get it right on all the targets.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the current GameWindow and rendering entry points for JS, JVM, Android, and Native, comparing their event-loop, timer, frame-request, and event-handling paths. Done means a simpler cross-target design with consistent updates and rendering, while addressing I/O delays and JVM Windows flicker; the issue leaves API exploration and migration scope open.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
game-dev
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.