mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 23:55:40 +00:00
GLContext: Fix Android context creation
This commit is contained in:
parent
da180a1c4f
commit
729e1b3392
|
@ -135,7 +135,7 @@ if(USE_EGL)
|
||||||
)
|
)
|
||||||
target_compile_definitions(common PRIVATE "-DUSE_EGL=1")
|
target_compile_definitions(common PRIVATE "-DUSE_EGL=1")
|
||||||
|
|
||||||
if(SUPPORTS_X11)
|
if(USE_X11)
|
||||||
target_sources(common PRIVATE
|
target_sources(common PRIVATE
|
||||||
gl/context_egl_x11.cpp
|
gl/context_egl_x11.cpp
|
||||||
gl/context_egl_x11.h
|
gl/context_egl_x11.h
|
||||||
|
|
|
@ -74,6 +74,8 @@ std::unique_ptr<GL::Context> Context::Create(const WindowInfo& wi, const Version
|
||||||
context = ContextWGL::Create(wi, versions_to_try, num_versions_to_try);
|
context = ContextWGL::Create(wi, versions_to_try, num_versions_to_try);
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
context = ContextAGL::Create(wi, versions_to_try, num_versions_to_try);
|
context = ContextAGL::Create(wi, versions_to_try, num_versions_to_try);
|
||||||
|
#elif defined(ANDROID)
|
||||||
|
context = ContextEGLAndroid::Create(wi, versions_to_try, num_versions_to_try);
|
||||||
#else
|
#else
|
||||||
if (wi.type == WindowInfo::Type::X11)
|
if (wi.type == WindowInfo::Type::X11)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
#include "glad_egl.h"
|
#include "glad_egl.h"
|
||||||
#include "x11_window.h"
|
|
||||||
|
|
||||||
namespace GL {
|
namespace GL {
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
#include "context_egl_android.h"
|
#include "context_egl_android.h"
|
||||||
#include "../log.h"
|
#include "../log.h"
|
||||||
|
#include <android/native_window.h>
|
||||||
Log_SetChannel(GL::ContextEGLAndroid);
|
Log_SetChannel(GL::ContextEGLAndroid);
|
||||||
|
|
||||||
namespace GL {
|
namespace GL {
|
||||||
ContextEGLX11::ContextEGLAndroid(const WindowInfo& wi) : ContextEGL(wi) {}
|
ContextEGLAndroid::ContextEGLAndroid(const WindowInfo& wi) : ContextEGL(wi) {}
|
||||||
ContextEGLX11::~ContextEGLAndroid() = default;
|
ContextEGLAndroid::~ContextEGLAndroid() = default;
|
||||||
|
|
||||||
std::unique_ptr<Context> ContextEGLAndroid::Create(const WindowInfo& wi, const Version* versions_to_try,
|
std::unique_ptr<Context> ContextEGLAndroid::Create(const WindowInfo& wi, const Version* versions_to_try,
|
||||||
size_t num_versions_to_try)
|
size_t num_versions_to_try)
|
||||||
|
@ -29,16 +30,16 @@ std::unique_ptr<Context> ContextEGLAndroid::CreateSharedContext(const WindowInfo
|
||||||
|
|
||||||
EGLNativeWindowType ContextEGLAndroid::GetNativeWindow(EGLConfig config)
|
EGLNativeWindowType ContextEGLAndroid::GetNativeWindow(EGLConfig config)
|
||||||
{
|
{
|
||||||
X11InhibitErrors ei;
|
|
||||||
|
|
||||||
EGLint native_visual_id = 0;
|
EGLint native_visual_id = 0;
|
||||||
if (!eglGetConfigAttrib(m_display, m_config, EGL_NATIVE_VISUAL_ID, &native_visual_id))
|
if (!eglGetConfigAttrib(m_display, m_config, EGL_NATIVE_VISUAL_ID, &native_visual_id))
|
||||||
{
|
{
|
||||||
Log_ErrorPrintf("Failed to get X11 visual ID");
|
Log_ErrorPrintf("Failed to get native visual ID");
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ANativeWindow_setBuffersGeometry(static_cast<ANativeWindow*>(m_wi.window_handle), 0, 0, static_cast<int32_t>(native_visual_id));
|
ANativeWindow_setBuffersGeometry(static_cast<ANativeWindow*>(m_wi.window_handle), 0, 0, static_cast<int32_t>(native_visual_id));
|
||||||
|
m_wi.surface_width = ANativeWindow_getWidth(static_cast<ANativeWindow*>(m_wi.window_handle));
|
||||||
|
m_wi.surface_height = ANativeWindow_getHeight(static_cast<ANativeWindow*>(m_wi.window_handle));
|
||||||
return static_cast<EGLNativeWindowType>(m_wi.window_handle);
|
return static_cast<EGLNativeWindowType>(m_wi.window_handle);
|
||||||
}
|
}
|
||||||
} // namespace GL
|
} // namespace GL
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "context_egl.h"
|
#include "context_egl.h"
|
||||||
#include "x11_window.h"
|
|
||||||
|
|
||||||
namespace GL {
|
namespace GL {
|
||||||
|
|
||||||
|
@ -17,11 +16,6 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EGLNativeWindowType GetNativeWindow(EGLConfig config) override;
|
EGLNativeWindowType GetNativeWindow(EGLConfig config) override;
|
||||||
|
|
||||||
private:
|
|
||||||
ALWAYS_INLINE Display* GetDisplay() const { return static_cast<Display*>(m_wi.display_connection); }
|
|
||||||
|
|
||||||
X11Window m_window;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace GL
|
} // namespace GL
|
||||||
|
|
Loading…
Reference in a new issue