mirror of
https://github.com/jpd002/Play-.git
synced 2025-04-28 21:57:57 +03:00
49 lines
928 B
C++
49 lines
928 B
C++
![]() |
#include "GSH_OpenGLQt.h"
|
||
|
#include <QWindow>
|
||
|
#include <QOpenGLContext>
|
||
|
|
||
|
CGSH_OpenGLQt::CGSH_OpenGLQt(QWindow* renderWindow)
|
||
|
: m_renderWindow(renderWindow)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
CGSH_OpenGLQt::~CGSH_OpenGLQt()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
CGSH_OpenGL::FactoryFunction CGSH_OpenGLQt::GetFactoryFunction(QWindow* renderWindow)
|
||
|
{
|
||
|
return [renderWindow] () { return new CGSH_OpenGLQt(renderWindow); };
|
||
|
}
|
||
|
|
||
|
void CGSH_OpenGLQt::InitializeImpl()
|
||
|
{
|
||
|
m_context = new QOpenGLContext();
|
||
|
m_context->setFormat(m_renderWindow->requestedFormat());
|
||
|
|
||
|
bool succeeded = m_context->create();
|
||
|
Q_ASSERT(succeeded);
|
||
|
|
||
|
succeeded = m_context->makeCurrent(m_renderWindow);
|
||
|
Q_ASSERT(succeeded);
|
||
|
|
||
|
auto result = glewInit();
|
||
|
Q_ASSERT(result == GLEW_OK);
|
||
|
|
||
|
CGSH_OpenGL::InitializeImpl();
|
||
|
}
|
||
|
|
||
|
void CGSH_OpenGLQt::ReleaseImpl()
|
||
|
{
|
||
|
CGSH_OpenGL::ReleaseImpl();
|
||
|
|
||
|
delete m_context;
|
||
|
}
|
||
|
|
||
|
void CGSH_OpenGLQt::PresentBackbuffer()
|
||
|
{
|
||
|
m_context->swapBuffers(m_renderWindow);
|
||
|
}
|