Compare commits

16 Commits

Author SHA1 Message Date
Rémi Verschelde
4e7751913d SCons: Remove obsolete DEBUG_MEMORY_ENABLED define
As done in https://github.com/godotengine/godot/pull/40623.
2020-07-23 09:45:11 +02:00
Rémi Verschelde
a5ae9d9b6b Add README and Godot license text 2020-06-20 17:55:28 +02:00
Fabio Alessandrelli
c0dd6e76b7 Move mix_rate, ouput_latency to AudioDriverManager
Each driver used to define the (same) project settings values
`audio/mix_rate` and `audio/output_latency`, but the setting names are
not driver specific.
Overriding is still possible via platform tags.
2020-05-18 13:02:06 +02:00
Rémi Verschelde
828e1880a6 Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to
will now be changed automatically to remove the first empty line.

This makes us lean closer to 1TBS (the one true brace style) instead
of hybridating it with some Allman-inspired spacing.

There's still the case of braces around single-statement blocks that
needs to be addressed (but clang-format can't help with that, but
clang-tidy may if we agree about it).

Part of #33027.
2020-05-14 16:54:55 +02:00
Rémi Verschelde
bae63f2ae2 Port member initialization from constructor to declaration (C++11)
Using `clang-tidy`'s `modernize-use-default-member-init` check and
manual review of the changes, and some extra manual changes that
`clang-tidy` failed to do.

Also went manually through all of `core` to find occurrences that
`clang-tidy` couldn't handle, especially all initializations done
in a constructor without using initializer lists.
2020-05-14 10:01:56 +02:00
Rémi Verschelde
d11cd02300 Rename InputFilter back to Input
It changed name as part of the DisplayServer and input refactoring
in #37317, with the rationale that input no longer goes through the
main loop, so the previous Input singleton now only does filtering.

But the gains in consistency are quite limited in the renaming, and
it breaks compatibility for all scripts and tutorials that access
the Input singleton via the scripting language. A temporary option
was suggested to keep the scripting singleton named `Input` even if
its type is `InputFilter`, but that adds inconsistency and breaks C#.

Fixes godotengine/godot-proposals#639.
Fixes #37319.
Fixes #37690.
2020-04-28 15:19:49 +02:00
lupoDharkael
a5c4985328 Replace NULL with nullptr 2020-04-02 13:38:00 +02:00
Rémi Verschelde
2283ef2994 SCons: Format buildsystem files with psf/black
Configured for a max line length of 120 characters.

psf/black is very opinionated and purposely doesn't leave much room for
configuration. The output is mostly OK so that should be fine for us,
but some things worth noting:

- Manually wrapped strings will be reflowed, so by using a line length
  of 120 for the sake of preserving readability for our long command
  calls, it also means that some manually wrapped strings are back on
  the same line and should be manually merged again.

- Code generators using string concatenation extensively look awful,
  since black puts each operand on a single line. We need to refactor
  these generators to use more pythonic string formatting, for which
  many options are available (`%`, `format` or f-strings).

- CI checks and a pre-commit hook will be added to ensure that future
  buildsystem changes are well-formatted.
2020-03-30 09:05:53 +02:00
Juan Linietsky
c88ff48e36 Renaming of servers for coherency.
VisualServer -> RenderingServer
PhysicsServer -> PhysicsServer3D
Physics2DServer -> PhysicsServer2D
NavigationServer -> NavigationServer3D
Navigation2DServer -> NavigationServer2D

Also renamed corresponding files.
2020-03-27 15:21:27 -03:00
Juan Linietsky
cfd5f8f93e Refactored input, goes all via windows now.
Also renamed Input to InputFilter because all it does is filter events.
2020-03-26 15:49:39 +01:00
Juan Linietsky
51607cbb93 Refactored Input, create DisplayServer and DisplayServerX11 2020-03-26 15:49:32 +01:00
Rémi Verschelde
46ef18cfff Merge pull request #18020 from bruvzg/input_fix_non_latin_and_add_hw_scancodes
Fix non-latin layout scancodes on Linux, adds access to physical scancodes.
2020-03-01 23:00:42 +01:00
Pedro J. Estébanez
6c8d166b84 Reimplement Mutex with C++'s <mutex>
Main:
- It's now implemented thanks to `<mutex>`. No more platform-specific implementations.
- `BinaryMutex` (non-recursive) is added, as an alternative for special cases.
- Doesn't need allocation/deallocation anymore. It can live in the stack and be part of other classes.
- Because of that, it's methods are now `const` and the inner mutex is `mutable` so it can be easily used in `const` contexts.
- A no-op implementation is provided if `NO_THREADS` is defined. No more need to add `#ifdef NO_THREADS` just for this.
- `MutexLock` now takes a reference. At this point the cases of null `Mutex`es are rare. If you ever need that, just don't use `MutexLock`.
- Thread-safe utilities are therefore simpler now.

Misc.:
- `ScopedMutexLock` is dropped and replaced by `MutexLock`, because they were pretty much the same.
- Every case of lock, do-something, unlock is replaced by `MutexLock` (complex cases where it's not straightfoward are kept as as explicit lock and unlock).
- `ShaderRD` contained an `std::mutex`, which has been replaced by `Mutex`.
2020-02-26 20:40:10 +01:00
bruvzg
372cff5481 Rename scancode to keycode.
Add `physical_keycode` (keyboard layout independent keycodes) to InputEventKey and InputMap.
Fix non-latin keyboard layout keycodes on Linux/X11 (fallback to physical keycodes).
2020-02-25 12:30:33 +02:00
Rémi Verschelde
1aa04a5ce2 Remove incomplete battery status/power API
It was initially implemented in #5871 for Godot 3.0, but never really
completed or thoroughly tested for most platforms. It then stayed in
limbo and nobody seems really keen to finish it, so it's better to
remove it in 4.0, and re-add eventually (possibly with a different API)
if there's demand and an implementation confirmed working on all
platforms.

Closes #8770.
2020-02-14 13:43:32 +01:00
Rémi Verschelde
72061c8ec9 Remove obsolete GLES3 backend
Due to the port to Vulkan and complete redesign of the rendering backend,
the `drivers/gles3` code is no longer usable in this state and is not
planned to be ported to the new architecture.

The GLES2 backend is kept (while still disabled and non-working) as it
will eventually be ported to serve as the low-end renderer for Godot 4.0.

Some GLES3 features might be selectively ported to the updated GLES2
backend if there's a need for them, and extensions we can use for that.

So long, OpenGL driver bugs!
2020-02-13 10:36:44 +01:00
12 changed files with 201 additions and 157 deletions

20
LICENSE.txt Normal file
View File

@@ -0,0 +1,20 @@
Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.
Copyright (c) 2014-2020 Godot Engine contributors.
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.

53
README.md Normal file
View File

@@ -0,0 +1,53 @@
## Godot Engine platform port for Haiku
This is the platform port of [Godot Engine](https://godotengine.org) for the
[Haiku](https://www.haiku-os.org) operating system.
Haiku is not an officially supported platform in the main tree of Godot, so
this port is kept separate so that it can be contributed to independently of
Godot's main release cycle.
It may imply that this port might not be functional for the latest versions of
Godot. For the time being, neither the `3.2` branch nor the `master` branch are
functional out-of-the-box on Haiku.
We welcome all contributions from Haiku developers to ensure that each branch
and Git tag of this repository work as expected with the matching branches and
tags of the [Godot repository](https://github.com/godotengine/godot/).
## Usage
This code is meant to be copied as `platform/haiku` in the Godot Engine
[source repository](https://github.com/godotengine/godot/) to make builds of
Godot for Haiku.
It can also be cloned as a Git submodule:
```
git clone https://github.com/godotengine/godot
cd godot
git submodule add https://github.com/godotengine/godot-haiku-platform platform/haiku
```
Be sure to use compatible branches for the Godot repository and the Haiku port.
You can then compile Godot for Haiku with:
```
# Editor build, optimized.
scons p=haiku tools=yes target=release_debug
# Export template, debug.
scons p=haiku tools=no target=release_debug
# Export template, release.
scons p=haiku tools=no target=release
```
## License
This port is distributed under the MIT license, with the same copyright as the
main Godot source repository.
See [LICENSE.txt](/LICENSE.txt) for details, and
[AUTHORS.md](https://github.com/godotengine/godot/blob/master/AUTHORS.md) in
the Godot repository for a list of contributors.

27
SCsub
View File

@@ -1,28 +1,25 @@
#!/usr/bin/env python
Import('env')
Import("env")
common_haiku = [
'os_haiku.cpp',
'context_gl_haiku.cpp',
'haiku_application.cpp',
'haiku_direct_window.cpp',
'haiku_gl_view.cpp',
'key_mapping_haiku.cpp',
'audio_driver_media_kit.cpp'
"os_haiku.cpp",
"context_gl_haiku.cpp",
"haiku_application.cpp",
"haiku_direct_window.cpp",
"haiku_gl_view.cpp",
"key_mapping_haiku.cpp",
"audio_driver_media_kit.cpp",
]
target = env.add_program(
'#bin/godot',
['godot_haiku.cpp'] + common_haiku
)
target = env.add_program("#bin/godot", ["godot_haiku.cpp"] + common_haiku)
command = env.Command('#bin/godot.rsrc', '#platform/haiku/godot.rdef',
['rc -o $TARGET $SOURCE'])
command = env.Command("#bin/godot.rsrc", "#platform/haiku/godot.rdef", ["rc -o $TARGET $SOURCE"])
def addResourcesAction(target=None, source=None, env=None):
return env.Execute('xres -o ' + File(target)[0].path + ' bin/godot.rsrc')
return env.Execute("xres -o " + File(target)[0].path + " bin/godot.rsrc")
env.AddPostAction(target, addResourcesAction)
env.Depends(target, command)

View File

@@ -34,16 +34,16 @@
#include "core/project_settings.h"
int32_t *AudioDriverMediaKit::samples_in = NULL;
int32_t *AudioDriverMediaKit::samples_in = nullptr;
Error AudioDriverMediaKit::init() {
active = false;
mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE);
mix_rate = GLOBAL_GET("audio/mix_rate");
speaker_mode = SPEAKER_MODE_STEREO;
channels = 2;
int latency = GLOBAL_DEF_RST("audio/output_latency", DEFAULT_OUTPUT_LATENCY);
int latency = GLOBAL_GET("audio/output_latency");
buffer_size = next_power_of_2(latency * mix_rate / 1000);
samples_in = memnew_arr(int32_t, buffer_size * channels);
@@ -59,15 +59,14 @@ Error AudioDriverMediaKit::init() {
&format,
"godot_sound_server",
AudioDriverMediaKit::PlayBuffer,
NULL,
nullptr,
this);
if (player->InitCheck() != B_OK) {
fprintf(stderr, "MediaKit ERR: can not create a BSoundPlayer instance\n");
ERR_FAIL_COND_V(player == NULL, ERR_CANT_OPEN);
ERR_FAIL_COND_V(player == nullptr, ERR_CANT_OPEN);
}
mutex = Mutex::create();
player->Start();
return OK;
@@ -108,14 +107,14 @@ void AudioDriverMediaKit::lock() {
if (!mutex)
return;
mutex->lock();
mutex.lock();
}
void AudioDriverMediaKit::unlock() {
if (!mutex)
return;
mutex->unlock();
mutex.unlock();
}
void AudioDriverMediaKit::finish() {
@@ -124,16 +123,10 @@ void AudioDriverMediaKit::finish() {
if (samples_in) {
memdelete_arr(samples_in);
};
if (mutex) {
memdelete(mutex);
mutex = NULL;
}
}
AudioDriverMediaKit::AudioDriverMediaKit() {
mutex = NULL;
player = NULL;
player = nullptr;
}
AudioDriverMediaKit::~AudioDriverMediaKit() {

View File

@@ -40,7 +40,7 @@
#include <SoundPlayer.h>
class AudioDriverMediaKit : public AudioDriver {
Mutex *mutex;
Mutex mutex;
BSoundPlayer *player;
static int32_t *samples_in;

140
detect.py
View File

@@ -12,7 +12,7 @@ def get_name():
def can_build():
if (os.name != "posix" or sys.platform == "darwin"):
if os.name != "posix" or sys.platform == "darwin":
return False
return True
@@ -22,41 +22,40 @@ def get_opts():
from SCons.Variables import EnumVariable
return [
EnumVariable('debug_symbols', 'Add debugging symbols to release builds', 'yes', ('yes', 'no', 'full')),
EnumVariable("debug_symbols", "Add debugging symbols to release builds", "yes", ("yes", "no", "full")),
]
def get_flags():
return [
]
return []
def configure(env):
## Build type
if (env["target"] == "release"):
env.Prepend(CCFLAGS=['-O3'])
if (env["debug_symbols"] == "yes"):
env.Prepend(CCFLAGS=['-g1'])
if (env["debug_symbols"] == "full"):
env.Prepend(CCFLAGS=['-g2'])
if env["target"] == "release":
env.Prepend(CCFLAGS=["-O3"])
if env["debug_symbols"] == "yes":
env.Prepend(CCFLAGS=["-g1"])
if env["debug_symbols"] == "full":
env.Prepend(CCFLAGS=["-g2"])
elif (env["target"] == "release_debug"):
env.Prepend(CCFLAGS=['-O2', '-DDEBUG_ENABLED'])
if (env["debug_symbols"] == "yes"):
env.Prepend(CCFLAGS=['-g1'])
if (env["debug_symbols"] == "full"):
env.Prepend(CCFLAGS=['-g2'])
elif env["target"] == "release_debug":
env.Prepend(CCFLAGS=["-O2", "-DDEBUG_ENABLED"])
if env["debug_symbols"] == "yes":
env.Prepend(CCFLAGS=["-g1"])
if env["debug_symbols"] == "full":
env.Prepend(CCFLAGS=["-g2"])
elif (env["target"] == "debug"):
env.Prepend(CCFLAGS=['-g3', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
elif env["target"] == "debug":
env.Prepend(CCFLAGS=["-g3", "-DDEBUG_ENABLED"])
## Architecture
is64 = sys.maxsize > 2**32
if (env["bits"] == "default"):
is64 = sys.maxsize > 2 ** 32
if env["bits"] == "default":
env["bits"] = "64" if is64 else "32"
## Compiler configuration
@@ -66,89 +65,94 @@ def configure(env):
## Dependencies
if not env['builtin_libwebp']:
env.ParseConfig('pkg-config libwebp --cflags --libs')
if not env["builtin_libwebp"]:
env.ParseConfig("pkg-config libwebp --cflags --libs")
# freetype depends on libpng and zlib, so bundling one of them while keeping others
# as shared libraries leads to weird issues
if env['builtin_freetype'] or env['builtin_libpng'] or env['builtin_zlib']:
env['builtin_freetype'] = True
env['builtin_libpng'] = True
env['builtin_zlib'] = True
if env["builtin_freetype"] or env["builtin_libpng"] or env["builtin_zlib"]:
env["builtin_freetype"] = True
env["builtin_libpng"] = True
env["builtin_zlib"] = True
if not env['builtin_freetype']:
env.ParseConfig('pkg-config freetype2 --cflags --libs')
if not env["builtin_freetype"]:
env.ParseConfig("pkg-config freetype2 --cflags --libs")
if not env['builtin_libpng']:
env.ParseConfig('pkg-config libpng16 --cflags --libs')
if not env["builtin_libpng"]:
env.ParseConfig("pkg-config libpng16 --cflags --libs")
if not env['builtin_bullet']:
if not env["builtin_bullet"]:
# We need at least version 2.88
import subprocess
bullet_version = subprocess.check_output(['pkg-config', 'bullet', '--modversion']).strip()
bullet_version = subprocess.check_output(["pkg-config", "bullet", "--modversion"]).strip()
if bullet_version < "2.88":
# Abort as system bullet was requested but too old
print("Bullet: System version {0} does not match minimal requirements ({1}). Aborting.".format(bullet_version, "2.88"))
print(
"Bullet: System version {0} does not match minimal requirements ({1}). Aborting.".format(
bullet_version, "2.88"
)
)
sys.exit(255)
env.ParseConfig('pkg-config bullet --cflags --libs')
env.ParseConfig("pkg-config bullet --cflags --libs")
if not env['builtin_enet']:
env.ParseConfig('pkg-config libenet --cflags --libs')
if not env["builtin_enet"]:
env.ParseConfig("pkg-config libenet --cflags --libs")
if not env['builtin_squish']:
env.ParseConfig('pkg-config libsquish --cflags --libs')
if not env["builtin_squish"]:
env.ParseConfig("pkg-config libsquish --cflags --libs")
if not env['builtin_zstd']:
env.ParseConfig('pkg-config libzstd --cflags --libs')
if not env["builtin_zstd"]:
env.ParseConfig("pkg-config libzstd --cflags --libs")
# Sound and video libraries
# Keep the order as it triggers chained dependencies (ogg needed by others, etc.)
if not env['builtin_libtheora']:
env['builtin_libogg'] = False # Needed to link against system libtheora
env['builtin_libvorbis'] = False # Needed to link against system libtheora
env.ParseConfig('pkg-config theora theoradec --cflags --libs')
if not env["builtin_libtheora"]:
env["builtin_libogg"] = False # Needed to link against system libtheora
env["builtin_libvorbis"] = False # Needed to link against system libtheora
env.ParseConfig("pkg-config theora theoradec --cflags --libs")
if not env['builtin_libvpx']:
env.ParseConfig('pkg-config vpx --cflags --libs')
if not env["builtin_libvpx"]:
env.ParseConfig("pkg-config vpx --cflags --libs")
if not env['builtin_libvorbis']:
env['builtin_libogg'] = False # Needed to link against system libvorbis
env.ParseConfig('pkg-config vorbis vorbisfile --cflags --libs')
if not env["builtin_libvorbis"]:
env["builtin_libogg"] = False # Needed to link against system libvorbis
env.ParseConfig("pkg-config vorbis vorbisfile --cflags --libs")
if not env['builtin_opus']:
env['builtin_libogg'] = False # Needed to link against system opus
env.ParseConfig('pkg-config opus opusfile --cflags --libs')
if not env["builtin_opus"]:
env["builtin_libogg"] = False # Needed to link against system opus
env.ParseConfig("pkg-config opus opusfile --cflags --libs")
if not env['builtin_libogg']:
env.ParseConfig('pkg-config ogg --cflags --libs')
if not env["builtin_libogg"]:
env.ParseConfig("pkg-config ogg --cflags --libs")
if env['builtin_libtheora']:
list_of_x86 = ['x86_64', 'x86', 'i386', 'i586']
if env["builtin_libtheora"]:
list_of_x86 = ["x86_64", "x86", "i386", "i586"]
if any(platform.machine() in s for s in list_of_x86):
env["x86_libtheora_opt_gcc"] = True
if not env['builtin_wslay']:
env.ParseConfig('pkg-config libwslay --cflags --libs')
if not env["builtin_wslay"]:
env.ParseConfig("pkg-config libwslay --cflags --libs")
if not env['builtin_mbedtls']:
if not env["builtin_mbedtls"]:
# mbedTLS does not provide a pkgconfig config yet. See https://github.com/ARMmbed/mbedtls/issues/228
env.Append(LIBS=['mbedtls', 'mbedcrypto', 'mbedx509'])
env.Append(LIBS=["mbedtls", "mbedcrypto", "mbedx509"])
if not env['builtin_miniupnpc']:
if not env["builtin_miniupnpc"]:
# No pkgconfig file so far, hardcode default paths.
env.Prepend(CPPPATH=["/system/develop/headers/x86/miniupnpc"])
env.Append(LIBS=["miniupnpc"])
# On Linux wchar_t should be 32-bits
# 16-bit library shouldn't be required due to compiler optimisations
if not env['builtin_pcre2']:
env.ParseConfig('pkg-config libpcre2-32 --cflags --libs')
if not env["builtin_pcre2"]:
env.ParseConfig("pkg-config libpcre2-32 --cflags --libs")
## Flags
env.Prepend(CPPPATH=['#platform/haiku'])
env.Append(CPPDEFINES=['UNIX_ENABLED', 'OPENGL_ENABLED', 'GLES_ENABLED'])
env.Append(CPPDEFINES=['MEDIA_KIT_ENABLED'])
env.Append(CPPDEFINES=['PTHREAD_NO_RENAME']) # TODO: enable when we have pthread_setname_np
env.Append(LIBS=['be', 'game', 'media', 'network', 'bnetapi', 'z', 'GL'])
env.Prepend(CPPPATH=["#platform/haiku"])
env.Append(CPPDEFINES=["UNIX_ENABLED", "OPENGL_ENABLED", "GLES_ENABLED"])
env.Append(CPPDEFINES=["MEDIA_KIT_ENABLED"])
env.Append(CPPDEFINES=["PTHREAD_NO_RENAME"]) # TODO: enable when we have pthread_setname_np
env.Append(LIBS=["be", "game", "media", "network", "bnetapi", "z", "GL"])

View File

@@ -42,10 +42,10 @@ HaikuDirectWindow::HaikuDirectWindow(BRect p_frame) :
last_button_mask = 0;
last_key_modifier_state = 0;
view = NULL;
update_runner = NULL;
input = NULL;
main_loop = NULL;
view = nullptr;
update_runner = nullptr;
input = nullptr;
main_loop = nullptr;
}
HaikuDirectWindow::~HaikuDirectWindow() {
@@ -74,7 +74,7 @@ void HaikuDirectWindow::SetMainLoop(MainLoop *p_main_loop) {
bool HaikuDirectWindow::QuitRequested() {
StopMessageRunner();
main_loop->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
main_loop->notification(NOTIFICATION_WM_CLOSE_REQUEST);
return false;
}
@@ -273,18 +273,20 @@ void HaikuDirectWindow::HandleKeyboardEvent(BMessage *message) {
event.instance();
GetKeyModifierState(event, modifiers);
event->set_pressed(message->what == B_KEY_DOWN);
event->set_scancode(KeyMappingHaiku::get_keysym(raw_char, key));
event->set_keycode(KeyMappingHaiku::get_keysym(raw_char, key));
event->set_physical_keycode(KeyMappingHaiku::get_keysym(raw_char, key));
event->set_echo(message->HasInt32("be:key_repeat"));
event->set_unicode(0);
const char *bytes = NULL;
const char *bytes = nullptr;
if (message->FindString("bytes", &bytes) == B_OK) {
event->set_unicode(BUnicodeChar::FromUTF8(&bytes));
}
//make it consistent across platforms.
if (event->get_scancode() == KEY_BACKTAB) {
event->set_scancode(KEY_TAB);
if (event->get_keycode() == KEY_BACKTAB) {
event->set_keycode(KEY_TAB);
event->set_physical_keycode(KEY_TAB);
event->set_shift(true);
}

View File

@@ -35,8 +35,8 @@
#include <DirectWindow.h>
#include "core/input/input.h"
#include "core/os/os.h"
#include "main/input_default.h"
#include "haiku_gl_view.h"

View File

@@ -32,7 +32,7 @@
#define KEY_MAPPING_HAIKU_H
class KeyMappingHaiku {
KeyMappingHaiku(){};
KeyMappingHaiku() {}
public:
static unsigned int get_keysym(int32 raw_char, int32 key);

View File

@@ -28,14 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "drivers/gles3/rasterizer_gles3.h"
#include "os_haiku.h"
#include "drivers/gles2/rasterizer_gles2.h"
#include "main/main.h"
#include "servers/physics/physics_server_sw.h"
#include "servers/visual/visual_server_raster.h"
#include "servers/visual/visual_server_wrap_mt.h"
#include "servers/physics_3d/physics_server_3d_sw.h"
#include "servers/rendering/rendering_server_raster.h"
#include "servers/rendering/rendering_server_wrap_mt.h"
#include <Screen.h>
@@ -78,7 +77,7 @@ int OS_Haiku::get_video_driver_count() const {
}
const char *OS_Haiku::get_video_driver_name(int p_driver) const {
return "GLES3";
return "GLES2";
}
int OS_Haiku::get_current_video_driver() const {
@@ -86,7 +85,7 @@ int OS_Haiku::get_current_video_driver() const {
}
Error OS_Haiku::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
main_loop = NULL;
main_loop = nullptr;
current_video_mode = p_desired;
app = new HaikuApplication();
@@ -112,18 +111,18 @@ Error OS_Haiku::initialize(const VideoMode &p_desired, int p_video_driver, int p
context_gl->initialize();
context_gl->make_current();
context_gl->set_use_vsync(current_video_mode.use_vsync);
RasterizerGLES3::register_config();
RasterizerGLES3::make_current();
// FIXME: That's not how the rasterizer setup should happen.
RasterizerGLES2::register_config();
RasterizerGLES2::make_current();
#endif
visual_server = memnew(VisualServerRaster);
rendering_server = memnew(RenderingServerRaster);
// FIXME: Reimplement threaded rendering
if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
visual_server = memnew(VisualServerWrapMT(visual_server, false));
rendering_server = memnew(RenderingServerWrapMT(rendering_server, false));
}
ERR_FAIL_COND_V(!visual_server, ERR_UNAVAILABLE);
ERR_FAIL_COND_V(!rendering_server, ERR_UNAVAILABLE);
video_driver_index = p_video_driver;
@@ -131,7 +130,7 @@ Error OS_Haiku::initialize(const VideoMode &p_desired, int p_video_driver, int p
window->SetInput(input);
window->Show();
visual_server->init();
rendering_server->init();
AudioDriverManager::initialize(p_audio_driver);
@@ -143,10 +142,10 @@ void OS_Haiku::finalize() {
memdelete(main_loop);
}
main_loop = NULL;
main_loop = nullptr;
visual_server->finish();
memdelete(visual_server);
rendering_server->finish();
memdelete(rendering_server);
memdelete(input);
@@ -170,8 +169,8 @@ void OS_Haiku::delete_main_loop() {
memdelete(main_loop);
}
main_loop = NULL;
window->SetMainLoop(NULL);
main_loop = nullptr;
window->SetMainLoop(nullptr);
}
void OS_Haiku::release_rendering_thread() {
@@ -268,7 +267,7 @@ void OS_Haiku::set_window_position(const Point2 &p_position) {
void OS_Haiku::set_window_fullscreen(bool p_enabled) {
window->SetFullScreen(p_enabled);
current_video_mode.fullscreen = p_enabled;
visual_server->init();
rendering_server->init();
}
bool OS_Haiku::is_window_fullscreen() const {
@@ -325,12 +324,10 @@ String OS_Haiku::get_executable_path() const {
}
bool OS_Haiku::_check_internal_feature_support(const String &p_feature) {
return p_feature == "pc";
}
String OS_Haiku::get_config_path() const {
if (has_environment("XDG_CONFIG_HOME")) {
return get_environment("XDG_CONFIG_HOME");
} else if (has_environment("HOME")) {
@@ -341,7 +338,6 @@ String OS_Haiku::get_config_path() const {
}
String OS_Haiku::get_data_path() const {
if (has_environment("XDG_DATA_HOME")) {
return get_environment("XDG_DATA_HOME");
} else if (has_environment("HOME")) {
@@ -352,7 +348,6 @@ String OS_Haiku::get_data_path() const {
}
String OS_Haiku::get_cache_path() const {
if (has_environment("XDG_CACHE_HOME")) {
return get_environment("XDG_CACHE_HOME");
} else if (has_environment("HOME")) {
@@ -361,18 +356,3 @@ String OS_Haiku::get_cache_path() const {
return get_config_path();
}
}
OS::PowerState OS_Haiku::get_power_state() {
WARN_PRINT("Power management is not implemented on this platform, defaulting to POWERSTATE_UNKNOWN");
return OS::POWERSTATE_UNKNOWN;
}
int OS_Haiku::get_power_seconds_left() {
WARN_PRINT("Power management is not implemented on this platform, defaulting to -1");
return -1;
}
int OS_Haiku::get_power_percent_left() {
WARN_PRINT("Power management is not implemented on this platform, defaulting to -1");
return -1;
}

View File

@@ -33,12 +33,12 @@
#include "audio_driver_media_kit.h"
#include "context_gl_haiku.h"
#include "core/input/input.h"
#include "drivers/unix/os_unix.h"
#include "haiku_application.h"
#include "haiku_direct_window.h"
#include "main/input_default.h"
#include "servers/audio_server.h"
#include "servers/visual_server.h"
#include "servers/rendering_server.h"
class OS_Haiku : public OS_Unix {
private:
@@ -46,7 +46,7 @@ private:
HaikuDirectWindow *window;
MainLoop *main_loop;
InputDefault *input;
VisualServer *visual_server;
RenderingServer *rendering_server;
VideoMode current_video_mode;
int video_driver_index;
@@ -113,10 +113,6 @@ public:
virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const;
virtual String get_executable_path() const;
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;

View File

@@ -33,5 +33,4 @@
// for ifaddrs.h needed in drivers/unix/ip_unix.cpp
#define _BSD_SOURCE 1
#define GLES3_INCLUDE_H "thirdparty/glad/glad/glad.h"
#define GLES2_INCLUDE_H "thirdparty/glad/glad/glad.h"