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
83 lines
2.1 KiB
C++
83 lines
2.1 KiB
C++
#include <cassert>
|
|
#include "opengl/OpenGlDef.h"
|
|
#include "GSH_OpenGLiOS.h"
|
|
|
|
CGSH_OpenGLiOS::CGSH_OpenGLiOS(CAEAGLLayer* layer)
|
|
: m_layer(layer)
|
|
{
|
|
}
|
|
|
|
CGSH_OpenGLiOS::~CGSH_OpenGLiOS()
|
|
{
|
|
}
|
|
|
|
CGSHandler::FactoryFunction CGSH_OpenGLiOS::GetFactoryFunction(CAEAGLLayer* layer)
|
|
{
|
|
return [layer]() { return new CGSH_OpenGLiOS(layer); };
|
|
}
|
|
|
|
void CGSH_OpenGLiOS::InitializeImpl()
|
|
{
|
|
m_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
|
|
|
|
if(!m_context)
|
|
{
|
|
NSLog(@"Failed to create ES context");
|
|
return;
|
|
}
|
|
|
|
if(![EAGLContext setCurrentContext:m_context])
|
|
{
|
|
NSLog(@"Failed to set ES context current");
|
|
return;
|
|
}
|
|
|
|
CreateFramebuffer();
|
|
|
|
{
|
|
PRESENTATION_PARAMS presentationParams;
|
|
presentationParams.mode = PRESENTATION_MODE_FIT;
|
|
presentationParams.windowWidth = m_framebufferWidth;
|
|
presentationParams.windowHeight = m_framebufferHeight;
|
|
|
|
SetPresentationParams(presentationParams);
|
|
}
|
|
|
|
CGSH_OpenGL::InitializeImpl();
|
|
}
|
|
|
|
void CGSH_OpenGLiOS::PresentBackbuffer()
|
|
{
|
|
glBindRenderbuffer(GL_RENDERBUFFER, m_colorRenderbuffer);
|
|
CHECKGLERROR();
|
|
|
|
BOOL success = [m_context presentRenderbuffer:GL_RENDERBUFFER];
|
|
assert(success == YES);
|
|
}
|
|
|
|
void CGSH_OpenGLiOS::CreateFramebuffer()
|
|
{
|
|
assert(m_defaultFramebuffer == 0);
|
|
|
|
glGenFramebuffers(1, &m_defaultFramebuffer);
|
|
glBindFramebuffer(GL_FRAMEBUFFER, m_defaultFramebuffer);
|
|
|
|
// Create color render buffer and allocate backing store.
|
|
glGenRenderbuffers(1, &m_colorRenderbuffer);
|
|
glBindRenderbuffer(GL_RENDERBUFFER, m_colorRenderbuffer);
|
|
[m_context renderbufferStorage:GL_RENDERBUFFER fromDrawable:m_layer];
|
|
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &m_framebufferWidth);
|
|
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &m_framebufferHeight);
|
|
|
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_colorRenderbuffer);
|
|
|
|
CHECKGLERROR();
|
|
|
|
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
|
{
|
|
NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatus(GL_FRAMEBUFFER));
|
|
assert(false);
|
|
}
|
|
|
|
m_presentFramebuffer = m_defaultFramebuffer;
|
|
}
|