5#include <alicorn/platform/winapi-check.hpp>
8#pragma comment(lib, "opengl32.lib")
53static PIXELFORMATDESCRIPTOR PixelFormatDescriptor = { 0 };
55OpenGL::OpenGL(
const Data_t & _Data) :
56 OpenGLCommonShader(_Data, uT(
"OpenGL "),
57 "#version 330 core\r\n"
58 "#define COVELLITE_SHADER_DESKTOP\r\n"),
59 m_hWnd(::covellite::any_cast<HWND>(_Data.Handle)),
60 m_hDeviceContex(USING_MOCK ::GetDC(m_hWnd))
62 WINAPI_CHECK (m_hDeviceContex != NULL);
64 PixelFormatDescriptor.nSize =
sizeof(PIXELFORMATDESCRIPTOR);
65 PixelFormatDescriptor.nVersion = 1;
66 PixelFormatDescriptor.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
67 PixelFormatDescriptor.iPixelType = PFD_TYPE_RGBA;
68 PixelFormatDescriptor.cColorBits = 32;
69 PixelFormatDescriptor.cAlphaBits = 8;
70 PixelFormatDescriptor.cDepthBits = 32;
71 PixelFormatDescriptor.iLayerType = PFD_MAIN_PLANE;
77# pragma warning(disable: 6387)
79 const auto PixelFormat = USING_MOCK ::ChoosePixelFormat(m_hDeviceContex,
80 &PixelFormatDescriptor);
81 WINAPI_CHECK (PixelFormat != 0);
83 WINAPI_CHECK USING_MOCK ::SetPixelFormat(m_hDeviceContex, PixelFormat,
84 &PixelFormatDescriptor);
88 m_hRenderContex = USING_MOCK ::wglCreateContext(m_hDeviceContex);
89 WINAPI_CHECK (m_hRenderContex != NULL);
91 WINAPI_CHECK USING_MOCK ::wglMakeCurrent(m_hDeviceContex, m_hRenderContex);
98OpenGL::~OpenGL(
void)
noexcept
100 USING_MOCK ::wglMakeCurrent(NULL, NULL);
101 USING_MOCK ::wglDeleteContext(m_hRenderContex);
103 USING_MOCK ::ReleaseDC(m_hWnd, m_hDeviceContex);
106void OpenGL::PresentFrame(
void)
108 WINAPI_CHECK USING_MOCK ::SwapBuffers(m_hDeviceContex);
110 OpenGLCommonShader::PresentFrame();