Skip to content

Enhance main loop#2049

Closed
dimensionscape wants to merge 38 commits into8.4.0-devfrom
main-loop-experimental-v3
Closed

Enhance main loop#2049
dimensionscape wants to merge 38 commits into8.4.0-devfrom
main-loop-experimental-v3

Conversation

@dimensionscape
Copy link
Copy Markdown
Member

No description provided.

joshtynjala and others added 30 commits April 13, 2026 19:46
gcc 15 changes the default standard from gnu17 to gnu23, but HashLink mysql won't build with gnu23. I confirmed that clang also supports gnu17 (and it is the documented default).
Replace SDL_GL_CreateContext with SDL_GL_GetCurrentContext in SDLWindow.cpp to use a single shared GL context instead of creating one per window. Keep SDL_GL_MakeCurrent call and add comments explaining the choice and a TODO to revisit context-per-window if windows are ever given independent render loops.
The quotes used previously prevented ~ from being expanded by the
shell, which broke the path on some platforms.

This allows the cache to function properly and should speed up build
times.
…py/paste into community.openfl.org

Discourse seems to preserve most Markdown, but I guess it prefers - over * for list items
Add calibrated sleep logic and fractional-frame stepping to improve timing accuracy and avoid overshooting frame deadlines. Introduces calibration for SDL_Delay(1) (s_minSleepCostMs / s_delay1CostMs) and helper functions (CalibrateMinSleep/CalibrateDelay1, SleepMinStep/SleepShortest) to decide whether to sleep 1ms or yield (SDL_Delay(0)). Adds NextFrameStep with fractional accumulation to advance nextUpdate using integer+fractional frame periods, and replaces unconditional SDL_Delay(1) with conditional calibrated delay/yield in the main loop. These changes reduce jitter and drift caused by coarse sleep quantization.
…quested

Some native targets will update the clipboard text automatically, including macOS, but not iOS or tvOS.
It seems that the automatic updating is desktop only, and mobile needs the manual update when trying to read the clipboard.
…h different bytesPerElement

Also, fix missing range error on set() when passing a view that is too long for the remaining space after the offset
Replace strict LIME_GLES3_API preprocessor checks with a condition that also allows desktop GL (!LIME_GLES) and add runtime null checks for GL function pointers before invoking them. Updates glFramebufferTextureLayer, glTexImage3D, glTexStorage3D and glTexSubImage3D (and their HL bindings) to avoid calling missing symbols on platforms where those APIs aren't available.
Replace strict LIME_GLES3_API compile-time guards with checks that allow desktop GL (or GLES3) and verify function pointer availability before calling. Adds nullptr checks around calls like glBlitFramebuffer, glClearBuffer* variants, glCopyTexSubImage3D, glDrawBuffers and glReadBuffer (including HL_* wrappers) to avoid invoking missing entry points. Also scopes the draw_buffers allocation/loop inside the availability guard. This makes the OpenGL bindings safer across platforms and when certain GL functions are not present.

We should probably come up with a more idomatic solution here but this is a good temporary workaround. These functions are available on desktop gl, not just gles3.
Replace narrow LIME_GLES3_API-only #ifdefs with a desktop-aware condition (#if defined(LIME_GLES3_API) || !defined(LIME_GLES)) and add runtime function-pointer null checks before calling GL functions. A TODO comment was added to remind maintainers to audit GLES3-only wrappers and introduce a proper desktop-GL capability macro later. Multiple wrappers were updated (samplers, vertex arrays, buffer copy, instanced draws, framebuffer invalidation, sampler params, tex storage, renderbuffer multisample, is* queries, vertex attrib divisor, etc.) to avoid calling NULL proc pointers on desktop GL while preserving behavior for pure GLES builds.
…> to force NPM build for a project. Do not force 'dist' directory (use <assets /> tags to populate the appropriate dist/ or public/ folder)
…='npm' /> to force NPM build for a project. Do not force 'dist' directory (use <assets /> tags to populate the appropriate dist/ or public/ folder)"

This reverts commit 175bf95.
Introduce configurable main-loop and VSync support across layers and refactor SDL application event/timing logic.

- API: Add SetMainLoop and SetVSyncMode to Application and GetVSyncInterval/GetRefreshRate to Window.
- ExternalInterface: Expose lime_application_set_main_loop and lime_application_set_vsync_mode (including HL variants).
- SDL backend: Large refactor of SDLApplication to support requested main-loop settings (profile, frameRate, timePrecision, busyWait, uncapMode, vsync), display refresh detection, sleep calibration, high-resolution timing, scheduler unthrottling, busy-wait modes, and improved frame dispatching. Adds modal event watch for native modal loops (Windows) and reorganizes event handling into many Process* helper methods.
- Window flags: Add several new WINDOW_FLAG_* values (SKIP_TASKBAR, UTILITY, POPUP_MENU, TOOLTIP).
- Haxe: Add enums/files for BusyWaitMode, FrameOptions, FrameProfile, TimePrecision, UncapMode, VSyncMode and related updates across backends and app/window Haxe classes.
- Tests: Add FrameTimingTest for runtime testing.

These changes enable finer control over application's main loop behavior and VSync handling, and improve cross-platform event/timing robustness.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants