From 6784d743f72f66e0e07343bdb326fa42c9f0f43c Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Wed, 27 Dec 2017 01:31:51 +0100 Subject: server platform now compiles and run on linux. Seems to also be able to do exports of some demos I tried. --- platform/server/SCsub | 2 + platform/server/detect.py | 4 +- platform/server/os_server.cpp | 167 +++++++++++++++++++++++++++++++----------- platform/server/os_server.h | 21 +++++- 4 files changed, 147 insertions(+), 47 deletions(-) (limited to 'platform') diff --git a/platform/server/SCsub b/platform/server/SCsub index 30d8cc806..0788ad75a 100644 --- a/platform/server/SCsub +++ b/platform/server/SCsub @@ -5,6 +5,8 @@ Import('env') common_server = [\ "os_server.cpp",\ + "#platform/x11/crash_handler_x11.cpp", + "#platform/x11/power_x11.cpp", ] prog = env.add_program('#bin/godot_server', ['godot_server.cpp'] + common_server) diff --git a/platform/server/detect.py b/platform/server/detect.py index bc615d3d0..c56625e83 100644 --- a/platform/server/detect.py +++ b/platform/server/detect.py @@ -12,9 +12,6 @@ def get_name(): def can_build(): - # Doesn't build against Godot 3.0 for now, disable to avoid confusing users - return False - if (os.name != "posix" or sys.platform == "darwin"): return False @@ -133,3 +130,4 @@ def configure(env): env.Append(CPPPATH=['#platform/server']) env.Append(CPPFLAGS=['-DSERVER_ENABLED', '-DUNIX_ENABLED']) env.Append(LIBS=['pthread']) + env.Append(LIBS=['dl']) diff --git a/platform/server/os_server.cpp b/platform/server/os_server.cpp index 370a34739..49ecc4389 100644 --- a/platform/server/os_server.cpp +++ b/platform/server/os_server.cpp @@ -27,11 +27,10 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ - -//#include "servers/visual/visual_server_raster.h" -//#include "servers/visual/rasterizer_dummy.h" #include "os_server.h" +#include "drivers/dummy/rasterizer_dummy.h" #include "print_string.h" +#include "servers/visual/visual_server_raster.h" #include #include @@ -48,65 +47,54 @@ const char *OS_Server::get_video_driver_name(int p_driver) const { return "Dummy"; } -Error OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { +int OS_Server::get_audio_driver_count() const { + return 0; +} - args = OS::get_singleton()->get_cmdline_args(); - current_videomode = p_desired; - main_loop = NULL; +const char *OS_Server::get_audio_driver_name(int p_driver) const { - //rasterizer = memnew( RasterizerDummy ); + return ""; +} - //visual_server = memnew( VisualServerRaster(rasterizer) ); +void OS_Server::initialize_core() { - AudioDriverManager::initialize(p_audio_driver); + crash_handler.initialize(); - sample_manager = memnew(SampleManagerMallocSW); - audio_server = memnew(AudioServerSW(sample_manager)); - audio_server->init(); - spatial_sound_server = memnew(SpatialSoundServerSW); - spatial_sound_server->init(); - spatial_sound_2d_server = memnew(SpatialSound2DServerSW); - spatial_sound_2d_server->init(); + OS_Unix::initialize_core(); +} - ERR_FAIL_COND_V(!visual_server, ERR_UNAVAILABLE); +void OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { + args = OS::get_singleton()->get_cmdline_args(); + current_videomode = p_desired; + main_loop = NULL; + + RasterizerDummy::make_current(); + + visual_server = memnew(VisualServerRaster); visual_server->init(); + AudioDriverManager::initialize(p_audio_driver); + input = memnew(InputDefault); - _ensure_user_data_dir(); + power_manager = memnew(PowerX11); - return OK; + _ensure_user_data_dir(); } - void OS_Server::finalize() { if (main_loop) memdelete(main_loop); main_loop = NULL; - spatial_sound_server->finish(); - memdelete(spatial_sound_server); - spatial_sound_2d_server->finish(); - memdelete(spatial_sound_2d_server); - - /* - if (debugger_connection_console) { - memdelete(debugger_connection_console); - } - */ - - memdelete(sample_manager); - - audio_server->finish(); - memdelete(audio_server); - visual_server->finish(); memdelete(visual_server); - //memdelete(rasterizer); memdelete(input); + memdelete(power_manager); + args.clear(); } @@ -183,9 +171,6 @@ void OS_Server::move_window_to_foreground() { void OS_Server::set_cursor_shape(CursorShape p_shape) { } -void OS_Server::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) { -} - OS::PowerState OS_Server::get_power_state() { return power_manager->get_power_state(); } @@ -198,6 +183,10 @@ int OS_Server::get_power_percent_left() { return power_manager->get_power_percent_left(); } +bool OS_Server::_check_internal_feature_support(const String &p_feature) { + return p_feature == "pc"; +} + void OS_Server::run() { force_quit = false; @@ -216,6 +205,102 @@ void OS_Server::run() { main_loop->finish(); } +String OS_Server::get_config_path() const { + + if (has_environment("XDG_CONFIG_HOME")) { + return get_environment("XDG_CONFIG_HOME"); + } else if (has_environment("HOME")) { + return get_environment("HOME").plus_file(".config"); + } else { + return "."; + } +} + +String OS_Server::get_data_path() const { + + if (has_environment("XDG_DATA_HOME")) { + return get_environment("XDG_DATA_HOME"); + } else if (has_environment("HOME")) { + return get_environment("HOME").plus_file(".local/share"); + } else { + return get_config_path(); + } +} + +String OS_Server::get_cache_path() const { + + if (has_environment("XDG_CACHE_HOME")) { + return get_environment("XDG_CACHE_HOME"); + } else if (has_environment("HOME")) { + return get_environment("HOME").plus_file(".cache"); + } else { + return get_config_path(); + } +} + +String OS_Server::get_system_dir(SystemDir p_dir) const { + + String xdgparam; + + switch (p_dir) { + case SYSTEM_DIR_DESKTOP: { + + xdgparam = "DESKTOP"; + } break; + case SYSTEM_DIR_DCIM: { + + xdgparam = "PICTURES"; + + } break; + case SYSTEM_DIR_DOCUMENTS: { + + xdgparam = "DOCUMENTS"; + + } break; + case SYSTEM_DIR_DOWNLOADS: { + + xdgparam = "DOWNLOAD"; + + } break; + case SYSTEM_DIR_MOVIES: { + + xdgparam = "VIDEOS"; + + } break; + case SYSTEM_DIR_MUSIC: { + + xdgparam = "MUSIC"; + + } break; + case SYSTEM_DIR_PICTURES: { + + xdgparam = "PICTURES"; + + } break; + case SYSTEM_DIR_RINGTONES: { + + xdgparam = "MUSIC"; + + } break; + } + + String pipe; + List arg; + arg.push_back(xdgparam); + Error err = const_cast(this)->execute("xdg-user-dir", arg, true, NULL, &pipe); + if (err != OK) + return "."; + return pipe.strip_edges(); +} + +void OS_Server::disable_crash_handler() { + crash_handler.disable(); +} + +bool OS_Server::is_disable_crash_handler() const { + return crash_handler.is_disabled(); +} + OS_Server::OS_Server() { //adriver here diff --git a/platform/server/os_server.h b/platform/server/os_server.h index 7abb4565d..8ab9e028b 100644 --- a/platform/server/os_server.h +++ b/platform/server/os_server.h @@ -27,10 +27,10 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ - #ifndef OS_SERVER_H #define OS_SERVER_H +#include "../x11/crash_handler_x11.h" #include "../x11/power_x11.h" #include "drivers/rtaudio/audio_driver_rtaudio.h" #include "drivers/unix/os_unix.h" @@ -63,11 +63,17 @@ class OS_Server : public OS_Unix { PowerX11 *power_manager; + CrashHandler crash_handler; + protected: virtual int get_video_driver_count() const; virtual const char *get_video_driver_name(int p_driver) const; - virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver); + virtual int get_audio_driver_count() const; + virtual const char *get_audio_driver_name(int p_driver) const; + + virtual void initialize_core(); + virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver); virtual void finalize(); virtual void set_main_loop(MainLoop *p_main_loop); @@ -76,7 +82,6 @@ public: virtual String get_name(); virtual void set_cursor_shape(CursorShape p_shape); - virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot); virtual void set_mouse_show(bool p_show); virtual void set_mouse_grab(bool p_grab); @@ -102,6 +107,16 @@ public: virtual OS::PowerState get_power_state(); virtual int get_power_seconds_left(); virtual int get_power_percent_left(); + virtual bool _check_internal_feature_support(const String &p_feature); + + virtual String get_config_path() const; + virtual String get_data_path() const; + virtual String get_cache_path() const; + + virtual String get_system_dir(SystemDir p_dir) const; + + void disable_crash_handler(); + bool is_disable_crash_handler() const; OS_Server(); }; -- cgit v1.2.3-70-g09d2 From 2de10aa4679a2a5612a7d7939dbd8e74a4caa886 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Tue, 9 Jan 2018 11:08:10 +0100 Subject: Fixes to OS_Server and DummyRasterizer to match new signatures --- drivers/dummy/rasterizer_dummy.h | 1 + platform/server/detect.py | 1 + platform/server/os_server.cpp | 11 ++++++++++- platform/server/os_server.h | 3 ++- 4 files changed, 14 insertions(+), 2 deletions(-) (limited to 'platform') diff --git a/drivers/dummy/rasterizer_dummy.h b/drivers/dummy/rasterizer_dummy.h index e2f256215..6d4d87b2f 100644 --- a/drivers/dummy/rasterizer_dummy.h +++ b/drivers/dummy/rasterizer_dummy.h @@ -493,6 +493,7 @@ public: void particles_set_emission_transform(RID p_particles, const Transform &p_transform) {} + bool particles_get_emitting(RID p_particles) { return false; } int particles_get_draw_passes(RID p_particles) const { return 0; } RID particles_get_draw_pass_mesh(RID p_particles, int p_pass) const { return RID(); } diff --git a/platform/server/detect.py b/platform/server/detect.py index c56625e83..fd4b6eae1 100644 --- a/platform/server/detect.py +++ b/platform/server/detect.py @@ -28,6 +28,7 @@ def get_opts(): def get_flags(): return [ + ("module_mobile_vr_enabled", False), ] diff --git a/platform/server/os_server.cpp b/platform/server/os_server.cpp index 49ecc4389..1340303fe 100644 --- a/platform/server/os_server.cpp +++ b/platform/server/os_server.cpp @@ -63,7 +63,7 @@ void OS_Server::initialize_core() { OS_Unix::initialize_core(); } -void OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { +Error OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { args = OS::get_singleton()->get_cmdline_args(); current_videomode = p_desired; @@ -81,7 +81,10 @@ void OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int p power_manager = memnew(PowerX11); _ensure_user_data_dir(); + + return OK; } + void OS_Server::finalize() { if (main_loop) @@ -100,10 +103,12 @@ void OS_Server::finalize() { void OS_Server::set_mouse_show(bool p_show) { } + void OS_Server::set_mouse_grab(bool p_grab) { grab = p_grab; } + bool OS_Server::is_mouse_grab_enabled() const { return grab; @@ -124,6 +129,7 @@ void OS_Server::set_window_title(const String &p_title) { void OS_Server::set_video_mode(const VideoMode &p_video_mode, int p_screen) { } + OS::VideoMode OS_Server::get_video_mode(int p_screen) const { return current_videomode; @@ -171,6 +177,9 @@ void OS_Server::move_window_to_foreground() { void OS_Server::set_cursor_shape(CursorShape p_shape) { } +void OS_Server::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) { +} + OS::PowerState OS_Server::get_power_state() { return power_manager->get_power_state(); } diff --git a/platform/server/os_server.h b/platform/server/os_server.h index 8ab9e028b..2cc6f0c47 100644 --- a/platform/server/os_server.h +++ b/platform/server/os_server.h @@ -73,7 +73,7 @@ protected: virtual const char *get_audio_driver_name(int p_driver) const; virtual void initialize_core(); - virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver); + virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver); virtual void finalize(); virtual void set_main_loop(MainLoop *p_main_loop); @@ -82,6 +82,7 @@ public: virtual String get_name(); virtual void set_cursor_shape(CursorShape p_shape); + virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot); virtual void set_mouse_show(bool p_show); virtual void set_mouse_grab(bool p_grab); -- cgit v1.2.3-70-g09d2 From 4e1923a931a3d849563bbe5d6fe4a52277daf090 Mon Sep 17 00:00:00 2001 From: K. S. Ernest (iFire) Lee Date: Tue, 13 Feb 2018 02:36:03 +0100 Subject: Add dummy audio driver, fix dummy rasterizer --- drivers/dummy/SCsub | 2 +- drivers/dummy/audio_driver_dummy.h | 58 ++++++++++++++++++++++++++++++++++++++ drivers/dummy/rasterizer_dummy.h | 26 ++++++++++++++--- platform/server/os_server.cpp | 5 ++-- 4 files changed, 84 insertions(+), 7 deletions(-) create mode 100644 drivers/dummy/audio_driver_dummy.h (limited to 'platform') diff --git a/drivers/dummy/SCsub b/drivers/dummy/SCsub index e170b8e38..28b315ae6 100644 --- a/drivers/dummy/SCsub +++ b/drivers/dummy/SCsub @@ -2,4 +2,4 @@ Import('env') -env.add_source_files(env.drivers_sources,"*.cpp") +env.add_source_files(env.drivers_sources, "*.cpp") diff --git a/drivers/dummy/audio_driver_dummy.h b/drivers/dummy/audio_driver_dummy.h new file mode 100644 index 000000000..c3d8e1076 --- /dev/null +++ b/drivers/dummy/audio_driver_dummy.h @@ -0,0 +1,58 @@ +/*************************************************************************/ +/* audio_driver_dummy.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef AUDIO_DRIVER_DUMMY_H +#define AUDIO_DRIVER_DUMMY_H + +#include "core/os/mutex.h" +#include "core/os/thread.h" +#include "servers/audio_server.h" + +class AudioDriverDummy : public AudioDriver { +public: + const char *get_name() const { + return "Dummy"; + }; + + virtual Error init() { return OK; } + virtual void start(){}; + virtual int get_mix_rate() const {}; + virtual SpeakerMode get_speaker_mode() const {}; + virtual void lock(){}; + virtual void unlock(){}; + virtual void finish(){}; + + virtual float get_latency(){}; + + AudioDriverDummy(){}; + ~AudioDriverDummy(){}; +}; + +#endif // AUDIO_DRIVER_DUMMY_H diff --git a/drivers/dummy/rasterizer_dummy.h b/drivers/dummy/rasterizer_dummy.h index 6d4d87b2f..1e9c79715 100644 --- a/drivers/dummy/rasterizer_dummy.h +++ b/drivers/dummy/rasterizer_dummy.h @@ -1,12 +1,12 @@ /*************************************************************************/ -/* rasterizer.h */ +/* rasterizer_dummy.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -31,6 +31,7 @@ #define RASTERIZER_DUMMY_H #include "camera_matrix.h" +#include "scene/resources/mesh.h" #include "servers/visual/rasterizer.h" #include "servers/visual_server.h" @@ -244,8 +245,12 @@ public: RID mesh_create() { return RID(); } + void mesh_add_surface_from_arrays(RID p_mesh, VS::PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), uint32_t p_compress_format = Mesh::ARRAY_COMPRESS_DEFAULT) {} void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector &p_array, int p_vertex_count, const PoolVector &p_index_array, int p_index_count, const AABB &p_aabb, const Vector > &p_blend_shapes = Vector >(), const Vector &p_bone_aabbs = Vector()) {} + void mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry::MeshData &p_mesh_data) {} + void mesh_add_surface_from_planes(RID p_mesh, const PoolVector &p_planes) {} + void mesh_set_blend_shape_count(RID p_mesh, int p_amount) {} int mesh_get_blend_shape_count(RID p_mesh) const { return 0; } @@ -446,6 +451,16 @@ public: void gi_probe_dynamic_data_update(RID p_gi_probe_data, int p_depth_slice, int p_slice_count, int p_mipmap, const void *p_data) {} /* LIGHTMAP CAPTURE */ + struct LightmapCaptureOctree { + + enum { + CHILD_EMPTY = 0xFFFFFFFF + }; + + uint16_t light[6][3]; //anisotropic light + float alpha; + uint32_t children[8]; + }; RID lightmap_capture_create() { return RID(); } void lightmap_capture_set_bounds(RID p_capture, const AABB &p_bounds) {} @@ -461,7 +476,10 @@ public: int lightmap_capture_get_octree_cell_subdiv(RID p_capture) const { return 0; } void lightmap_capture_set_energy(RID p_capture, float p_energy) {} float lightmap_capture_get_energy(RID p_capture) const { return 0.0; } - const PoolVector *lightmap_capture_get_octree_ptr(RID p_capture) const {} + const PoolVector *lightmap_capture_get_octree_ptr(RID p_capture) const { + PoolVector p; + return &p; + } /* PARTICLES */ diff --git a/platform/server/os_server.cpp b/platform/server/os_server.cpp index 1340303fe..a8be4fbc3 100644 --- a/platform/server/os_server.cpp +++ b/platform/server/os_server.cpp @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "os_server.h" +#include "drivers/dummy/audio_driver_dummy.h" #include "drivers/dummy/rasterizer_dummy.h" #include "print_string.h" #include "servers/visual/visual_server_raster.h" @@ -48,12 +49,12 @@ const char *OS_Server::get_video_driver_name(int p_driver) const { } int OS_Server::get_audio_driver_count() const { - return 0; + return 1; } const char *OS_Server::get_audio_driver_name(int p_driver) const { - return ""; + return "Dummy"; } void OS_Server::initialize_core() { -- cgit v1.2.3-70-g09d2