diff options
| author | Matthew Parlane <parlane@gmail.com> | 2017-03-28 17:19:35 +1300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-03-28 17:19:35 +1300 |
| commit | 85d74a506f6e4024ae1ffdf857d68ebed96fa4a9 (patch) | |
| tree | 615c4104ef8ab87cdc6267b9f856140eab025aa8 /Source/Core/Common/GL/GLInterface | |
| parent | 8c23888968cbc8b513c5b45df5014213ba356bc1 (diff) | |
| parent | 0831dad467374f11256b5e63ca66b9dff5bf2463 (diff) | |
Merge pull request #4951 from waddlesplash/haiku-2
Initial support for Haiku.
Diffstat (limited to 'Source/Core/Common/GL/GLInterface')
| -rw-r--r-- | Source/Core/Common/GL/GLInterface/BGL.cpp | 70 | ||||
| -rw-r--r-- | Source/Core/Common/GL/GLInterface/BGL.h | 27 | ||||
| -rw-r--r-- | Source/Core/Common/GL/GLInterface/EGLHaiku.cpp | 30 | ||||
| -rw-r--r-- | Source/Core/Common/GL/GLInterface/EGLHaiku.h | 16 | ||||
| -rw-r--r-- | Source/Core/Common/GL/GLInterface/GLInterface.cpp | 4 |
5 files changed, 147 insertions, 0 deletions
diff --git a/Source/Core/Common/GL/GLInterface/BGL.cpp b/Source/Core/Common/GL/GLInterface/BGL.cpp new file mode 100644 index 0000000000..7cc9070a49 --- /dev/null +++ b/Source/Core/Common/GL/GLInterface/BGL.cpp @@ -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()); +} diff --git a/Source/Core/Common/GL/GLInterface/BGL.h b/Source/Core/Common/GL/GLInterface/BGL.h new file mode 100644 index 0000000000..aeb678f804 --- /dev/null +++ b/Source/Core/Common/GL/GLInterface/BGL.h @@ -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; +}; diff --git a/Source/Core/Common/GL/GLInterface/EGLHaiku.cpp b/Source/Core/Common/GL/GLInterface/EGLHaiku.cpp new file mode 100644 index 0000000000..253b9c8c98 --- /dev/null +++ b/Source/Core/Common/GL/GLInterface/EGLHaiku.cpp @@ -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() +{ +} diff --git a/Source/Core/Common/GL/GLInterface/EGLHaiku.h b/Source/Core/Common/GL/GLInterface/EGLHaiku.h new file mode 100644 index 0000000000..fc755963df --- /dev/null +++ b/Source/Core/Common/GL/GLInterface/EGLHaiku.h @@ -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; +}; diff --git a/Source/Core/Common/GL/GLInterface/GLInterface.cpp b/Source/Core/Common/GL/GLInterface/GLInterface.cpp index e134544311..edd84cc2ab 100644 --- a/Source/Core/Common/GL/GLInterface/GLInterface.cpp +++ b/Source/Core/Common/GL/GLInterface/GLInterface.cpp @@ -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 |
