diff --git a/src/Layers/xrRenderGL/glHW.cpp b/src/Layers/xrRenderGL/glHW.cpp index aa02fd50d92..9c5f215a529 100644 --- a/src/Layers/xrRenderGL/glHW.cpp +++ b/src/Layers/xrRenderGL/glHW.cpp @@ -48,17 +48,12 @@ void CHW::CreateDevice(SDL_Window *hWnd, bool move_window) R_ASSERT(m_hWnd); - // Get the device context - Uint32 pixelFormat = SDL_GetWindowPixelFormat(m_hWnd); - if (SDL_PIXELFORMAT_UNKNOWN == pixelFormat) - { - Msg("Could not get pixel format: %s", SDL_GetError()); - return; - } - - //TODO Choose the closest pixel format - - //TODO Apply the pixel format to the device context + //Choose the closest pixel format + SDL_DisplayMode mode; + SDL_GetWindowDisplayMode(m_hWnd, &mode); + mode.format = SDL_PIXELFORMAT_RGBA8888; + // Apply the pixel format to the device context + SDL_SetWindowDisplayMode(m_hWnd, &mode); // Create the context m_hRC = SDL_GL_CreateContext(m_hWnd); @@ -77,6 +72,10 @@ void CHW::CreateDevice(SDL_Window *hWnd, bool move_window) return; } + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); + SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); + // Initialize OpenGL Extension Wrangler if (glewInit() != GLEW_OK) { @@ -176,6 +175,8 @@ void CHW::updateWindowProps(SDL_Window* m_sdlWnd) } else { + SDL_SetWindowPosition(m_sdlWnd, 0, 0); + SDL_SetWindowSize(m_sdlWnd, psCurrentVidMode[0], psCurrentVidMode[1]); SDL_ShowWindow(m_sdlWnd); } @@ -299,5 +300,6 @@ void CHW::ClearDepthStencilView(GLuint pDepthStencilView, UINT ClearFlags, FLOAT HRESULT CHW::Present(UINT /*SyncInterval*/, UINT /*Flags*/) { RImplementation.Target->phase_flip(); - return SwapBuffers(m_hDC) ? S_OK : E_FAIL; + SDL_GL_SwapWindow(m_hWnd); + return S_OK; } diff --git a/src/Layers/xrRenderPC_GL/stdafx.h b/src/Layers/xrRenderPC_GL/stdafx.h index 4dad96261a7..a1379cf097b 100644 --- a/src/Layers/xrRenderPC_GL/stdafx.h +++ b/src/Layers/xrRenderPC_GL/stdafx.h @@ -13,11 +13,6 @@ #include "SDL_opengl.h" #include #include "SDL_opengl_glext.h" -#if defined(WINDOWS) -#include -#elif defined(LINUX) -#include -#endif #include "Layers/xrRender/xrD3DDefs.h" #include "Layers/xrRender/Debug/dxPixEventWrapper.h"