Add nativescript frame callback, deprecate NimRuntime
This commit is contained in:
parent
e587fdf382
commit
0062568dbc
5 changed files with 19 additions and 16 deletions
|
|
@ -95,15 +95,6 @@ If you would like to use Nim in an existing project:
|
|||
GDNative library resource that contains paths to dynamic libraries
|
||||
compiled by Nim.
|
||||
|
||||
3. Add ``NimRuntime`` as an `AutoLoad singleton <https://godot.readthedocs.io/en/stable/learning/step_by_step/singletons_autoload.html>`_
|
||||
to your project. To do this, copy ``project/scripts/NimRuntime.gdns`` into
|
||||
your project and add these lines to ``project.godot``, adjusting path to
|
||||
``NimRuntime.gdns`` as necessary:
|
||||
.. code-block:: cfg
|
||||
[autoload]
|
||||
NimRuntime="*res://scripts/NimRuntime.gdns"
|
||||
|
||||
|
||||
Next Steps
|
||||
----------
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
author = "Xored Software, Inc."
|
||||
description = "Godot Engine bindings"
|
||||
license = "MIT"
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
--path:"$projectdir"
|
||||
--path:"$projectdir"
|
||||
-d:useRealtimeGc
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# Copyright 2017 Xored Software, Inc.
|
||||
|
||||
import tables, typetraits, macros
|
||||
import tables, typetraits, macros, asyncdispatch
|
||||
import core.godotbase
|
||||
import core.vector2, core.rect2,
|
||||
core.vector3, core.transform2d,
|
||||
|
|
@ -668,14 +668,22 @@ proc godot_gdnative_terminate(options: ptr GodotNativeTerminateOptions) {.
|
|||
cdecl, exportc, dynlib.} =
|
||||
deallocHeap(runFinalizers = not options[].inEditor, allowGcAfterwards = false)
|
||||
|
||||
proc godot_nativescript_thread_enter() {.
|
||||
cdecl, exportc, dynlib.} =
|
||||
const nimGcStepLengthUs {.intdefine.} = 2000
|
||||
proc godot_nativescript_frame() {.cdecl, exportc, dynlib.} =
|
||||
if asyncdispatch.hasPendingOperations():
|
||||
poll(0)
|
||||
GC_step(nimGcStepLengthUs, false, 0)
|
||||
|
||||
when not defined(release):
|
||||
onUnhandledException = proc(errorMsg: string) =
|
||||
printError("Unhandled Nim exception: " & errorMsg)
|
||||
|
||||
proc godot_nativescript_thread_enter() {.cdecl, exportc, dynlib.} =
|
||||
when compileOption("threads"):
|
||||
setupForeignThreadGc()
|
||||
else:
|
||||
print(cstring"A foreign thread is created, but app is compiled without --threads:on. Bad things will happen if Nim code is invoked from this thread.")
|
||||
|
||||
proc godot_nativescript_thread_exit() {.
|
||||
cdecl, exportc, dynlib.} =
|
||||
proc godot_nativescript_thread_exit() {.cdecl, exportc, dynlib.} =
|
||||
when compileOption("threads"):
|
||||
teardownForeignThreadGc()
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
import asyncdispatch
|
||||
import godot, node
|
||||
|
||||
{.warning: ("NimRuntime is deprecated - it is no longer necessary to add it " &
|
||||
"as an AutoLoad class. It will be removed in v0.5.0.").}
|
||||
|
||||
gdobj NimRuntime of Node:
|
||||
method enterTree*() =
|
||||
discard getTree().connect("idle_frame", self, "idle", newArray())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue