Skip to content

Commit

Permalink
Remove TransparentBlt test
Browse files Browse the repository at this point in the history
Apparently it doesn't support black as the transparency color on some computers?
  • Loading branch information
periwinkle9 committed Jul 27, 2023
1 parent dad13f2 commit a336462
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
4 changes: 2 additions & 2 deletions DDrawTransparencyTest.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>winmm.lib;ddraw.lib;msimg32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>winmm.lib;ddraw.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand All @@ -112,7 +112,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>false</GenerateDebugInformation>
<AdditionalDependencies>winmm.lib;ddraw.lib;msimg32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>winmm.lib;ddraw.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand Down
23 changes: 14 additions & 9 deletions draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,8 @@ class Roach
{
RECT rcSet = {x, y, x + 72, y + 72};
RECT rcWork = rect[ani_no];

// Let's try overriding the color key?
DDBLTFX bltfx;
memset(&bltfx, 0, sizeof bltfx); // Also sets color key to 0x00000000
bltfx.dwSize = sizeof bltfx;
backbuffer->Blt(&rcSet, surf, &rcWork, DDBLT_KEYSRCOVERRIDE | DDBLT_WAIT, &bltfx);

backbuffer->Blt(&rcSet, surf, &rcWork, DDBLT_KEYSRC | DDBLT_WAIT, NULL);
}
};

Expand Down Expand Up @@ -251,11 +247,20 @@ class Frog
}
}
}
void draw(int x, int y, LPDIRECTDRAWSURFACE surf) const
void draw(int x, int y, LPDIRECTDRAWSURFACE surf, bool overrideColorKey = false) const
{
RECT rcSet = {x, y, x + 96, y + 96};
RECT rcWork = facingRight ? rcRight[ani_no] : rcLeft[ani_no];
backbuffer->Blt(&rcSet, surf, &rcWork, DDBLT_KEYSRC | DDBLT_WAIT, NULL);

if (overrideColorKey)
{
DDBLTFX bltfx;
memset(&bltfx, 0, sizeof bltfx); // Also sets color key to 0x00000000
bltfx.dwSize = sizeof bltfx;
backbuffer->Blt(&rcSet, surf, &rcWork, DDBLT_KEYSRCOVERRIDE | DDBLT_WAIT, &bltfx);
}
else
backbuffer->Blt(&rcSet, surf, &rcWork, DDBLT_KEYSRC | DDBLT_WAIT, NULL);
}
};

Expand Down Expand Up @@ -288,7 +293,7 @@ BOOL renderLoop(HINSTANCE hInstance, HWND hWnd)
leftFacingRoach.draw(204, 28, roachSurface);
// Draw BigCroakers
rightFacingFrog.draw(32, 128, frogSurface1);
leftFacingFrog.draw(192, 128, frogSurface2);
leftFacingFrog.draw(192, 128, frogSurface2, true);

if (!drawFrame(hInstance, hWnd))
return FALSE;
Expand Down
13 changes: 3 additions & 10 deletions load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ BOOL loadFrog1()

BOOL loadFrog2()
{
// Using TransparentBlt
// BitBlt again but we override the color key later
HANDLE handle = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BIGCROAKER), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
if (handle == NULL)
{
Expand All @@ -283,13 +283,6 @@ BOOL loadFrog2()
return FALSE;
}

// Black out the surface
DDBLTFX ddbltfx;
memset(&ddbltfx, 0, sizeof ddbltfx);
ddbltfx.dwSize = sizeof ddbltfx;
ddbltfx.dwFillColor = 0x000000;
frogSurface2->Blt(&windowRect, 0, 0, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);

// Copy bitmap onto surface
HDC hdc = CreateCompatibleDC(NULL);
HGDIOBJ hgdiobj = SelectObject(hdc, handle);
Expand All @@ -300,9 +293,9 @@ BOOL loadFrog2()
return FALSE;
}

if (!TransparentBlt(hdc2, 0, 0, bitmap.bmWidth, bitmap.bmHeight, hdc, 0, 0, bitmap.bmWidth, bitmap.bmHeight, 0))
if (!BitBlt(hdc2, 0, 0, bitmap.bmWidth, bitmap.bmHeight, hdc, 0, 0, SRCCOPY))
{
reportFailure("TransparentBlt", __LINE__, 0);
reportFailure("BitBlt", __LINE__, 0);
return FALSE;
}
frogSurface2->ReleaseDC(hdc2);
Expand Down

0 comments on commit a336462

Please sign in to comment.