Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/windy/platforms/emscripten/emdefs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ proc emscripten_set_main_loop*(f: proc() {.cdecl.}, a: cint, b: bool) {.importc.
# Additional Emscripten functions that might be needed
proc emscripten_cancel_main_loop*() {.importc.}
proc emscripten_get_now*(): cdouble {.importc.}
proc emscripten_request_animation_frame_loop*(f: proc(time: cdouble): cint {.cdecl.}, userData: pointer): cint {.importc.}
proc emscripten_sleep*(ms: cuint) {.importc.}

# WebGL bindings
Expand Down
9 changes: 9 additions & 0 deletions src/windy/platforms/emscripten/platform.nim
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ proc pollEvents*() =
pollHttp()
emscripten_sleep(0)

proc run*(window: Window) =
proc mainLoop() {.cdecl.} =
if mainWindow != nil:
if mainWindow.onFrame != nil:
mainWindow.onFrame()
mainWindow.state.perFrame = PerFrame()
pollHttp()
emscripten_set_main_loop(mainLoop, 0, true)

proc size*(window: Window): IVec2 =
# Get the size of the canvas.
result.x = get_window_width() * get_device_pixel_ratio().int32
Expand Down