mirror of
https://github.com/godotengine/gdnative-demos.git
synced 2026-01-04 22:10:30 +03:00
Update README files for C demos
As of this commit, a lot of the content in these files is incorrect.
This commit is contained in:
@@ -1,37 +1,67 @@
|
||||
# GLFW Example using C
|
||||
# GLFW example using C
|
||||
|
||||
This is a small example using C to create a GDNative script that
|
||||
exposes a smaaaaall part of the GLFW API.
|
||||
|
||||
## Compiling
|
||||
|
||||
Dependencies:
|
||||
* You need to have the [Godot headers](https://github.com/GodotNativeTools/godot_headers) saved somewhere on your system
|
||||
* You need to have GLFW and its headers installed
|
||||
* clang or any decent C compiler that's C11 or C99 compatible
|
||||
* You need [Godot headers](https://github.com/godotengine/godot_headers),
|
||||
this is now a submodule of this repo.
|
||||
* `clang`, `gcc`, or any decent C compiler that's C11 or C99 compatible.
|
||||
* You need to have GLFW and its headers installed.
|
||||
|
||||
To compile the library, do
|
||||
## Compile with SCons (cross platform)
|
||||
You can use SCons to compile the library if you have it installed:
|
||||
|
||||
cd src
|
||||
clang -std=c11 -fPIC -c -I/PATH/TO/GODOT/HEADERS init.c -o init.os
|
||||
clang -shared -lglfw init.os -o libglfw.so
|
||||
```
|
||||
scons platform=PLATFORM
|
||||
```
|
||||
|
||||
#or use gcc
|
||||
gcc -std=c11 -fPIC -c -I/PATH/TO/GODOT/HEADERS init.c -o init.os
|
||||
gcc -shared init.os -o libglfw.so -lglfw
|
||||
Where platform is: windows, linuxbsd, or macos
|
||||
|
||||
This creates the file `libglfw.so` in your `src` directory.
|
||||
For windows you need to find out what compiler flags need to be used, I don't know which ones. (If you do, feel free to fork and update this project and README)
|
||||
|
||||
On mac:
|
||||
## Manually compiling
|
||||
|
||||
cd src
|
||||
clang -std=c11 -fPIC -c -I/PATH/TO/GODOT/HEADERS -I/PATH/TO/GLFW/HEADERS init.c -o init.os -arch i386 -arch x86_64
|
||||
clang -dynamiclib libglfw.dylib init.os -o libglfw_godot.dylib -arch i386 -arch x86_64 -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -Wl,-undefined,dynamic_lookup
|
||||
### Linux
|
||||
To compile the library on Linux, do
|
||||
|
||||
```
|
||||
cd src
|
||||
clang -std=c11 -fPIC -c -I../godot_headers init.c -o init.os
|
||||
clang -shared -lglfw init.os -o ../project/gdnative/linuxbsd/libglfw.so
|
||||
|
||||
# Or use GCC.
|
||||
gcc -std=c11 -fPIC -c -I../godot_headers init.c -o init.os
|
||||
gcc -shared init.os -o ../project/gdnative/linuxbsd/libglfw.so -lglfw
|
||||
```
|
||||
|
||||
This creates the file `libsimple.so` in the `project/gdnative/linuxbsd` directory.
|
||||
|
||||
|
||||
### macOS
|
||||
On macOS:
|
||||
|
||||
```
|
||||
clang -std=c11 -fPIC -c -I../godot_headers -I/PATH/TO/GLFW/HEADERS init.c -o init.os -arch x86_64
|
||||
clang -dynamiclib libglfw.dylib init.os -o project/gdnative/macos/libglfw_godot.dylib -arch x86_64 -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -Wl,-undefined,dynamic_lookup
|
||||
```
|
||||
|
||||
This creates the file `libsimple.dylib` in the `project/gdnative/macos` directory.
|
||||
|
||||
This creates the file 'libglfw_godot.dylib' as a universal binary (or alternatively remove one of the -arch options from both commands if you want to just compile for one architecture).
|
||||
If you want to statically link GLFW in just replace libglfw.dylib by libglfw.a, make sure to copy these files from GLFW.
|
||||
|
||||
|
||||
### Windows
|
||||
On Windows: **TODO: Missing GLFW-specific instructions**
|
||||
|
||||
```
|
||||
cd src
|
||||
cl /Fosimple.obj /c simple.c /nologo -EHsc -DNDEBUG /MD /I. /I../godot_headers
|
||||
link /nologo /dll /out:..\project\gdnative\windows\libsimple.dll /implib:..\project\gdnative\windows\libsimple.lib simple.obj
|
||||
```
|
||||
|
||||
This creates the file `libsimple.dll` in the `project/gdnative/windows` directory.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
Create a window object using `load("res://GLFW.gdn").new()`
|
||||
|
||||
@@ -1,49 +1,53 @@
|
||||
# Simple example using C
|
||||
|
||||
This is a small example using C to create a GDNative script that just showcases some very simple bare bones calls
|
||||
|
||||
## Compiling
|
||||
# Instance binding demo using C
|
||||
|
||||
Dependencies:
|
||||
* You need to have the [Godot headers](https://github.com/GodotNativeTools/godot_headers) saved somewhere on your system
|
||||
* clang or any decent C compiler that's C11 or C99 compatible
|
||||
* You need [Godot headers](https://github.com/godotengine/godot_headers),
|
||||
this is now a submodule of this repo.
|
||||
* `clang`, `gcc`, or any decent C compiler that's C11 or C99 compatible.
|
||||
|
||||
### Scons (cross platform)
|
||||
You can use scons to compile the library if you have it installed:
|
||||
## Compile with SCons (cross platform)
|
||||
You can use SCons to compile the library if you have it installed:
|
||||
|
||||
scons platform=PLATFORM
|
||||
```
|
||||
scons platform=PLATFORM
|
||||
```
|
||||
|
||||
Where platform is: x11, osx or windows
|
||||
Optionally you can specify:
|
||||
Where platform is: windows, linuxbsd, or macos
|
||||
|
||||
headers=/PATH/TO/GODOT/HEADERS
|
||||
|
||||
## Manually compiling
|
||||
|
||||
### Linux
|
||||
To compile the library on Linux, do
|
||||
|
||||
cd src
|
||||
clang -std=c11 -fPIC -c -I/PATH/TO/GODOT/HEADERS simple.c -o simple.os
|
||||
clang -shared simple.os -o ../bin/libsimple.so
|
||||
```
|
||||
cd src
|
||||
clang -std=c11 -fPIC -c -I../godot_headers instance_binding.c -o instance_binding.os
|
||||
clang -shared instance_binding.os -o ../project/gdnative/linuxbsd/libinstance_binding.so
|
||||
```
|
||||
|
||||
This creates the file `libsimple.so` in your `src` directory.
|
||||
For windows you need to find out what compiler flags need to be used, I don't know which ones. (If you do, feel free to fork and update this project and README)
|
||||
This creates the file `libinstance_binding.so` in the `project/gdnative/linuxbsd` directory.
|
||||
|
||||
### Mac OS X
|
||||
On Mac OS X:
|
||||
|
||||
cd src
|
||||
clang -std=c11 -fPIC -c -I/PATH/TO/GODOT/HEADERS simple.c -o simple.os -arch i386 -arch x86_64
|
||||
clang -dynamiclib simple.os -o ../bin/libsimple.dylib -arch i386 -arch x86_64
|
||||
### macOS
|
||||
On macOS:
|
||||
|
||||
```
|
||||
cd src
|
||||
clang -std=c11 -fPIC -c -I../godot_headers instance_binding.c -o instance_binding.os -arch x86_64
|
||||
clang -dynamiclib instance_binding.os -o ../project/gdnative/macos/libinstance_binding.dylib -arch x86_64
|
||||
```
|
||||
|
||||
This creates the file `libinstance_binding.dylib` in the `project/gdnative/macos` directory.
|
||||
|
||||
This creates the file 'libsimple.dylib' as a universal binary (or alternatively remove one of the -arch options from both commands if you want to just compile for one architecture).
|
||||
|
||||
### Windows
|
||||
To be added
|
||||
On Windows:
|
||||
|
||||
## Usage
|
||||
|
||||
Create a new object using `load("res://SIMPLE.gdns").new()`
|
||||
|
||||
This object has following methods you can use:
|
||||
* `get_data()`
|
||||
```
|
||||
cd src
|
||||
cl /Foinstance_binding.obj /c instance_binding.c /nologo -EHsc -DNDEBUG /MD /I. /I../godot_headers
|
||||
link /nologo /dll /out:..\project\gdnative\windows\libinstance_binding.dll /implib:..\project\gdnative\windows\libinstance_binding.lib instance_binding.obj
|
||||
```
|
||||
|
||||
This creates the file `libinstance_binding.dll` in the `project/gdnative/windows` directory.
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
# Simple example using C
|
||||
|
||||
This is a small example using C to create a GDNative script that just showcases some very simple bare bones calls
|
||||
|
||||
## Compiling
|
||||
This is a small example using C to create a GDNative script
|
||||
that just showcases some very simple bare bones calls.
|
||||
|
||||
Dependencies:
|
||||
* You need [Godot headers](https://github.com/godotengine/godot_headers),
|
||||
this is now a submodule of this repo.
|
||||
* `clang`, `gcc`, or any decent C compiler that's C11 or C99 compatible.
|
||||
|
||||
* You need [Godot headers](https://github.com/GodotNativeTools/godot_headers), this is now a submodule of this repo
|
||||
* clang or any decent C compiler that's C11 or C99 compatible
|
||||
|
||||
### Scons (cross platform)
|
||||
You can use scons to compile the library if you have it installed:
|
||||
## Compile with SCons (cross platform)
|
||||
You can use SCons to compile the library if you have it installed:
|
||||
|
||||
```
|
||||
scons platform=PLATFORM
|
||||
@@ -18,6 +17,9 @@ scons platform=PLATFORM
|
||||
|
||||
Where platform is: windows, linuxbsd, or macos
|
||||
|
||||
|
||||
## Manually compiling
|
||||
|
||||
### Linux
|
||||
To compile the library on Linux, do
|
||||
|
||||
@@ -27,19 +29,20 @@ clang -std=c11 -fPIC -c -I../godot_headers simple.c -o simple.os
|
||||
clang -shared simple.os -o ../project/gdnative/linuxbsd/libsimple.so
|
||||
```
|
||||
|
||||
This creates the file `libsimple.so` in your `project/gdnative/linuxbsd` directory.
|
||||
For windows you need to find out what compiler flags need to be used, I don't know which ones. (If you do, feel free to fork and update this project and README)
|
||||
This creates the file `libsimple.so` in the `project/gdnative/linuxbsd` directory.
|
||||
|
||||
### Mac OS X
|
||||
On Mac OS X:
|
||||
|
||||
### macOS
|
||||
On macOS:
|
||||
|
||||
```
|
||||
cd src
|
||||
clang -std=c11 -fPIC -c -I../godot_headers simple.c -o simple.os -arch i386 -arch x86_64
|
||||
clang -dynamiclib simple.os -o ../project/gdnative/macos/libsimple.dylib -arch i386 -arch x86_64
|
||||
clang -std=c11 -fPIC -c -I../godot_headers simple.c -o simple.os -arch x86_64
|
||||
clang -dynamiclib simple.os -o ../project/gdnative/macos/libsimple.dylib -arch x86_64
|
||||
```
|
||||
|
||||
This creates the file 'libsimple.dylib' as a universal binary (or alternatively remove one of the -arch options from both commands if you want to just compile for one architecture).
|
||||
This creates the file `libsimple.dylib` in the `project/gdnative/macos` directory.
|
||||
|
||||
|
||||
### Windows
|
||||
On Windows:
|
||||
@@ -50,13 +53,12 @@ cl /Fosimple.obj /c simple.c /nologo -EHsc -DNDEBUG /MD /I. /I../godot_headers
|
||||
link /nologo /dll /out:..\project\gdnative\windows\libsimple.dll /implib:..\project\gdnative\windows\libsimple.lib simple.obj
|
||||
```
|
||||
|
||||
This creates the file `libsimple.dll` in your `project/gdnative/windows` directory.
|
||||
This creates the file `libsimple.dll` in the `project/gdnative/windows` directory.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
Create a new object using `load("res://SIMPLE.gdns").new()`
|
||||
Create a new object using `load("res://simple.gdns").new()`
|
||||
|
||||
This object has following methods you can use:
|
||||
* `get_data()`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user