DXGL r90 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r89‎ | r90 | r91 >
Date:21:59, 27 January 2012
Author:admin
Status:new
Tags:
Comment:
Add lpDDSurfaceTargetOverride to Flip
Fix DDCAPS_COLORKEY bit
Modified paths:
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.h (modified) (history)

Diff [purge]

Index: ddraw/glDirectDraw.cpp
@@ -772,7 +772,7 @@
773773 else if(lpDDHELCaps) ddCaps.dwSize = lpDDHELCaps->dwSize;
774774 else ERR(DDERR_INVALIDPARAMS);
775775 ddCaps.dwCaps = DDCAPS_BLT | DDCAPS_BLTCOLORFILL | DDCAPS_BLTSTRETCH |
776 - DDCAPS_GDI | DDCAPS_PALETTE | DDCAPS_CANBLTSYSMEM;
 776+ DDCAPS_COLORKEY | DDCAPS_GDI | DDCAPS_PALETTE | DDCAPS_CANBLTSYSMEM;
777777 ddCaps.dwCaps2 = DDCAPS2_CANRENDERWINDOWED | DDCAPS2_WIDESURFACES | DDCAPS2_NOPAGELOCKREQUIRED |
778778 DDCAPS2_FLIPINTERVAL | DDCAPS2_FLIPNOVSYNC;
779779 ddCaps.dwFXCaps = DDFXCAPS_BLTSHRINKX | DDFXCAPS_BLTSHRINKY |
@@ -779,7 +779,7 @@
780780 DDFXCAPS_BLTSTRETCHX | DDFXCAPS_BLTSTRETCHY;
781781 ddCaps.dwPalCaps = DDPCAPS_8BIT | DDPCAPS_PRIMARYSURFACE;
782782 ddCaps.ddsOldCaps.dwCaps = ddCaps.ddsCaps.dwCaps =
783 - DDSCAPS_BACKBUFFER | DDSCAPS_COMPLEX | DDCAPS_COLORKEY | DDSCAPS_FLIP |
 783+ DDSCAPS_BACKBUFFER | DDSCAPS_COMPLEX | DDSCAPS_FLIP |
784784 DDSCAPS_FRONTBUFFER | DDSCAPS_OFFSCREENPLAIN | DDSCAPS_PALETTE |
785785 DDSCAPS_SYSTEMMEMORY | DDSCAPS_VIDEOMEMORY;
786786 ddCaps.dwCKeyCaps = DDCKEYCAPS_SRCBLT;
Index: ddraw/glDirectDrawSurface.cpp
@@ -579,6 +579,14 @@
580580 }
581581 HRESULT WINAPI glDirectDrawSurface7::Flip(LPDIRECTDRAWSURFACE7 lpDDSurfaceTargetOverride, DWORD dwFlags)
582582 {
 583+ HRESULT ret = Flip2(lpDDSurfaceTargetOverride,dwFlags);
 584+ if(ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) RenderScreen(texture,this);
 585+ return ret;
 586+}
 587+HRESULT glDirectDrawSurface7::Flip2(LPDIRECTDRAWSURFACE7 lpDDSurfaceTargetOverride, DWORD dwFlags)
 588+{
 589+ DWORD i;
 590+ glDirectDrawSurface7 *tmp;
583591 if(dwFlags & DDFLIP_NOVSYNC) swapinterval=0;
584592 else
585593 {
@@ -588,13 +596,34 @@
589597 else swapinterval=1;
590598 }
591599 int flips = 1;
592 - if(lpDDSurfaceTargetOverride) ERR(DDERR_GENERIC);
 600+ if(lpDDSurfaceTargetOverride)
 601+ {
 602+ bool success = false;
 603+ if(lpDDSurfaceTargetOverride == this) return DD_OK;
 604+ tmp = this;
 605+ for(i = 0; i < ddsd.dwBackBufferCount; i++)
 606+ {
 607+ tmp = tmp->GetBackbuffer();
 608+ if(lpDDSurfaceTargetOverride == tmp)
 609+ {
 610+ success = true;
 611+ i++;
 612+ break;
 613+ }
 614+ }
 615+ if(!success) return DDERR_INVALIDPARAMS;
 616+ for(DWORD x = 0; x < i; x++)
 617+ {
 618+ if(x == i-1) return Flip2(NULL,dwFlags);
 619+ else Flip2(NULL,0);
 620+ }
 621+ }
593622 if(ddsd.ddsCaps.dwCaps & DDSCAPS_FLIP)
594623 {
595624 if(ddsd.ddsCaps.dwCaps & DDSCAPS_BACKBUFFER) return DDERR_INVALIDOBJECT;
596625 GLuint *textures = new GLuint[ddsd.dwBackBufferCount+1];
597626 textures[0] = texture;
598 - glDirectDrawSurface7 *tmp = this;
 627+ tmp = this;
599628 if(dirty & 1)
600629 {
601630 renderer->UploadTexture(buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,
@@ -603,7 +632,7 @@
604633 dirty &= ~1;
605634 }
606635 this->dirty |= 2;
607 - for(DWORD i = 0; i < ddsd.dwBackBufferCount; i++)
 636+ for(i = 0; i < ddsd.dwBackBufferCount; i++)
608637 {
609638 tmp = tmp->GetBackbuffer();
610639 if(tmp->dirty & 1)
@@ -626,7 +655,6 @@
627656 tmp = tmp->GetBackbuffer();
628657 tmp->SetTexture(textures[i+1]);
629658 }
630 - RenderScreen(textures[0],this);
631659 delete textures;
632660 }
633661 else return DDERR_NOTFLIPPABLE;
@@ -1124,7 +1152,9 @@
11251153 }
11261154 HRESULT WINAPI glDirectDrawSurface1::Flip(LPDIRECTDRAWSURFACE lpDDSurfaceTargetOverride, DWORD dwFlags)
11271155 {
1128 - return glDDS7->Flip((LPDIRECTDRAWSURFACE7)lpDDSurfaceTargetOverride,dwFlags);
 1156+ if(lpDDSurfaceTargetOverride)
 1157+ return glDDS7->Flip(((glDirectDrawSurface1*)lpDDSurfaceTargetOverride)->GetDDS7(),dwFlags);
 1158+ else return glDDS7->Flip(NULL,dwFlags);
11291159 }
11301160 HRESULT WINAPI glDirectDrawSurface1::GetAttachedSurface(LPDDSCAPS lpDDSCaps, LPDIRECTDRAWSURFACE FAR *lplpDDAttachedSurface)
11311161 {
@@ -1304,7 +1334,9 @@
13051335 }
13061336 HRESULT WINAPI glDirectDrawSurface2::Flip(LPDIRECTDRAWSURFACE2 lpDDSurfaceTargetOverride, DWORD dwFlags)
13071337 {
1308 - return glDDS7->Flip((LPDIRECTDRAWSURFACE7)lpDDSurfaceTargetOverride,dwFlags);
 1338+ if(lpDDSurfaceTargetOverride)
 1339+ return glDDS7->Flip(((glDirectDrawSurface2*)lpDDSurfaceTargetOverride)->GetDDS7(),dwFlags);
 1340+ else return glDDS7->Flip(NULL,dwFlags);
13091341 }
13101342 HRESULT WINAPI glDirectDrawSurface2::GetAttachedSurface(LPDDSCAPS lpDDSCaps, LPDIRECTDRAWSURFACE2 FAR *lplpDDAttachedSurface)
13111343 {
@@ -1496,7 +1528,9 @@
14971529 }
14981530 HRESULT WINAPI glDirectDrawSurface3::Flip(LPDIRECTDRAWSURFACE3 lpDDSurfaceTargetOverride, DWORD dwFlags)
14991531 {
1500 - return glDDS7->Flip((LPDIRECTDRAWSURFACE7)lpDDSurfaceTargetOverride,dwFlags);
 1532+ if(lpDDSurfaceTargetOverride)
 1533+ return glDDS7->Flip(((glDirectDrawSurface3*)lpDDSurfaceTargetOverride)->GetDDS7(),dwFlags);
 1534+ else return glDDS7->Flip(NULL,dwFlags);
15011535 }
15021536 HRESULT WINAPI glDirectDrawSurface3::GetAttachedSurface(LPDDSCAPS lpDDSCaps, LPDIRECTDRAWSURFACE3 FAR *lplpDDAttachedSurface)
15031537 {
@@ -1692,7 +1726,9 @@
16931727 }
16941728 HRESULT WINAPI glDirectDrawSurface4::Flip(LPDIRECTDRAWSURFACE4 lpDDSurfaceTargetOverride, DWORD dwFlags)
16951729 {
1696 - return glDDS7->Flip((LPDIRECTDRAWSURFACE7)lpDDSurfaceTargetOverride,dwFlags);
 1730+ if(lpDDSurfaceTargetOverride)
 1731+ return glDDS7->Flip(((glDirectDrawSurface4*)lpDDSurfaceTargetOverride)->GetDDS7(),dwFlags);
 1732+ else return glDDS7->Flip(NULL,dwFlags);
16971733 }
16981734 HRESULT WINAPI glDirectDrawSurface4::GetAttachedSurface(LPDDSCAPS2 lpDDSCaps2, LPDIRECTDRAWSURFACE4 FAR *lplpDDAttachedSurface)
16991735 {
Index: ddraw/glDirectDrawSurface.h
@@ -97,6 +97,7 @@
9898 return texture;
9999 }
100100 void Restore2();
 101+ HRESULT Flip2(LPDIRECTDRAWSURFACE7 lpDDSurfaceTargetOverride, DWORD dwFlags);
101102 void SetTexture(GLuint newtexture){texture = newtexture;};
102103 glDirectDrawSurface7 *GetBackbuffer(){return backbuffer;};
103104 glDirectDrawSurface7 *GetZBuffer(){return zbuffer;};