mirror of
https://github.com/jpd002/Play-.git
synced 2025-04-28 13:47:57 +03:00

Some checks failed
Build macOS / build_macos (push) Has been cancelled
Build Android / build_android (apk) (push) Has been cancelled
Build Android / build_android (libretro) (push) Has been cancelled
Build Linux ARM32 / build_linux_arm32 (push) Has been cancelled
Build Linux ARM64 / build_linux_arm64 (push) Has been cancelled
Build Windows Psf / build_windows_psf (off, x86_64, Visual Studio 16 2019, installer64.nsi, x64) (push) Has been cancelled
Build Windows Psf / build_windows_psf (on, x86_64, Visual Studio 16 2019, installer64.nsi, x64) (push) Has been cancelled
Build Windows / build_windows (x86_32, Visual Studio 16 2019, installer32.nsi, win32_msvc2019, Win32) (push) Has been cancelled
Build Windows / build_windows (x86_64, Visual Studio 16 2019, installer64.nsi, win64_msvc2019_64, x64) (push) Has been cancelled
Check Format / run_clangformat (push) Has been cancelled
Build iOS / build_ios (push) Has been cancelled
Build JavaScript / build_js (push) Has been cancelled
Build Linux / build_linux (push) Has been cancelled
95 lines
2.3 KiB
C++
95 lines
2.3 KiB
C++
#include <cassert>
|
|
#include "opengl/OpenGlDef.h"
|
|
#include "GSH_OpenGLAndroid.h"
|
|
#include "AppConfig.h"
|
|
|
|
CGSH_OpenGLAndroid::CGSH_OpenGLAndroid(NativeWindowType window)
|
|
: m_window(window)
|
|
{
|
|
//We'll probably need to keep 'window' as a Global JNI object
|
|
}
|
|
|
|
CGSH_OpenGLAndroid::~CGSH_OpenGLAndroid()
|
|
{
|
|
}
|
|
|
|
CGSHandler::FactoryFunction CGSH_OpenGLAndroid::GetFactoryFunction(NativeWindowType window)
|
|
{
|
|
return [window]() { return new CGSH_OpenGLAndroid(window); };
|
|
}
|
|
|
|
void CGSH_OpenGLAndroid::InitializeImpl()
|
|
{
|
|
static const EGLint configAttribs[] =
|
|
{
|
|
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
|
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
|
EGL_BLUE_SIZE, 8,
|
|
EGL_GREEN_SIZE, 8,
|
|
EGL_RED_SIZE, 8,
|
|
EGL_NONE};
|
|
|
|
static const EGLint contextAttribs[] =
|
|
{
|
|
EGL_CONTEXT_CLIENT_VERSION, 3,
|
|
EGL_NONE};
|
|
|
|
m_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
|
eglInitialize(m_display, 0, 0);
|
|
|
|
EGLint numConfigs = 0;
|
|
eglChooseConfig(m_display, configAttribs, &m_config, 1, &numConfigs);
|
|
assert(numConfigs > 0);
|
|
|
|
m_context = eglCreateContext(m_display, m_config, NULL, contextAttribs);
|
|
assert(m_context != EGL_NO_CONTEXT);
|
|
|
|
SetupContext();
|
|
|
|
CGSH_OpenGL::InitializeImpl();
|
|
}
|
|
|
|
void CGSH_OpenGLAndroid::PresentBackbuffer()
|
|
{
|
|
eglSwapBuffers(m_display, m_surface);
|
|
}
|
|
|
|
void CGSH_OpenGLAndroid::SetWindow(NativeWindowType window)
|
|
{
|
|
m_window = window;
|
|
SendGSCall(
|
|
[this]() {
|
|
SetupContext();
|
|
},
|
|
true);
|
|
}
|
|
|
|
void CGSH_OpenGLAndroid::SetupContext()
|
|
{
|
|
if(m_surface != EGL_NO_SURFACE)
|
|
{
|
|
eglDestroySurface(m_display, m_surface);
|
|
m_surface = EGL_NO_SURFACE;
|
|
}
|
|
|
|
m_surface = eglCreateWindowSurface(m_display, m_config, m_window, NULL);
|
|
assert(m_surface != EGL_NO_SURFACE);
|
|
|
|
auto makeCurrentResult = eglMakeCurrent(m_display, m_surface, m_surface, m_context);
|
|
assert(makeCurrentResult != EGL_FALSE);
|
|
|
|
{
|
|
GLint w = 0, h = 0;
|
|
eglQuerySurface(m_display, m_surface, EGL_WIDTH, &w);
|
|
eglQuerySurface(m_display, m_surface, EGL_HEIGHT, &h);
|
|
|
|
PRESENTATION_PARAMS presentationParams;
|
|
presentationParams.mode = static_cast<CGSHandler::PRESENTATION_MODE>(CAppConfig::GetInstance().GetPreferenceInteger(PREF_CGSHANDLER_PRESENTATION_MODE));
|
|
presentationParams.windowWidth = w;
|
|
presentationParams.windowHeight = h;
|
|
|
|
SetPresentationParams(presentationParams);
|
|
}
|
|
|
|
eglSwapInterval(m_display, 0);
|
|
}
|