blob: 7e4bb83177007716cb7c0b26785528d28ec75905 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
#include "servers/visual/visual_server_raster.h"
#include "servers/visual/visual_server_wrap_mt.h"
#include "drivers/gles2/rasterizer_gles2.h"
#include "servers/physics/physics_server_sw.h"
//#include "servers/physics_2d/physics_2d_server_wrap_mt.h"
#include "main/main.h"
#include "os_haiku.h"
OS_Haiku::OS_Haiku() {
AudioDriverManagerSW::add_driver(&driver_dummy);
};
void OS_Haiku::run() {
if (!main_loop) {
return;
}
main_loop->init();
window->Show();
window->StartMessageRunner();
app->Run();
window->StopMessageRunner();
delete app;
main_loop->finish();
}
String OS_Haiku::get_name() {
return "Haiku";
}
int OS_Haiku::get_video_driver_count() const {
return 1;
}
const char* OS_Haiku::get_video_driver_name(int p_driver) const {
return "GLES2";
}
OS::VideoMode OS_Haiku::get_default_video_mode() const {
return OS::VideoMode(800, 600, false);
}
void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_audio_driver) {
main_loop = NULL;
current_video_mode = p_desired;
app = new HaikuApplication();
BRect frame;
frame.Set(50, 50, 50 + current_video_mode.width - 1, 50 + current_video_mode.height - 1);
window = new HaikuDirectWindow(frame);
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
context_gl = memnew(ContextGL_Haiku(window));
context_gl->initialize();
rasterizer = memnew(RasterizerGLES2);
#endif
visual_server = memnew(VisualServerRaster(rasterizer));
ERR_FAIL_COND(!visual_server);
// TODO: enable multithreaded VS
//if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
// visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD));
//}
visual_server->init();
physics_server = memnew(PhysicsServerSW);
physics_server->init();
physics_2d_server = memnew(Physics2DServerSW);
// TODO: enable multithreaded PS
//physics_2d_server = Physics2DServerWrapMT::init_server<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();
input = memnew(InputDefault);
window->SetInput(input);
}
void OS_Haiku::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);
audio_server->finish();
memdelete(audio_server);
memdelete(sample_manager);
visual_server->finish();
memdelete(visual_server);
memdelete(rasterizer);
physics_server->finish();
memdelete(physics_server);
physics_2d_server->finish();
memdelete(physics_2d_server);
memdelete(input);
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
memdelete(context_gl);
#endif
}
void OS_Haiku::set_main_loop(MainLoop* p_main_loop) {
main_loop = p_main_loop;
input->set_main_loop(p_main_loop);
window->SetMainLoop(p_main_loop);
}
MainLoop* OS_Haiku::get_main_loop() const {
return main_loop;
}
void OS_Haiku::delete_main_loop() {
if (main_loop) {
memdelete(main_loop);
}
main_loop = NULL;
window->SetMainLoop(NULL);
}
void OS_Haiku::release_rendering_thread() {
context_gl->release_current();
}
void OS_Haiku::make_rendering_thread() {
context_gl->make_current();
}
bool OS_Haiku::can_draw() const {
// TODO: implement
return true;
}
void OS_Haiku::swap_buffers() {
context_gl->swap_buffers();
}
Point2 OS_Haiku::get_mouse_pos() const {
return window->GetLastMousePosition();
}
int OS_Haiku::get_mouse_button_state() const {
return window->GetLastButtonMask();
}
void OS_Haiku::set_cursor_shape(CursorShape p_shape) {
//ERR_PRINT("set_cursor_shape() NOT IMPLEMENTED");
}
void OS_Haiku::set_window_title(const String& p_title) {
window->SetTitle(p_title.utf8().get_data());
}
Size2 OS_Haiku::get_window_size() const {
ERR_PRINT("get_window_size() NOT IMPLEMENTED");
}
void OS_Haiku::set_video_mode(const VideoMode& p_video_mode, int p_screen) {
ERR_PRINT("set_video_mode() NOT IMPLEMENTED");
}
OS::VideoMode OS_Haiku::get_video_mode(int p_screen) const {
return current_video_mode;
}
void OS_Haiku::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const {
ERR_PRINT("get_fullscreen_mode_list() NOT IMPLEMENTED");
}
String OS_Haiku::get_executable_path() const {
return OS::get_executable_path();
}
|