Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
karroffel committed Apr 1, 2018
1 parent b707692 commit 0dce8be
Show file tree
Hide file tree
Showing 11 changed files with 629 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ members = [
"geom",
"test",
"examples/hello_world",
"examples/misc_mesh_playground"
"examples/misc_mesh_playground",
"examples/low_level_registering",
]
10 changes: 10 additions & 0 deletions examples/low_level_registering/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "low_level_registering"
version = "0.1.0"
authors = ["karroffel <[email protected]>"]

[lib]
crate-type = ["cdylib"]

[dependencies]
gdnative = { path = "../../gdnative" }
28 changes: 28 additions & 0 deletions examples/low_level_registering/Main.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[gd_scene load_steps=4 format=2]

[ext_resource path="res://low_level_registering_library.gdnlib" type="GDNativeLibrary" id=1]

[sub_resource type="NativeScript" id=1]

resource_name = "Test"
class_name = "Test"
library = ExtResource( 1 )

[sub_resource type="GDScript" id=2]

script/source = "extends Node

func _ready():
yield(get_tree().create_timer(1.0), \"timeout\")
$\"..\".queue_free()
"
[node name="Node" type="Node" index="0"]
script = SubResource( 1 )
[node name="Node" type="Node" parent="." index="0"]
script = SubResource( 2 )
101 changes: 101 additions & 0 deletions examples/low_level_registering/default_env.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
[gd_resource type="Environment" load_steps=2 format=2]

[sub_resource type="ProceduralSky" id=1]

radiance_size = 4
sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 )
sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 )
sky_curve = 0.25
sky_energy = 1.0
ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 )
ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 )
ground_curve = 0.01
ground_energy = 1.0
sun_color = Color( 1, 1, 1, 1 )
sun_latitude = 35.0
sun_longitude = 0.0
sun_angle_min = 1.0
sun_angle_max = 100.0
sun_curve = 0.05
sun_energy = 16.0
texture_size = 2

[resource]

background_mode = 2
background_sky = SubResource( 1 )
background_sky_custom_fov = 0.0
background_color = Color( 0, 0, 0, 1 )
background_energy = 1.0
background_canvas_max_layer = 0
ambient_light_color = Color( 0, 0, 0, 1 )
ambient_light_energy = 1.0
ambient_light_sky_contribution = 1.0
fog_enabled = false
fog_color = Color( 0.5, 0.6, 0.7, 1 )
fog_sun_color = Color( 1, 0.9, 0.7, 1 )
fog_sun_amount = 0.0
fog_depth_enabled = true
fog_depth_begin = 10.0
fog_depth_curve = 1.0
fog_transmit_enabled = false
fog_transmit_curve = 1.0
fog_height_enabled = false
fog_height_min = 0.0
fog_height_max = 100.0
fog_height_curve = 1.0
tonemap_mode = 0
tonemap_exposure = 1.0
tonemap_white = 1.0
auto_exposure_enabled = false
auto_exposure_scale = 0.4
auto_exposure_min_luma = 0.05
auto_exposure_max_luma = 8.0
auto_exposure_speed = 0.5
ss_reflections_enabled = false
ss_reflections_max_steps = 64
ss_reflections_fade_in = 0.15
ss_reflections_fade_out = 2.0
ss_reflections_depth_tolerance = 0.2
ss_reflections_roughness = true
ssao_enabled = false
ssao_radius = 1.0
ssao_intensity = 1.0
ssao_radius2 = 0.0
ssao_intensity2 = 1.0
ssao_bias = 0.01
ssao_light_affect = 0.0
ssao_color = Color( 0, 0, 0, 1 )
ssao_quality = 0
ssao_blur = 3
ssao_edge_sharpness = 4.0
dof_blur_far_enabled = false
dof_blur_far_distance = 10.0
dof_blur_far_transition = 5.0
dof_blur_far_amount = 0.1
dof_blur_far_quality = 1
dof_blur_near_enabled = false
dof_blur_near_distance = 2.0
dof_blur_near_transition = 1.0
dof_blur_near_amount = 0.1
dof_blur_near_quality = 1
glow_enabled = false
glow_levels/1 = false
glow_levels/2 = false
glow_levels/3 = true
glow_levels/4 = false
glow_levels/5 = true
glow_levels/6 = false
glow_levels/7 = false
glow_intensity = 0.8
glow_strength = 1.0
glow_bloom = 0.0
glow_blend_mode = 2
glow_hdr_threshold = 1.0
glow_hdr_scale = 2.0
glow_bicubic_upscale = false
adjustment_enabled = false
adjustment_brightness = 1.0
adjustment_contrast = 1.0
adjustment_saturation = 1.0

Binary file added examples/low_level_registering/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions examples/low_level_registering/icon.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"

[deps]

source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[entry]

X11.64="../../target/debug/liblow_level_registering.so"

[dependencies]

X11.64=[ ]

[general]

singleton=false
load_once=true
symbol_prefix="godot_rust_"
reloadable=true
19 changes: 19 additions & 0 deletions examples/low_level_registering/project.godot
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters

config_version=3

[application]

config/name="Godot Rust - Low Level Registering"
run/main_scene="res://Main.tscn"
config/icon="res://icon.png"

[rendering]

environment/default_environment="res://default_env.tres"
78 changes: 78 additions & 0 deletions examples/low_level_registering/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#[macro_use]
extern crate gdnative as godot;

use godot::*;

struct MyClass {
class_info: GodotClassInfo,

elapsed_time: f64,
}

impl MyClass {
fn new(info: GodotClassInfo) -> Self {
MyClass {
class_info: info,
elapsed_time: 0.0,
}
}

fn _ready(&mut self) {
godot_print!("Hello World!");
}

fn _process(&mut self, delta: f64) {
self.elapsed_time += delta;
}

fn _exit_tree(&mut self) {
godot_print!("MyClass node was running for {} seconds",
self.elapsed_time);
}
}

godot_gdnative_init!(godot_rust_gdnative_init);

godot_gdnative_terminate!(godot_rust_gdnative_terminate);

godot_nativescript_init! {
godot_rust_nativescript_init,
|handle| {

let constructor = godot_create_constructor!(MyClass, MyClass::new);
let destructor = godot_create_destructor!(MyClass);

let ready_method = godot_create_method!(MyClass,
fn _ready(&mut self) -> ());

let ready_method = GodotScriptMethod {
name: "_ready",
method_ptr: Some(ready_method),
attributes: GodotScriptMethodAttributes {
rpc_mode: GodotRpcMode::Disabled
},
method_data: std::ptr::null_mut(),
free_func: None
};

let process_method = godot_create_method!(MyClass,
fn _process(&mut self, delta: f64) -> ());

let exit_tree_method = godot_create_method!(MyClass,
fn _exit_tree(&mut self) -> ());

let builder = GodotScriptClassBuilder::new();
builder
.set_class_name("Test")
.set_base_class_name("Node")
.set_constructor(Some(constructor))
.set_destructor(Some(destructor))

.add_method_advanced(ready_method)

.add_method("_process", process_method)
.add_method("_exit_tree", exit_tree_method)

.build(handle);
}
}
Loading

0 comments on commit 0dce8be

Please sign in to comment.