DXGL r933 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r932‎ | r933 | r934 >
Date:21:52, 9 August 2019
Author:admin
Status:new
Tags:
Comment:
Another tweak to overlays, still not working.
Modified paths:
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirectDrawSurface.cpp
@@ -1976,6 +1976,12 @@
19771977 if (overlay->flags & DDOVER_HIDE) overlays[i].enabled = FALSE;
19781978 memcpy(&overlays[i], overlay, sizeof(OVERLAY));
19791979 glTexture_AddRef(overlays[i].texture);
 1980+ if (ddInterface->lastsync)
 1981+ {
 1982+ RenderScreen(ddInterface->primary->texture, 1, NULL, TRUE, overlays, overlaycount);
 1983+ ddInterface->lastsync = false;
 1984+ }
 1985+ else RenderScreen(ddInterface->primary->texture, 0, NULL, TRUE, overlays, overlaycount);
19801986 return DD_OK;
19811987 }
19821988 }
Index: ddraw/glRenderer.cpp
@@ -3631,6 +3631,7 @@
36323632 ddsd.lPitch = x2 * 4;
36333633 ddsd.dwHeight = y2;
36343634 glTexture_Create(&ddsd, &This->backbuffers[index], This, x2, y2, FALSE, TRUE, 0);
 3635+ glUtil_InitFBO(This->util, &This->backbuffers[index]->levels[0].fbo);
36353636 }
36363637 if((This->backbuffers[index]->levels[0].ddsd.dwWidth != x2) || (This->backbuffers[index]->levels[0].ddsd.dwHeight != y2))
36373638 {
@@ -3641,32 +3642,35 @@
36423643 ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT;
36433644 glTexture__SetSurfaceDesc(This->backbuffers[index], &ddsd);
36443645 }
3645 - glUtil_SetFBOTextures(This->util,&This->fbo,This->backbuffers[index],NULL,0,0,FALSE);
3646 - view[0] = view[2] = 0;
3647 - view[1] = (GLfloat)x2;
3648 - view[3] = (GLfloat)y2;
3649 - glUtil_SetViewport(This->util,0,0,x2,y2);
3650 - glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
3651 - glUtil_SetTexture(This->util,8,*texture);
3652 - *texture = This->backbuffers[index];
3653 - if (!paletted && firstpass && (dxglcfg.postfilter == 1))
3654 - glTexture__SetFilter(*texture, 8, GL_LINEAR, GL_LINEAR, This);
3655 - else glTexture__SetFilter(*texture, 8, GL_NEAREST, GL_NEAREST, This);
3656 - This->ext->glUniform1i(This->shaders->shaders[progtype].tex0, 8);
3657 - This->ext->glUniform4f(This->shaders->shaders[progtype].view,view[0],view[1],view[2],view[3]);
3658 - This->bltvertices[0].s = This->bltvertices[0].t = This->bltvertices[1].t = This->bltvertices[2].s = 1.;
3659 - This->bltvertices[1].s = This->bltvertices[2].t = This->bltvertices[3].s = This->bltvertices[3].t = 0.;
3660 - This->bltvertices[0].y = This->bltvertices[1].y = This->bltvertices[1].x = This->bltvertices[3].x = 0.;
3661 - This->bltvertices[0].x = This->bltvertices[2].x = (float)x2;
3662 - This->bltvertices[2].y = This->bltvertices[3].y = (float)y2;
3663 - glUtil_EnableArray(This->util,This->shaders->shaders[progtype].pos,TRUE);
3664 - This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].pos,2,GL_FLOAT,GL_FALSE,sizeof(BltVertex),&This->bltvertices[0].x);
3665 - glUtil_EnableArray(This->util,This->shaders->shaders[progtype].texcoord,TRUE);
3666 - This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].texcoord,2,GL_FLOAT,GL_FALSE,sizeof(BltVertex),&This->bltvertices[0].s);
3667 - glUtil_SetCull(This->util,D3DCULL_NONE);
3668 - glUtil_SetPolyMode(This->util,D3DFILL_SOLID);
3669 - This->ext->glDrawRangeElements(GL_TRIANGLE_STRIP,0,3,4,GL_UNSIGNED_SHORT,bltindices);
3670 - glUtil_SetFBO(This->util, NULL);
 3646+ if (texture)
 3647+ {
 3648+ glUtil_SetFBOTextures(This->util, &This->fbo, This->backbuffers[index], NULL, 0, 0, FALSE);
 3649+ view[0] = view[2] = 0;
 3650+ view[1] = (GLfloat)x2;
 3651+ view[3] = (GLfloat)y2;
 3652+ glUtil_SetViewport(This->util, 0, 0, x2, y2);
 3653+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 3654+ glUtil_SetTexture(This->util, 8, *texture);
 3655+ *texture = This->backbuffers[index];
 3656+ if (!paletted && firstpass && (dxglcfg.postfilter == 1))
 3657+ glTexture__SetFilter(*texture, 8, GL_LINEAR, GL_LINEAR, This);
 3658+ else glTexture__SetFilter(*texture, 8, GL_NEAREST, GL_NEAREST, This);
 3659+ This->ext->glUniform1i(This->shaders->shaders[progtype].tex0, 8);
 3660+ This->ext->glUniform4f(This->shaders->shaders[progtype].view, view[0], view[1], view[2], view[3]);
 3661+ This->bltvertices[0].s = This->bltvertices[0].t = This->bltvertices[1].t = This->bltvertices[2].s = 1.;
 3662+ This->bltvertices[1].s = This->bltvertices[2].t = This->bltvertices[3].s = This->bltvertices[3].t = 0.;
 3663+ This->bltvertices[0].y = This->bltvertices[1].y = This->bltvertices[1].x = This->bltvertices[3].x = 0.;
 3664+ This->bltvertices[0].x = This->bltvertices[2].x = (float)x2;
 3665+ This->bltvertices[2].y = This->bltvertices[3].y = (float)y2;
 3666+ glUtil_EnableArray(This->util, This->shaders->shaders[progtype].pos, TRUE);
 3667+ This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].pos, 2, GL_FLOAT, GL_FALSE, sizeof(BltVertex), &This->bltvertices[0].x);
 3668+ glUtil_EnableArray(This->util, This->shaders->shaders[progtype].texcoord, TRUE);
 3669+ This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].texcoord, 2, GL_FLOAT, GL_FALSE, sizeof(BltVertex), &This->bltvertices[0].s);
 3670+ glUtil_SetCull(This->util, D3DCULL_NONE);
 3671+ glUtil_SetPolyMode(This->util, D3DFILL_SOLID);
 3672+ This->ext->glDrawRangeElements(GL_TRIANGLE_STRIP, 0, 3, 4, GL_UNSIGNED_SHORT, bltindices);
 3673+ glUtil_SetFBO(This->util, NULL);
 3674+ }
36713675 }
36723676
36733677 void glRenderer__DrawBackbufferRect(glRenderer *This, glTexture *texture, RECT srcrect, RECT destrect, int progtype, int index)
@@ -4072,7 +4076,12 @@
40734077 view[2] = 0;
40744078 view[3] = (GLfloat)texture->bigheight;
40754079 }
4076 - glUtil_SetFBO(This->util, NULL);
 4080+ if (This->overlays)
 4081+ {
 4082+ glRenderer__DrawBackbuffer(This, NULL, viewport[2], viewport[3], 0, FALSE, FALSE, 1);
 4083+ glUtil_SetFBOTexture(This->util, &This->backbuffers[1]->levels[0].fbo, This->backbuffers[1], NULL, 0, 0, FALSE);
 4084+ }
 4085+ else glUtil_SetFBO(This->util, NULL);
40774086 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
40784087 if(This->ddInterface->GetBPP() == 8)
40794088 {
@@ -4182,8 +4191,20 @@
41834192 glRenderer__Blt(This, &bltcmd, TRUE);
41844193 }
41854194 }
 4195+ glUtil_SetFBO(This->util, NULL);
 4196+ ShaderManager_SetShader(This->shaders, PROG_TEXTURE, NULL, 0);
 4197+ progtype = PROG_TEXTURE;
 4198+ glUtil_SetTexture(This->util, 8, texture);
 4199+ This->ext->glUniform1i(This->shaders->shaders[progtype].tex0, 8);
 4200+ glUtil_EnableArray(This->util, This->shaders->shaders[progtype].pos, TRUE);
 4201+ This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].pos, 2, GL_FLOAT, GL_FALSE, sizeof(BltVertex), &This->bltvertices[0].x);
 4202+ glUtil_EnableArray(This->util, This->shaders->shaders[progtype].texcoord, TRUE);
 4203+ This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].texcoord, 2, GL_FLOAT, GL_FALSE, sizeof(BltVertex), &This->bltvertices[0].s);
 4204+ glUtil_SetCull(This->util, D3DCULL_NONE);
 4205+ glUtil_SetPolyMode(This->util, D3DFILL_SOLID);
 4206+ This->ext->glDrawRangeElements(GL_TRIANGLE_STRIP, 0, 3, 4, GL_UNSIGNED_SHORT, bltindices);
41864207 }
4187 - glFlush();
 4208+ if(dxglcfg.SingleBufferDevice) glFlush();
41884209 if(This->hWnd) SwapBuffers(This->hDC);
41894210 else
41904211 {