2015-05-28 00:42:40 +00:00
|
|
|
#include "servers/visual/visual_server_raster.h"
|
2015-05-29 20:36:48 +00:00
|
|
|
#include "servers/visual/visual_server_wrap_mt.h"
|
2015-05-28 00:42:40 +00:00
|
|
|
#include "drivers/gles2/rasterizer_gles2.h"
|
2015-06-11 19:57:41 +00:00
|
|
|
#include "servers/physics/physics_server_sw.h"
|
|
|
|
#include "main/main.h"
|
|
|
|
|
2015-05-25 00:49:24 +00:00
|
|
|
#include "os_haiku.h"
|
|
|
|
|
2015-06-11 19:57:41 +00:00
|
|
|
|
2015-05-25 03:02:55 +00:00
|
|
|
OS_Haiku::OS_Haiku() {
|
2015-06-11 19:57:41 +00:00
|
|
|
AudioDriverManagerSW::add_driver(&driver_dummy);
|
2015-05-25 03:02:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void OS_Haiku::run() {
|
2015-06-11 19:57:41 +00:00
|
|
|
if (!main_loop) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
main_loop->init();
|
2015-06-16 18:52:24 +00:00
|
|
|
window->Show();
|
|
|
|
window->StartMessageRunner();
|
2015-06-11 19:57:41 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
while (true) {
|
|
|
|
// TODO: process events
|
|
|
|
|
|
|
|
if (Main::iteration() == true) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
app->Run();
|
2015-06-16 18:52:24 +00:00
|
|
|
window->StopMessageRunner();
|
2015-06-11 19:57:41 +00:00
|
|
|
delete app;
|
|
|
|
|
|
|
|
main_loop->finish();
|
2015-05-25 03:02:55 +00:00
|
|
|
}
|
|
|
|
|
2015-05-25 00:49:24 +00:00
|
|
|
String OS_Haiku::get_name() {
|
|
|
|
return "Haiku";
|
|
|
|
}
|
2015-05-25 03:02:55 +00:00
|
|
|
|
|
|
|
int OS_Haiku::get_video_driver_count() const {
|
2015-05-29 21:57:07 +00:00
|
|
|
return 1;
|
2015-05-25 03:02:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char* OS_Haiku::get_video_driver_name(int p_driver) const {
|
2015-05-29 21:57:07 +00:00
|
|
|
return "GLES2";
|
2015-05-25 03:02:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
OS::VideoMode OS_Haiku::get_default_video_mode() const {
|
2015-05-29 21:57:07 +00:00
|
|
|
return OS::VideoMode(800, 600, false);
|
2015-05-25 03:02:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_audio_driver) {
|
2015-05-28 00:42:40 +00:00
|
|
|
main_loop = NULL;
|
2015-05-29 21:57:07 +00:00
|
|
|
current_video_mode = p_desired;
|
2015-05-28 00:42:40 +00:00
|
|
|
|
2015-06-11 19:57:41 +00:00
|
|
|
app = new HaikuApplication();
|
|
|
|
|
2015-06-16 18:52:24 +00:00
|
|
|
BRect frame;
|
|
|
|
frame.Set(50, 50, 50 + current_video_mode.width - 1, 50 + current_video_mode.height - 1);
|
|
|
|
|
|
|
|
window = new HaikuDirectWindow(frame);
|
|
|
|
|
2015-05-28 00:42:40 +00:00
|
|
|
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
|
2015-06-16 18:52:24 +00:00
|
|
|
context_gl = memnew(ContextGL_Haiku(window));
|
2015-06-11 19:57:41 +00:00
|
|
|
context_gl->initialize();
|
2015-05-28 00:42:40 +00:00
|
|
|
|
|
|
|
rasterizer = memnew(RasterizerGLES2);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
visual_server = memnew(VisualServerRaster(rasterizer));
|
|
|
|
|
2015-06-11 19:57:41 +00:00
|
|
|
ERR_FAIL_COND(!visual_server);
|
|
|
|
|
2015-06-16 18:52:24 +00:00
|
|
|
//if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
|
|
|
|
// visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD));
|
|
|
|
//}
|
2015-05-29 21:57:07 +00:00
|
|
|
|
|
|
|
visual_server->init();
|
2015-06-11 19:57:41 +00:00
|
|
|
|
|
|
|
physics_server = memnew(PhysicsServerSW);
|
|
|
|
physics_server->init();
|
|
|
|
physics_2d_server = memnew(Physics2DServerSW);
|
|
|
|
physics_2d_server->init();
|
|
|
|
|
|
|
|
AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton();
|
|
|
|
|
|
|
|
if (AudioDriverManagerSW::get_driver(p_audio_driver)->init() != OK) {
|
|
|
|
ERR_PRINT("Initializing audio failed.");
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
2015-06-16 18:52:24 +00:00
|
|
|
|
|
|
|
input = memnew(InputDefault);
|
|
|
|
window->SetInput(input);
|
2015-05-25 03:02:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OS_Haiku::finalize() {
|
2015-05-28 00:42:40 +00:00
|
|
|
if (main_loop) {
|
|
|
|
memdelete(main_loop);
|
|
|
|
}
|
|
|
|
|
|
|
|
main_loop = NULL;
|
|
|
|
|
2015-06-11 19:57:41 +00:00
|
|
|
spatial_sound_server->finish();
|
|
|
|
memdelete(spatial_sound_server);
|
|
|
|
|
|
|
|
spatial_sound_2d_server->finish();
|
|
|
|
memdelete(spatial_sound_2d_server);
|
|
|
|
|
|
|
|
audio_server->finish();
|
|
|
|
memdelete(audio_server);
|
|
|
|
memdelete(sample_manager);
|
|
|
|
|
2015-05-28 00:42:40 +00:00
|
|
|
visual_server->finish();
|
|
|
|
memdelete(visual_server);
|
|
|
|
memdelete(rasterizer);
|
2015-06-11 19:57:41 +00:00
|
|
|
|
|
|
|
physics_server->finish();
|
|
|
|
memdelete(physics_server);
|
|
|
|
|
|
|
|
physics_2d_server->finish();
|
|
|
|
memdelete(physics_2d_server);
|
|
|
|
|
2015-06-16 18:52:24 +00:00
|
|
|
memdelete(input);
|
|
|
|
|
2015-06-11 19:57:41 +00:00
|
|
|
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
|
|
|
|
memdelete(context_gl);
|
|
|
|
#endif
|
2015-05-25 03:02:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OS_Haiku::set_main_loop(MainLoop* p_main_loop) {
|
2015-05-28 00:42:40 +00:00
|
|
|
main_loop = p_main_loop;
|
2015-06-16 18:52:24 +00:00
|
|
|
input->set_main_loop(p_main_loop);
|
2015-05-25 03:02:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MainLoop* OS_Haiku::get_main_loop() const {
|
2015-05-28 00:42:40 +00:00
|
|
|
return main_loop;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OS_Haiku::delete_main_loop() {
|
|
|
|
if (main_loop) {
|
|
|
|
memdelete(main_loop);
|
|
|
|
}
|
|
|
|
|
|
|
|
main_loop = NULL;
|
2015-05-25 03:02:55 +00:00
|
|
|
}
|
|
|
|
|
2015-06-11 19:57:41 +00:00
|
|
|
void OS_Haiku::release_rendering_thread() {
|
2015-06-16 18:52:24 +00:00
|
|
|
context_gl->release_current();
|
2015-06-11 19:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OS_Haiku::make_rendering_thread() {
|
2015-06-16 18:52:24 +00:00
|
|
|
context_gl->make_current();
|
2015-06-11 19:57:41 +00:00
|
|
|
}
|
|
|
|
|
2015-05-25 03:02:55 +00:00
|
|
|
bool OS_Haiku::can_draw() const {
|
2015-06-11 19:57:41 +00:00
|
|
|
// TODO: implement
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OS_Haiku::swap_buffers() {
|
|
|
|
context_gl->swap_buffers();
|
2015-05-25 03:02:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Point2 OS_Haiku::get_mouse_pos() const {
|
2015-05-29 21:57:07 +00:00
|
|
|
ERR_PRINT("get_mouse_pos() NOT IMPLEMENTED");
|
2015-05-25 03:02:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int OS_Haiku::get_mouse_button_state() const {
|
2015-05-29 21:57:07 +00:00
|
|
|
ERR_PRINT("get_mouse_button_state() NOT IMPLEMENTED");
|
2015-05-25 03:02:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OS_Haiku::set_cursor_shape(CursorShape p_shape) {
|
2015-05-29 21:57:07 +00:00
|
|
|
ERR_PRINT("set_cursor_shape() NOT IMPLEMENTED");
|
2015-05-25 03:02:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OS_Haiku::set_window_title(const String& p_title) {
|
2015-06-11 19:57:41 +00:00
|
|
|
//ERR_PRINT("set_window_title() NOT IMPLEMENTED");
|
|
|
|
window->SetTitle(p_title.utf8().get_data());
|
2015-05-25 03:02:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Size2 OS_Haiku::get_window_size() const {
|
2015-05-29 21:57:07 +00:00
|
|
|
ERR_PRINT("get_window_size() NOT IMPLEMENTED");
|
2015-05-25 03:02:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OS_Haiku::set_video_mode(const VideoMode& p_video_mode, int p_screen) {
|
2015-05-29 21:57:07 +00:00
|
|
|
ERR_PRINT("set_video_mode() NOT IMPLEMENTED");
|
2015-05-25 03:02:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
OS::VideoMode OS_Haiku::get_video_mode(int p_screen) const {
|
2015-05-29 21:57:07 +00:00
|
|
|
return current_video_mode;
|
2015-05-25 03:02:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OS_Haiku::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const {
|
2015-05-29 21:57:07 +00:00
|
|
|
ERR_PRINT("get_fullscreen_mode_list() NOT IMPLEMENTED");
|
2015-05-25 03:02:55 +00:00
|
|
|
}
|
2015-05-25 03:34:16 +00:00
|
|
|
|
|
|
|
String OS_Haiku::get_executable_path() const {
|
|
|
|
return OS::get_executable_path();
|
|
|
|
}
|