Skip to content

Commit 46b8e01

Browse files
first commit
0 parents  commit 46b8e01

17 files changed

+248
-0
lines changed

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Godot files
2+
/.import/
3+
export_presets.cfg
4+
/src/godot_headers
5+
/src/godot-cpp
6+
7+
# C# shit
8+
.mono/
9+
10+
# cmake build folder
11+
/build/
12+
13+
# scons build stuff
14+
*.os
15+
.sconsign.dblite

CMakeLists.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
cmake_minimum_required(VERSION 2.8.11)
2+
project(AnimationTest)
3+
4+
set(CMAKE_CXX_STANDARD 11)
5+
6+
# # CMake to help local projects find the build dir
7+
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../build/lib")
8+
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../build/lib")
9+
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../build")
10+
# set(HEADER_COPY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../build/include")
11+
#
12+
# # Copy header files to the output directory so they can be used
13+
# # by other projects in development.
14+
# file(
15+
# COPY ${CMAKE_CURRENT_SOURCE_DIR}/revolve
16+
# DESTINATION ${HEADER_COPY_DIR}
17+
# FILES_MATCHING PATTERN "*.h"
18+
# )
19+
20+
include_directories(
21+
${CMAKE_CURRENT_SOURCE_DIR}/src/godot_headers
22+
${CMAKE_CURRENT_SOURCE_DIR}/src/godot-cpp/include/
23+
${CMAKE_CURRENT_SOURCE_DIR}/src/godot-cpp/include/core
24+
)
25+
26+
set(ANIMATION_TEST_SRC
27+
src/gdexample.cpp
28+
src/gdlibrary.cpp
29+
)
30+
31+
add_library(animationtest SHARED ${ANIMATION_TEST_SRC})
32+
33+
# install stuff
34+
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR})
35+
36+
install(
37+
TARGETS animationtest
38+
DESTINATION bin
39+
)

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# AnimationTest
2+
3+
Animation Test project with GDNative C++
4+
5+
# Build instructions
6+
How to build your project. You don't have to reload the editor between builds.
7+
8+
First you need to download and build a couple of extra dependencies:
9+
10+
## Godot Headers
11+
download godot headers in `src/godot_headers`
12+
from `https://github.com/GodotNativeTools/godot_headers`
13+
14+
## Godot C++
15+
download godot-cpp in `src/godot-cpp`
16+
from `https://github.com/GodotNativeTools/godot-cpp`
17+
18+
Compile godot-cpp:
19+
```bash
20+
$ cd src/godot-cpp
21+
$ godot --gdnative-generate-json-api godot_api.json
22+
$ scons platform=windows/linux/osx headers_dir=../godot_headers generate_bindings=yes target=release
23+
```
24+
25+
## CMake
26+
```bash
27+
$ mkdir build && cd build
28+
$ cmake ..
29+
$ make
30+
$ make install
31+
```
32+
33+
# Run
34+
Open the project and run the example. A GDSCript loads the _simple_ example library and connects a _Button_ with the `get_data` function.

bin/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.so
2+
*.dll
3+
*.dylib

bin/gdexample.gdnlib

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[general]
2+
3+
singleton=false
4+
load_once=true
5+
symbol_prefix="godot_"
6+
reloadable=true
7+
8+
[entry]
9+
10+
OSX.64="res://bin/osx/libgdexample.so"
11+
Windows.64="res://bin/win64/libgdexample.so"
12+
X11.64="res://demo/bin/x11/libgdexample.so"
13+
14+
[dependencies]
15+
16+
OSX.64=[ ]
17+
Windows.64=[ ]
18+
X11.64=[ ]

bin/gdexample.gdns

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[gd_resource type="NativeScript" load_steps=2 format=2]
2+
3+
[ext_resource path="res://demo/bin/gdexample.gdnlib" type="GDNativeLibrary" id=1]
4+
5+
[resource]
6+
7+
class_name = "GDExample"
8+
library = ExtResource( 1 )
9+

default_env.tres

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[gd_resource type="Environment" load_steps=2 format=2]
2+
[sub_resource type="ProceduralSky" id=1]
3+
[resource]
4+
background_mode = 2
5+
background_sky = SubResource( 1 )

icon.png

3.42 KB
Loading

icon.png.import

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
11+
12+
[params]
13+
14+
compress/mode=0
15+
compress/lossy_quality=0.7
16+
compress/hdr_mode=0
17+
compress/normal_map=0
18+
flags/repeat=0
19+
flags/filter=true
20+
flags/mipmaps=false
21+
flags/anisotropic=false
22+
flags/srgb=2
23+
process/fix_alpha_border=true
24+
process/premult_alpha=false
25+
process/HDR_as_SRGB=false
26+
stream=false
27+
size_limit=0
28+
detect_3d=true
29+
svg/scale=1.0

project.godot

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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="AnimationTest"
14+
config/icon="res://icon.png"
15+
16+
[rendering]
17+
18+
environment/default_environment="res://default_env.tres"

src/.gdignore

Whitespace-only changes.

src/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.o
2+
*.os

src/gdexample.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include "gdexample.h"
2+
#include <iostream>
3+
4+
using namespace godot;
5+
6+
void GDExample::_register_methods()
7+
{
8+
register_method((char *)"_process", &GDExample::_process);
9+
}
10+
11+
GDExample::GDExample()
12+
: time_passed(0)
13+
{
14+
std::cout << "GDExample init" << std::endl;
15+
}
16+
17+
GDExample::~GDExample()
18+
{}
19+
20+
void GDExample::_process(float delta)
21+
{
22+
time_passed += delta;
23+
24+
Vector2 new_position = Vector2(
25+
10.0 + (10.0 * sin(time_passed * 2.0)),
26+
10.0 + (10.0 * cos(time_passed * 1.5))
27+
);
28+
29+
owner->set_position(new_position);
30+
}

src/gdexample.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#ifndef GDEXAMPLE_H
2+
#define GDEXAMPLE_H
3+
4+
#include <Godot.hpp>
5+
#include <Sprite.hpp>
6+
7+
namespace godot {
8+
9+
class GDExample: public godot::GodotScript<Sprite>
10+
{
11+
GODOT_CLASS(GDExample)
12+
13+
private:
14+
float time_passed;
15+
16+
public:
17+
static void _register_methods();
18+
19+
GDExample();
20+
~GDExample();
21+
22+
void _process(float delta);
23+
};
24+
25+
}
26+
27+
#endif // GDEXAMPLE_H

src/gdlibrary.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "gdexample.h"
2+
3+
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o)
4+
{
5+
godot::Godot::gdnative_init(o);
6+
}
7+
8+
extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o)
9+
{
10+
godot::Godot::gdnative_terminate(o);
11+
}
12+
13+
extern "C" void GDN_EXPORT godot_nativescript_init(void *handle)
14+
{
15+
godot::Godot::nativescript_init(handle);
16+
godot::register_class<godot::GDExample>();
17+
}

src/godot-cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/home/matteo/projects/godot/godot-cpp/

src/godot_headers

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/home/matteo/projects/godot/godot_headers/

0 commit comments

Comments
 (0)