mirror of
https://github.com/godotengine/godot.git
synced 2024-11-10 14:12:51 +00:00
server platform now compiles and run on linux.
Seems to also be able to do exports of some demos I tried.
(cherry picked from commit 6784d743f7
)
This commit is contained in:
parent
fb4a784319
commit
149ffcb1a4
@ -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)
|
||||
|
@ -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
|
||||
|
||||
@ -136,3 +133,4 @@ def configure(env):
|
||||
env.Append(CPPPATH=['#platform/server'])
|
||||
env.Append(CPPFLAGS=['-DSERVER_ENABLED', '-DUNIX_ENABLED'])
|
||||
env.Append(LIBS=['pthread'])
|
||||
env.Append(LIBS=['dl'])
|
||||
|
@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
const char *OS_Server::get_audio_driver_name(int p_driver) const {
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void OS_Server::initialize_core() {
|
||||
|
||||
crash_handler.initialize();
|
||||
|
||||
OS_Unix::initialize_core();
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
//rasterizer = memnew( RasterizerDummy );
|
||||
RasterizerDummy::make_current();
|
||||
|
||||
//visual_server = memnew( VisualServerRaster(rasterizer) );
|
||||
visual_server = memnew(VisualServerRaster);
|
||||
visual_server->init();
|
||||
|
||||
AudioDriverManager::initialize(p_audio_driver);
|
||||
|
||||
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();
|
||||
|
||||
ERR_FAIL_COND_V(!visual_server, ERR_UNAVAILABLE);
|
||||
|
||||
visual_server->init();
|
||||
|
||||
input = memnew(InputDefault);
|
||||
|
||||
power_manager = memnew(PowerX11);
|
||||
|
||||
_ensure_user_data_dir();
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
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<String> arg;
|
||||
arg.push_back(xdgparam);
|
||||
Error err = const_cast<OS_Server *>(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
|
||||
|
@ -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();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user