mirror of
https://github.com/godotengine/gdnative-demos.git
synced 2026-01-03 14:09:44 +03:00
Improve outdated README files and improve simple C++ demo
This commit is contained in:
@@ -1,44 +1,21 @@
|
||||
## C++
|
||||
# C++ demos
|
||||
|
||||
### Initial setup
|
||||
These demos show how to use the GDNative C++ bindings.
|
||||
|
||||
You need to clone the GDNative C++ bindings in the root of this project:
|
||||
Dependencies:
|
||||
* You need [godot-cpp](https://github.com/godotengine/godot-cpp),
|
||||
this is now a Git submodule of this repo.
|
||||
* `clang`, `gcc`, or any decent C++ compiler that's C++14 compatible.
|
||||
|
||||
## Compiling
|
||||
|
||||
For each of the C++ demos, you can use SCons to compile the library:
|
||||
|
||||
```
|
||||
git clone --recursive https://github.com/GodotNativeTools/godot-cpp
|
||||
scons platform=PLATFORM
|
||||
```
|
||||
|
||||
Where PLATFORM is: `windows`, `linux`, or `osx`.
|
||||
|
||||
### Updating the api.json
|
||||
Our api.json file contains meta data of all the classes that are part of the Godot core and are needed to generate the C++ binding classes for use in GDNative modules.
|
||||
|
||||
This file is supplied with our godot_headers repository for your convinience but if you are running a custom build of Godot and need access to classes that have recent changes a new api.json file must be generated. You do this by starting your Godot executable with the following parameters:
|
||||
|
||||
```
|
||||
$ godot --gdnative-generate-json-api api.json
|
||||
```
|
||||
|
||||
Now copy the api.json file into your folder structure so its easy to access. **Note** the remark below for the extra ```custom_api_file``` command line parameter needed to tell scons where to find your file.
|
||||
|
||||
### Compiling the cpp bindings library
|
||||
The final step is to compile our cpp bindings library:
|
||||
```
|
||||
$ cd godot-cpp
|
||||
$ scons platform=<your platform> generate_bindings=yes
|
||||
$ cd ..
|
||||
```
|
||||
|
||||
> Replace `<your platform>` with either `windows`, `linux` or `osx`.
|
||||
|
||||
> Include `use_llvm=yes` for using clang++
|
||||
|
||||
> Include `target=runtime` to build a runtime build (windows only at the moment)
|
||||
|
||||
> The resulting library will be created in `godot-cpp/bin/`, take note of its name as it will be different depending on platform.
|
||||
|
||||
> If you want to use an alternative api.json file add `use_custom_api_file=yes custom_api_file=../api.json`, be sure to specify the correct location of where you placed your file.
|
||||
|
||||
|
||||
### Compile the demos
|
||||
|
||||
A `Makefile` is provided in each demo to make the process more convenient.
|
||||
This creates the file `libsimple` in the respective
|
||||
subfolders in the `project/gdnative` directory.
|
||||
|
||||
Reference in New Issue
Block a user