@@ -48,17 +48,12 @@ void CHW::CreateDevice(SDL_Window *hWnd, bool move_window)
4848
4949 R_ASSERT (m_hWnd);
5050
51- // Get the device context
52- Uint32 pixelFormat = SDL_GetWindowPixelFormat (m_hWnd);
53- if (SDL_PIXELFORMAT_UNKNOWN == pixelFormat)
54- {
55- Msg (" Could not get pixel format: %s" , SDL_GetError ());
56- return ;
57- }
58-
59- // TODO Choose the closest pixel format
60-
61- // TODO Apply the pixel format to the device context
51+ // Choose the closest pixel format
52+ SDL_DisplayMode mode;
53+ SDL_GetWindowDisplayMode (m_hWnd, &mode);
54+ mode.format = SDL_PIXELFORMAT_RGBA8888;
55+ // Apply the pixel format to the device context
56+ SDL_SetWindowDisplayMode (m_hWnd, &mode);
6257
6358 // Create the context
6459 m_hRC = SDL_GL_CreateContext (m_hWnd);
@@ -77,6 +72,10 @@ void CHW::CreateDevice(SDL_Window *hWnd, bool move_window)
7772 return ;
7873 }
7974
75+ SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1 );
76+ SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 24 );
77+ SDL_GL_SetAttribute (SDL_GL_STENCIL_SIZE, 8 );
78+
8079 // Initialize OpenGL Extension Wrangler
8180 if (glewInit () != GLEW_OK)
8281 {
@@ -176,6 +175,8 @@ void CHW::updateWindowProps(SDL_Window* m_sdlWnd)
176175 }
177176 else
178177 {
178+ SDL_SetWindowPosition (m_sdlWnd, 0 , 0 );
179+ SDL_SetWindowSize (m_sdlWnd, psCurrentVidMode[0 ], psCurrentVidMode[1 ]);
179180 SDL_ShowWindow (m_sdlWnd);
180181 }
181182
@@ -299,5 +300,6 @@ void CHW::ClearDepthStencilView(GLuint pDepthStencilView, UINT ClearFlags, FLOAT
299300HRESULT CHW::Present (UINT /* SyncInterval*/ , UINT /* Flags*/ )
300301{
301302 RImplementation.Target ->phase_flip ();
302- return SwapBuffers (m_hDC) ? S_OK : E_FAIL;
303+ SDL_GL_SwapWindow (m_hWnd);
304+ return S_OK;
303305}
0 commit comments