├── .gitignore ├── .vscode └── settings.json ├── README.md ├── default_env.tres ├── fonts └── Roboto │ ├── RobotoRegular.tres │ └── ttf │ ├── LICENSE.txt │ └── Roboto-Regular.ttf ├── fps_counter.tscn ├── icon.png ├── icon.png.import ├── main.tscn ├── nakefile.nim ├── nakefile.nim.cfg ├── nimlib.gdnlib ├── project.godot ├── scene.tscn ├── scripts ├── FPSCounter.gdns └── MainPanel.gdns └── src ├── config.nims ├── fpscounter.nim ├── mainpanel.nim ├── nim.cfg ├── stub.nim └── stub.nimble /.gitignore: -------------------------------------------------------------------------------- 1 | /.import 2 | /_dlls 3 | /nakefile 4 | /src/godotapi 5 | /logs 6 | nimcache 7 | .nimcache 8 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.tabSize": 2, 3 | "editor.rulers": [80], 4 | "editor.insertSpaces": true, 5 | "editor.detectIndentation": false, 6 | "files.eol": "\n", 7 | "files.trimTrailingWhitespace": true, 8 | "nim.buildOnSave": false, 9 | "nim.lintOnSave": true, 10 | "nim.project": ["src/stub.nim"], 11 | "files.exclude": { 12 | "**/.nimcache/**": true 13 | } 14 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Stub project to demonstrate usage of the [godot-nim](https://github.com/pragmagic/godot-nim) library. 2 | 3 | Prerequisites: 4 | 5 | 1. Install [nake](https://github.com/fowlmouth/nake): `nimble install nake -n`. 6 | 2. Ensure `~/.nimble/bin` is in your PATH (On Windows: `C:\Users\\.nimble\bin`). 7 | 3. Set `GODOT_BIN` environment varible to point to Godot executable (requires Godot 3.0 changeset [b759d14](https://github.com/godotengine/godot/commit/b759d1416f574e5b642413edd623b04f2a1d20ad) or newer). 8 | 4. Install godot-nim: `nimble install godot` 9 | 10 | Run `nake build` in any directory within the project to compile for the current platform. 11 | -------------------------------------------------------------------------------- /default_env.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="Environment" load_steps=2 format=2] 2 | 3 | [sub_resource type="ProceduralSky" id=1] 4 | 5 | radiance_size = 4 6 | sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 ) 7 | sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 ) 8 | sky_curve = 0.25 9 | sky_energy = 1.0 10 | ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 ) 11 | ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 ) 12 | ground_curve = 0.01 13 | ground_energy = 1.0 14 | sun_color = Color( 1, 1, 1, 1 ) 15 | sun_latitude = 35.0 16 | sun_longitude = 0.0 17 | sun_angle_min = 1.0 18 | sun_angle_max = 100.0 19 | sun_curve = 0.05 20 | sun_energy = 16.0 21 | texture_size = 2 22 | 23 | [resource] 24 | 25 | background_mode = 2 26 | background_sky = SubResource( 1 ) 27 | background_sky_custom_fov = 0.0 28 | background_color = Color( 0, 0, 0, 1 ) 29 | background_energy = 1.0 30 | background_canvas_max_layer = 0 31 | ambient_light_color = Color( 0, 0, 0, 1 ) 32 | ambient_light_energy = 1.0 33 | ambient_light_sky_contribution = 0.0 34 | fog_enabled = false 35 | fog_color = Color( 0.5, 0.6, 0.7, 1 ) 36 | fog_sun_color = Color( 1, 0.9, 0.7, 1 ) 37 | fog_sun_amount = 0.0 38 | fog_depth_enabled = true 39 | fog_depth_begin = 10.0 40 | fog_depth_curve = 1.0 41 | fog_transmit_enabled = false 42 | fog_transmit_curve = 1.0 43 | fog_height_enabled = false 44 | fog_height_min = 0.0 45 | fog_height_max = 100.0 46 | fog_height_curve = 1.0 47 | tonemap_mode = 0 48 | tonemap_exposure = 1.0 49 | tonemap_white = 1.0 50 | auto_exposure_enabled = false 51 | auto_exposure_scale = 0.4 52 | auto_exposure_min_luma = 0.05 53 | auto_exposure_max_luma = 8.0 54 | auto_exposure_speed = 0.5 55 | ss_reflections_enabled = false 56 | ss_reflections_max_steps = 64 57 | ss_reflections_fade_in = 0.15 58 | ss_reflections_fade_out = 2.0 59 | ss_reflections_depth_tolerance = 0.2 60 | ss_reflections_roughness = true 61 | ssao_enabled = false 62 | ssao_radius = 1.0 63 | ssao_intensity = 1.0 64 | ssao_radius2 = 0.0 65 | ssao_intensity2 = 1.0 66 | ssao_bias = 0.01 67 | ssao_light_affect = 0.0 68 | ssao_color = Color( 0, 0, 0, 1 ) 69 | ssao_quality = 0 70 | ssao_blur = 1 71 | ssao_edge_sharpness = 4.0 72 | dof_blur_far_enabled = false 73 | dof_blur_far_distance = 10.0 74 | dof_blur_far_transition = 5.0 75 | dof_blur_far_amount = 0.1 76 | dof_blur_far_quality = 1 77 | dof_blur_near_enabled = false 78 | dof_blur_near_distance = 2.0 79 | dof_blur_near_transition = 1.0 80 | dof_blur_near_amount = 0.1 81 | dof_blur_near_quality = 1 82 | glow_enabled = false 83 | glow_levels/1 = false 84 | glow_levels/2 = false 85 | glow_levels/3 = true 86 | glow_levels/4 = false 87 | glow_levels/5 = true 88 | glow_levels/6 = false 89 | glow_levels/7 = false 90 | glow_intensity = 0.8 91 | glow_strength = 1.0 92 | glow_bloom = 0.0 93 | glow_blend_mode = 2 94 | glow_hdr_threshold = 1.0 95 | glow_hdr_scale = 2.0 96 | glow_bicubic_upscale = false 97 | adjustment_enabled = false 98 | adjustment_brightness = 1.0 99 | adjustment_contrast = 1.0 100 | adjustment_saturation = 1.0 101 | 102 | -------------------------------------------------------------------------------- /fonts/Roboto/RobotoRegular.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="DynamicFontData" format=2] 2 | 3 | [resource] 4 | 5 | font_path = "res://fonts/Roboto/ttf/Roboto-Regular.ttf" 6 | -------------------------------------------------------------------------------- /fonts/Roboto/ttf/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /fonts/Roboto/ttf/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pragmagic/godot-nim-stub/c0fa88d72b12bf92e347c870588fbb7e323f05aa/fonts/Roboto/ttf/Roboto-Regular.ttf -------------------------------------------------------------------------------- /fps_counter.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=4 format=2] 2 | 3 | [ext_resource path="res://fonts/Roboto/RobotoRegular.tres" type="DynamicFontData" id=1] 4 | [ext_resource path="res://scripts/FPSCounter.gdns" type="Script" id=2] 5 | 6 | [sub_resource type="DynamicFont" id=1] 7 | 8 | size = 40 9 | use_mipmaps = false 10 | use_filter = false 11 | font_data = ExtResource( 1 ) 12 | _sections_unfolded = [ "Extra Spacing", "Font", "Settings" ] 13 | 14 | [node name="Label" type="Label"] 15 | 16 | anchor_left = 1.0 17 | anchor_top = 0.0 18 | anchor_right = 1.0 19 | anchor_bottom = 0.0 20 | margin_top = 10.0 21 | margin_right = 10.0 22 | grow_horizontal = 0 23 | rect_pivot_offset = Vector2( 0, 0 ) 24 | mouse_filter = 2 25 | mouse_default_cursor_shape = 0 26 | size_flags_horizontal = 1 27 | size_flags_vertical = 4 28 | custom_fonts/font = SubResource( 1 ) 29 | text = "FPS: 9000" 30 | percent_visible = 1.0 31 | lines_skipped = 0 32 | max_lines_visible = -1 33 | script = ExtResource( 2 ) 34 | _sections_unfolded = [ "Anchor", "Grow Direction", "Margin", "custom_colors", "custom_fonts" ] 35 | 36 | 37 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pragmagic/godot-nim-stub/c0fa88d72b12bf92e347c870588fbb7e323f05aa/icon.png -------------------------------------------------------------------------------- /icon.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" 6 | 7 | [deps] 8 | 9 | source_file="res://icon.png" 10 | source_md5="c3558f79862e8e00c74fb188280dd8ef" 11 | 12 | dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] 13 | dest_md5="faf846ccd89e2edfcabb6f1c3125aa7e" 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/normal_map=0 21 | flags/repeat=0 22 | flags/filter=true 23 | flags/mipmaps=false 24 | flags/anisotropic=false 25 | flags/srgb=2 26 | process/fix_alpha_border=true 27 | process/premult_alpha=false 28 | process/HDR_as_SRGB=false 29 | stream=false 30 | size_limit=0 31 | detect_3d=true 32 | svg/scale=1.0 33 | -------------------------------------------------------------------------------- /main.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=5 format=2] 2 | 3 | [ext_resource path="res://scripts/MainPanel.gdns" type="Script" id=1] 4 | [ext_resource path="res://fonts/Roboto/RobotoRegular.tres" type="DynamicFontData" id=2] 5 | [ext_resource path="res://fps_counter.tscn" type="PackedScene" id=3] 6 | 7 | [sub_resource type="DynamicFont" id=1] 8 | 9 | size = 80 10 | use_mipmaps = false 11 | use_filter = false 12 | font_data = ExtResource( 2 ) 13 | _sections_unfolded = [ "Font", "Settings" ] 14 | 15 | [node name="Panel" type="Panel"] 16 | 17 | anchor_left = 0.0 18 | anchor_top = 0.0 19 | anchor_right = 1.0 20 | anchor_bottom = 1.0 21 | rect_pivot_offset = Vector2( 0, 0 ) 22 | mouse_filter = 0 23 | mouse_default_cursor_shape = 0 24 | size_flags_horizontal = 1 25 | size_flags_vertical = 1 26 | script = ExtResource( 1 ) 27 | _sections_unfolded = [ "Anchor", "Margin" ] 28 | 29 | [node name="Label" type="Label" parent="." index="0"] 30 | 31 | anchor_left = 0.0 32 | anchor_top = 0.0 33 | anchor_right = 1.0 34 | anchor_bottom = 1.0 35 | rect_pivot_offset = Vector2( 0, 0 ) 36 | mouse_filter = 2 37 | mouse_default_cursor_shape = 0 38 | size_flags_horizontal = 1 39 | size_flags_vertical = 4 40 | custom_fonts/font = SubResource( 1 ) 41 | text = "Click me to load scene" 42 | align = 1 43 | valign = 1 44 | percent_visible = 1.0 45 | lines_skipped = 0 46 | max_lines_visible = -1 47 | _sections_unfolded = [ "Anchor", "Margin", "custom_fonts" ] 48 | 49 | [node name="FPS" parent="." index="1" instance=ExtResource( 3 )] 50 | 51 | margin_left = 189.0 52 | margin_bottom = 58.0 53 | 54 | 55 | -------------------------------------------------------------------------------- /nakefile.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Xored Software, Inc. 2 | 3 | import nake 4 | import os, ospaths, times 5 | import godotapigen 6 | 7 | proc genGodotApi() = 8 | let godotBin = getEnv("GODOT_BIN") 9 | if godotBin.len == 0: 10 | echo "GODOT_BIN environment variable is not set" 11 | quit(-1) 12 | if not fileExists(godotBin): 13 | echo "Invalid GODOT_BIN path: " & godotBin 14 | quit(-1) 15 | 16 | const targetDir = "src"/"godotapi" 17 | createDir(targetDir) 18 | const jsonFile = targetDir/"api.json" 19 | if not fileExists(jsonFile) or 20 | godotBin.getLastModificationTime() > jsonFile.getLastModificationTime(): 21 | direShell(godotBin, "--gdnative-generate-json-api", getCurrentDir()/jsonFile) 22 | if not fileExists(jsonFile): 23 | echo "Failed to generate api.json" 24 | quit(-1) 25 | 26 | genApi(targetDir, jsonFile) 27 | 28 | task "build", "Builds the client for the current platform": 29 | genGodotApi() 30 | let bitsPostfix = when sizeof(int) == 8: "_64" else: "_32" 31 | let libFile = 32 | when defined(windows): 33 | "nim" & bitsPostfix & ".dll" 34 | elif defined(ios): 35 | "nim_ios" & bitsPostfix & ".dylib" 36 | elif defined(macosx): 37 | "nim_mac.dylib" 38 | elif defined(android): 39 | "libnim_android.so" 40 | elif defined(linux): 41 | "nim_linux" & bitsPostfix & ".so" 42 | else: nil 43 | createDir("_dlls") 44 | withDir "src": 45 | direShell(["nimble", "c", ".."/"src"/"stub.nim", "-o:.."/"_dlls"/libFile]) 46 | 47 | task "clean", "Remove files produced by build": 48 | removeDir(".nimcache") 49 | removeDir("src"/".nimcache") 50 | removeDir("src"/"godotapi") 51 | removeDir("_dlls") 52 | removeFile("nakefile") 53 | removeFile("nakefile.exe") 54 | -------------------------------------------------------------------------------- /nakefile.nim.cfg: -------------------------------------------------------------------------------- 1 | nimcache=".nimcache" -------------------------------------------------------------------------------- /nimlib.gdnlib: -------------------------------------------------------------------------------- 1 | [entry] 2 | 3 | X11.64="res://_dlls/nim_linux_64.so" 4 | X11.32="res://_dlls/nim_linux_32.so" 5 | Windows.64="res://_dlls/nim_64.dll" 6 | Windows.32="res://_dlls/nim_32.dll" 7 | OSX.64="res://_dlls/nim_mac.dylib" 8 | Android.armeabi-v7a="res://_dlls/armeabi-v7a/libnim_android.so" 9 | iOS.armv7="res://_dlls/nim_ios_32.a" 10 | iOS.arm64="res://_dlls/nim_ios_64.a" 11 | 12 | [general] 13 | 14 | singleton=false 15 | load_once=true 16 | symbol_prefix="godot_" 17 | 18 | [dependencies] 19 | 20 | Windows=PoolStringArray() -------------------------------------------------------------------------------- /project.godot: -------------------------------------------------------------------------------- 1 | ; Engine configuration file. 2 | ; It's best edited using the editor UI and not directly, 3 | ; since the parameters that go here are not all obvious. 4 | ; 5 | ; Format: 6 | ; [section] ; section goes between [] 7 | ; param=value ; assign values to parameters 8 | 9 | config_version=3 10 | 11 | [application] 12 | 13 | config/name="Godot-Nim Stub" 14 | run/main_scene="res://main.tscn" 15 | config/icon="res://icon.png" 16 | 17 | [gdnative] 18 | 19 | singletons=[ ] 20 | 21 | [rendering] 22 | 23 | environment/default_environment="res://default_env.tres" 24 | -------------------------------------------------------------------------------- /scene.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=3 format=2] 2 | 3 | [ext_resource path="res://fps_counter.tscn" type="PackedScene" id=1] 4 | 5 | [sub_resource type="CapsuleMesh" id=1] 6 | 7 | radius = 1.0 8 | mid_height = 1.0 9 | radial_segments = 64 10 | rings = 8 11 | 12 | [node name="Node" type="Node" index="0"] 13 | 14 | [node name="MeshInstance" type="MeshInstance" parent="." index="0"] 15 | 16 | layers = 1 17 | material_override = null 18 | cast_shadow = 1 19 | extra_cull_margin = 0.0 20 | use_in_baked_light = false 21 | lod_min_distance = 0.0 22 | lod_min_hysteresis = 0.0 23 | lod_max_distance = 0.0 24 | lod_max_hysteresis = 0.0 25 | mesh = SubResource( 1 ) 26 | skeleton = NodePath("..") 27 | material/0 = null 28 | _sections_unfolded = [ "Geometry", "material" ] 29 | 30 | [node name="Label" parent="." index="1" instance=ExtResource( 1 )] 31 | 32 | [node name="Camera" type="Camera" parent="." index="2"] 33 | 34 | transform = Transform( 0.930689, 0.16529, -0.326338, 0, 0.892097, 0.451845, 0.365811, -0.420527, 0.830265, -0.972205, 1.19673, 2.59579 ) 35 | keep_aspect = 1 36 | cull_mask = 1048575 37 | environment = null 38 | h_offset = 0.0 39 | v_offset = 0.0 40 | doppler_tracking = 0 41 | projection = 0 42 | current = true 43 | fov = 65.0 44 | size = 1.0 45 | near = 0.1 46 | far = 100.0 47 | 48 | 49 | -------------------------------------------------------------------------------- /scripts/FPSCounter.gdns: -------------------------------------------------------------------------------- 1 | [gd_resource type="NativeScript" load_steps=2 format=2] 2 | 3 | [ext_resource path="res://nimlib.gdnlib" type="GDNativeLibrary" id=1] 4 | 5 | [resource] 6 | 7 | resource_name = "FPSCounter" 8 | library = ExtResource( 1 ) 9 | class_name = "FPSCounter" -------------------------------------------------------------------------------- /scripts/MainPanel.gdns: -------------------------------------------------------------------------------- 1 | [gd_resource type="NativeScript" load_steps=2 format=2] 2 | 3 | [ext_resource path="res://nimlib.gdnlib" type="GDNativeLibrary" id=1] 4 | 5 | [resource] 6 | 7 | resource_name = "MainPanel" 8 | library = ExtResource( 1 ) 9 | class_name = "MainPanel" -------------------------------------------------------------------------------- /src/config.nims: -------------------------------------------------------------------------------- 1 | import ospaths 2 | 3 | switch("nimcache", ".nimcache"/hostOS/hostCPU) 4 | 5 | when defined(macosx): 6 | when defined(ios): 7 | if hostCPU == "arm64": 8 | switch("passC", "-arch arm64") 9 | switch("passL", "-arch arm64") 10 | elif hostCPU == "arm": 11 | switch("passC", "-arch armv7") 12 | switch("passL", "-arch armv7") 13 | switch("passC", "-mios-version-min=9.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk") 14 | switch("passL", "-mios-version-min=9.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk") 15 | else: 16 | switch("passL", "-framework Cocoa") 17 | elif defined(android): 18 | let ndk = getEnv("ANDROID_NDK_ROOT") 19 | let toolchain = getEnv("ANDROID_TOOLCHAIN") 20 | 21 | if ndk.len == 0: 22 | raise newException(OSError, 23 | "ANDROID_NDK_ROOT environment variable is necessary for android build") 24 | if toolchain.len == 0: 25 | raise newException(OSError, 26 | "ANDROID_TOOLCHAIN environment variable is necessary for android build") 27 | 28 | const level = $16 # change this to the necessary API level 29 | const arch = "arm" 30 | let sysroot = "--sysroot=\"" & ndk & "/platforms/android-" & level & "/arch-" & arch & "/\"" 31 | switch("passL", sysroot) 32 | switch("passC", sysroot) 33 | 34 | switch("cc", "clang") 35 | switch("arm.linux.clang.path", toolchain / "bin") 36 | switch("arm.linux.clang.exe", arch & "-linux-androideabi-clang") 37 | switch("arm.linux.clang.compilerexe", arch & "-linux-androideabi-clang") 38 | switch("arm.linux.clang.linkerexe", arch & "-linux-androideabi-clang") 39 | elif defined(windows): 40 | assert(sizeof(int) == 8) 41 | switch("cc", "vcc") 42 | elif defined(linux): 43 | switch("passC", "-fPIC") 44 | else: 45 | raise newException(OSError, "Unsupported platform: " & hostOS) 46 | 47 | when not defined(release): 48 | switch("debugger", "native") 49 | -------------------------------------------------------------------------------- /src/fpscounter.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Xored Software, Inc. 2 | 3 | import strutils 4 | import godot 5 | import godotapi / [engine, label] 6 | 7 | gdobj FPSCounter of Label: 8 | var lastFPS: float32 9 | 10 | method ready*() = 11 | self.setProcess(true) 12 | 13 | method process*(delta: float64) = 14 | let fps = getFramesPerSecond() 15 | if int(fps * 10) != int(self.lastFPS * 10): 16 | self.lastFPS = fps 17 | self.text = "FPS: " & formatFloat(fps, ffDecimal, 1) 18 | -------------------------------------------------------------------------------- /src/mainpanel.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Xored Software, Inc. 2 | 3 | import godot 4 | import godotapi / [scene_tree, resource_loader, packed_scene, panel, 5 | global_constants, input_event_mouse_button] 6 | 7 | gdobj MainPanel of Panel: 8 | method ready*() = 9 | self.setProcessInput(true) 10 | 11 | method input*(event: InputEvent) = 12 | if event of InputEventMouseButton: 13 | let ev = event as InputEventMouseButton 14 | if ev.buttonIndex == BUTTON_LEFT: 15 | self.getTree().setInputAsHandled() 16 | let scene = load("res://scene.tscn") as PackedScene 17 | self.getTree().root.addChild(scene.instance()) 18 | self.queueFree() 19 | -------------------------------------------------------------------------------- /src/nim.cfg: -------------------------------------------------------------------------------- 1 | --path:"$projectdir" 2 | --app:lib 3 | -d:useRealtimeGc 4 | --noMain 5 | --warning[LockLevel]:off -------------------------------------------------------------------------------- /src/stub.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Xored Software, Inc. 2 | 3 | ## Import independent scene objects here 4 | ## (no need to import everything, just independent roots) 5 | 6 | when not defined(release): 7 | import segfaults # converts segfaults into NilAccessError 8 | 9 | import fpscounter 10 | import mainpanel 11 | -------------------------------------------------------------------------------- /src/stub.nimble: -------------------------------------------------------------------------------- 1 | version = "0.1.0" 2 | author = "Xored Software, Inc." 3 | description = "Godot-Nim Project Stub" 4 | license = "MIT" 5 | 6 | requires "godot >= 0.7.21 & < 0.8.0" --------------------------------------------------------------------------------