mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Merge pull request #4951 from waddlesplash/haiku-2
Initial support for Haiku.
This commit is contained in:
@ -95,6 +95,9 @@ if(WIN32)
|
||||
set(SRCS ${SRCS} GL/GLInterface/WGL.cpp)
|
||||
elseif(APPLE)
|
||||
set(SRCS ${SRCS} GL/GLInterface/AGL.mm)
|
||||
elseif(HAIKU)
|
||||
set(SRCS ${SRCS} GL/GLInterface/BGL.cpp)
|
||||
set(LIBS ${LIBS} be GL)
|
||||
elseif(USE_X11)
|
||||
if (NOT USE_EGL)
|
||||
set(SRCS ${SRCS} GL/GLInterface/GLX.cpp)
|
||||
@ -115,4 +118,7 @@ add_dolphin_library(common "${SRCS}" "${LIBS}")
|
||||
if(UNIX)
|
||||
# Posix networking code needs to be fixed for Windows
|
||||
add_executable(traversal_server TraversalServer.cpp)
|
||||
if(HAIKU)
|
||||
target_link_libraries(traversal_server network)
|
||||
endif()
|
||||
endif()
|
||||
|
70
Source/Core/Common/GL/GLInterface/BGL.cpp
Normal file
70
Source/Core/Common/GL/GLInterface/BGL.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Common/GL/GLInterface/BGL.h"
|
||||
|
||||
#include <GLView.h>
|
||||
#include <Size.h>
|
||||
#include <Window.h>
|
||||
|
||||
void cInterfaceBGL::Swap()
|
||||
{
|
||||
m_gl->SwapBuffers();
|
||||
}
|
||||
|
||||
bool cInterfaceBGL::Create(void* window_handle, bool core)
|
||||
{
|
||||
m_window = static_cast<BWindow*>(window_handle);
|
||||
|
||||
m_gl = new BGLView(m_window->Bounds(), "cInterfaceBGL", B_FOLLOW_ALL_SIDES, 0,
|
||||
BGL_RGB | BGL_DOUBLE | BGL_ALPHA);
|
||||
m_window->AddChild(m_gl);
|
||||
|
||||
s_opengl_mode = GLInterfaceMode::MODE_OPENGL;
|
||||
|
||||
// Control m_window size and picture scaling
|
||||
BRect size = m_gl->Frame();
|
||||
s_backbuffer_width = size.IntegerWidth();
|
||||
s_backbuffer_height = size.IntegerHeight();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cInterfaceBGL::MakeCurrent()
|
||||
{
|
||||
m_gl->LockGL();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cInterfaceBGL::ClearCurrent()
|
||||
{
|
||||
m_gl->UnlockGL();
|
||||
return true;
|
||||
}
|
||||
|
||||
void cInterfaceBGL::Shutdown()
|
||||
{
|
||||
// We don't need to delete m_gl, it's owned by the BWindow.
|
||||
m_gl = nullptr;
|
||||
}
|
||||
|
||||
void cInterfaceBGL::Update()
|
||||
{
|
||||
BRect size = m_gl->Frame();
|
||||
|
||||
if (s_backbuffer_width == size.IntegerWidth() && s_backbuffer_height == size.IntegerHeight())
|
||||
return;
|
||||
|
||||
s_backbuffer_width = size.IntegerWidth();
|
||||
s_backbuffer_height = size.IntegerHeight();
|
||||
}
|
||||
|
||||
void cInterfaceBGL::SwapInterval(int interval)
|
||||
{
|
||||
}
|
||||
|
||||
void* cInterfaceBGL::GetFuncAddress(const std::string& name)
|
||||
{
|
||||
return m_gl->GetGLProcAddress(name.c_str());
|
||||
}
|
27
Source/Core/Common/GL/GLInterface/BGL.h
Normal file
27
Source/Core/Common/GL/GLInterface/BGL.h
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Common/GL/GLInterfaceBase.h"
|
||||
|
||||
class BWindow;
|
||||
class BGLView;
|
||||
|
||||
class cInterfaceBGL final : public cInterfaceBase
|
||||
{
|
||||
public:
|
||||
void Swap() override;
|
||||
void* GetFuncAddress(const std::string& name) override;
|
||||
bool Create(void* window_handle, bool core) override;
|
||||
bool MakeCurrent() override;
|
||||
bool ClearCurrent() override;
|
||||
void Shutdown() override;
|
||||
void Update() override;
|
||||
void SwapInterval(int interval) override;
|
||||
|
||||
private:
|
||||
BWindow* m_window;
|
||||
BGLView* m_gl;
|
||||
};
|
30
Source/Core/Common/GL/GLInterface/EGLHaiku.cpp
Normal file
30
Source/Core/Common/GL/GLInterface/EGLHaiku.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Common/GL/GLInterface/EGLHaiku.h"
|
||||
|
||||
#include <Window.h>
|
||||
|
||||
EGLDisplay cInterfaceEGLHaiku::OpenDisplay()
|
||||
{
|
||||
return eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
}
|
||||
|
||||
EGLNativeWindowType cInterfaceEGLHaiku::InitializePlatform(EGLNativeWindowType host_window,
|
||||
EGLConfig config)
|
||||
{
|
||||
EGLint format;
|
||||
eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &format);
|
||||
|
||||
BWindow* window = reinterpret_cast<BWindow*>(host_window);
|
||||
const int width = window->Size().width;
|
||||
const int height = window->Size().height;
|
||||
GLInterface->SetBackBufferDimensions(width, height);
|
||||
|
||||
return host_window;
|
||||
}
|
||||
|
||||
void cInterfaceEGLHaiku::ShutdownPlatform()
|
||||
{
|
||||
}
|
16
Source/Core/Common/GL/GLInterface/EGLHaiku.h
Normal file
16
Source/Core/Common/GL/GLInterface/EGLHaiku.h
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Common/GL/GLInterface/EGL.h"
|
||||
|
||||
class cInterfaceEGLHaiku final : public cInterfaceEGL
|
||||
{
|
||||
protected:
|
||||
EGLDisplay OpenDisplay() override;
|
||||
EGLNativeWindowType InitializePlatform(EGLNativeWindowType host_window,
|
||||
EGLConfig config) override;
|
||||
void ShutdownPlatform() override;
|
||||
};
|
@ -20,6 +20,8 @@
|
||||
#include "Common/GL/GLInterface/EGL.h"
|
||||
#elif ANDROID
|
||||
#include "Common/GL/GLInterface/EGLAndroid.h"
|
||||
#elif defined(__HAIKU__)
|
||||
#include "Common/GL/GLInterface/BGL.h"
|
||||
#else
|
||||
#error Platform doesnt have a GLInterface
|
||||
#endif
|
||||
@ -40,6 +42,8 @@ std::unique_ptr<cInterfaceBase> HostGL_CreateGLInterface()
|
||||
#endif
|
||||
#elif ANDROID
|
||||
return std::make_unique<cInterfaceEGLAndroid>();
|
||||
#elif defined(__HAIKU__)
|
||||
return std::make_unique<cInterfaceBGL>();
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include <sys/types.h>
|
||||
#if defined __APPLE__ || defined __FreeBSD__ || defined __OpenBSD__
|
||||
#include <sys/sysctl.h>
|
||||
#elif defined __HAIKU__
|
||||
#include <OS.h>
|
||||
#else
|
||||
#include <sys/sysinfo.h>
|
||||
#endif
|
||||
@ -269,6 +271,10 @@ size_t MemPhysical()
|
||||
size_t length = sizeof(size_t);
|
||||
sysctl(mib, 2, &physical_memory, &length, NULL, 0);
|
||||
return physical_memory;
|
||||
#elif defined __HAIKU__
|
||||
system_info sysinfo;
|
||||
get_system_info(&sysinfo);
|
||||
return static_cast<size_t>(sysinfo.max_pages * B_PAGE_SIZE);
|
||||
#else
|
||||
struct sysinfo memInfo;
|
||||
sysinfo(&memInfo);
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && !defined(ANDROID) && !defined(__OpenBSD__)
|
||||
#if !defined(_WIN32) && !defined(ANDROID) && !defined(__HAIKU__) && !defined(__OpenBSD__)
|
||||
static locale_t GetCLocale()
|
||||
{
|
||||
static locale_t c_locale = newlocale(LC_ALL_MASK, "C", nullptr);
|
||||
@ -123,11 +123,11 @@ bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list ar
|
||||
c_locale = _create_locale(LC_ALL, "C");
|
||||
writtenCount = _vsnprintf_l(out, outsize, format, c_locale, args);
|
||||
#else
|
||||
#if !defined(ANDROID) && !defined(__OpenBSD__)
|
||||
#if !defined(ANDROID) && !defined(__HAIKU__) && !defined(__OpenBSD__)
|
||||
locale_t previousLocale = uselocale(GetCLocale());
|
||||
#endif
|
||||
writtenCount = vsnprintf(out, outsize, format, args);
|
||||
#if !defined(ANDROID) && !defined(__OpenBSD__)
|
||||
#if !defined(ANDROID) && !defined(__HAIKU__) && !defined(__OpenBSD__)
|
||||
uselocale(previousLocale);
|
||||
#endif
|
||||
#endif
|
||||
@ -164,12 +164,12 @@ std::string StringFromFormatV(const char* format, va_list args)
|
||||
std::string temp = buf;
|
||||
delete[] buf;
|
||||
#else
|
||||
#if !defined(ANDROID) && !defined(__OpenBSD__)
|
||||
#if !defined(ANDROID) && !defined(__HAIKU__) && !defined(__OpenBSD__)
|
||||
locale_t previousLocale = uselocale(GetCLocale());
|
||||
#endif
|
||||
if (vasprintf(&buf, format, args) < 0)
|
||||
ERROR_LOG(COMMON, "Unable to allocate memory for string");
|
||||
#if !defined(ANDROID) && !defined(__OpenBSD__)
|
||||
#if !defined(ANDROID) && !defined(__HAIKU__) && !defined(__OpenBSD__)
|
||||
uselocale(previousLocale);
|
||||
#endif
|
||||
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include <mach/mach.h>
|
||||
#elif defined BSD4_4 || defined __FreeBSD__ || defined __OpenBSD__
|
||||
#include <pthread_np.h>
|
||||
#elif defined __HAIKU__
|
||||
#include <OS.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_VTUNE
|
||||
@ -136,6 +138,8 @@ void SetCurrentThreadName(const char* szThreadName)
|
||||
pthread_setname_np(szThreadName);
|
||||
#elif defined __FreeBSD__ || defined __OpenBSD__
|
||||
pthread_set_name_np(pthread_self(), szThreadName);
|
||||
#elif defined __HAIKU__
|
||||
rename_thread(find_thread(nullptr), szThreadName);
|
||||
#else
|
||||
// linux doesn't allow to set more than 16 bytes, including \0.
|
||||
pthread_setname_np(pthread_self(), std::string(szThreadName).substr(0, 15).c_str());
|
||||
|
Reference in New Issue
Block a user