@@ -177,6 +177,7 @@ void CHW::Reset (HWND hwnd)
177
177
178
178
CHK_GL (glDeleteProgramPipelines (1 , &pPP));
179
179
CHK_GL (glDeleteFramebuffers (1 , &pFB));
180
+ CHK_GL (glDeleteFramebuffers (1 , &pCFB));
180
181
181
182
CHK_GL (glDeleteTextures (1 , &pBaseRT));
182
183
CHK_GL (glDeleteTextures (1 , &pBaseZB));
@@ -337,10 +338,13 @@ void CHW::UpdateViews()
337
338
glGenProgramPipelines (1 , &pPP);
338
339
CHK_GL (glBindProgramPipeline (pPP));
339
340
340
- // Create the framebuffer
341
+ // Create the default framebuffer
341
342
glGenFramebuffers (1 , &pFB);
342
343
CHK_GL (glBindFramebuffer (GL_FRAMEBUFFER, pFB));
343
344
345
+ // Create the clear framebuffer
346
+ glGenFramebuffers (1 , &pCFB);
347
+
344
348
// Create a render target view
345
349
// We reserve a texture name to represent GL_BACK
346
350
glGenTextures (1 , &HW.pBaseRT );
@@ -354,7 +358,14 @@ void CHW::UpdateViews()
354
358
355
359
void CHW::ClearRenderTargetView (GLuint pRenderTargetView, const FLOAT ColorRGBA[4 ])
356
360
{
357
- // TODO: OGL: Bind the RT to a clear frame buffer.
361
+ if (pRenderTargetView == 0 )
362
+ return ;
363
+
364
+ // Bind the clear framebuffer and attach the render target
365
+ RCache.set_FB (pCFB);
366
+ CHK_GL (glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pRenderTargetView, 0 ));
367
+
368
+ // Clear the color buffer without affecting the global state
358
369
glPushAttrib (GL_COLOR_BUFFER_BIT);
359
370
glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
360
371
glClearColor (ColorRGBA[0 ], ColorRGBA[1 ], ColorRGBA[2 ], ColorRGBA[3 ]);
@@ -364,7 +375,13 @@ void CHW::ClearRenderTargetView(GLuint pRenderTargetView, const FLOAT ColorRGBA[
364
375
365
376
void CHW::ClearDepthStencilView (GLuint pDepthStencilView, UINT ClearFlags, FLOAT Depth, UINT8 Stencil)
366
377
{
367
- // TODO: OGL: Bind the DS to a clear frame buffer.
378
+ if (pDepthStencilView == 0 )
379
+ return ;
380
+
381
+ // Bind the clear framebuffer and attach the render target
382
+ RCache.set_FB (pCFB);
383
+ CHK_GL (glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, pDepthStencilView, 0 ));
384
+
368
385
u32 mask = 0 ;
369
386
if (ClearFlags & D3D_CLEAR_DEPTH)
370
387
mask |= (u32 )GL_DEPTH_BUFFER_BIT;
0 commit comments