@@ -38,6 +38,7 @@ CHW::CHW() :
3838 m_hRC(NULL ),
3939 pDevice(this ),
4040 pContext(this ),
41+ m_pSwapChain(this ),
4142 m_move_window(true ),
4243 pBaseRT(0 ),
4344 pBaseZB(0 ),
@@ -132,7 +133,7 @@ void CHW::CreateDevice( HWND hWnd, bool move_window )
132133 // Clip control ensures compatibility with D3D device coordinates.
133134 // TODO: OGL: Also use GL_UPPER_LEFT to match D3D.
134135 // TODO: OGL: Fix these differences in the blenders/shaders.
135- CHK_GL (glClipControl (GL_LOWER_LEFT , GL_ZERO_TO_ONE));
136+ CHK_GL (glClipControl (GL_UPPER_LEFT , GL_ZERO_TO_ONE));
136137
137138 // Create render target and depth-stencil views here
138139 UpdateViews ();
@@ -346,11 +347,12 @@ void CHW::UpdateViews()
346347 // Create the clear framebuffer
347348 glGenFramebuffers (1 , &pCFB);
348349
349- // Create a render target view
350- // We reserve a texture name to represent GL_BACK
350+ // Create a color render target
351351 glGenTextures (1 , &HW.pBaseRT );
352+ CHK_GL (glBindTexture (GL_TEXTURE_2D, HW.pBaseRT ));
353+ CHK_GL (glTexStorage2D (GL_TEXTURE_2D, 1 , GL_RGBA8, psCurrentVidMode[0 ], psCurrentVidMode[1 ]));
352354
353- // Create Depth /stencil buffer
355+ // Create depth /stencil buffer
354356 glGenTextures (1 , &HW.pBaseZB );
355357 CHK_GL (glBindTexture (GL_TEXTURE_2D, HW.pBaseZB ));
356358 CHK_GL (glTexStorage2D (GL_TEXTURE_2D, 1 , GL_DEPTH24_STENCIL8, psCurrentVidMode[0 ], psCurrentVidMode[1 ]));
@@ -372,6 +374,8 @@ void CHW::ClearRenderTargetView(GLuint pRenderTargetView, const FLOAT ColorRGBA[
372374 glClearColor (ColorRGBA[0 ], ColorRGBA[1 ], ColorRGBA[2 ], ColorRGBA[3 ]);
373375 CHK_GL (glClear (GL_COLOR_BUFFER_BIT));
374376 glPopAttrib ();
377+
378+ RCache.set_FB (pFB);
375379}
376380
377381void CHW::ClearDepthStencilView (GLuint pDepthStencilView, UINT ClearFlags, FLOAT Depth, UINT8 Stencil)
@@ -403,5 +407,13 @@ void CHW::ClearDepthStencilView(GLuint pDepthStencilView, UINT ClearFlags, FLOAT
403407 }
404408 CHK_GL (glClear ((ClearBufferMask)mask));
405409 glPopAttrib ();
410+
411+ RCache.set_FB (pFB);
412+ }
413+
414+ HRESULT CHW::Present (UINT SyncInterval, UINT Flags)
415+ {
416+ RImplementation.Target ->phase_flip ();
417+ return SwapBuffers (m_hDC) ? S_OK : E_FAIL;
406418}
407419#endif
0 commit comments