Chroma keying seems to work with ok with dbPastImage(), sprites, and 3d objects. Is this what you want?
Example with paste image:
#include <puregdk/core/puregdk.h>
#include <puregdk/initPureGDK.h>
#include <puregdk/simpleWindow.h>
#include <windows.h>
using namespace std;
int __stdcall WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
int screenWidth = 640;
int screenHeight = 480;
if (!initPureGDK("gdkengine.dll"))
return 1;
HWND hWnd = openWindow(0, 0, screenWidth, screenHeight,
"PureGDK - Game Developer's Toolkit", WS_OVERLAPPED | WS_CLIPSIBLINGS |
WS_CAPTION | WS_SYSMENU | WS_CLIPCHILDREN, true);
dbOpenScreen(hWnd, 0, 0, screenWidth, screenHeight);
ShowWindow(hWnd, SW_SHOW);
dbAutoCamOff();
// Must be called before image is loaded
dbSetImageChromaKey(255, 0, 255);
// Get circle
dbInk(dbRGB(255, 0, 255), 0);
dbBox(0, 0, 320, 320);
dbInk(dbRGB(0, 0, 0), 0);
dbCircle(320/2, 320/2, 150);
int circleImageId = dbGetImage(0, 0, 320, 320, 0);
// Set the background color
dbClearScreen(dbRGB(133, 194, 122));
// Paste the image, black is transparent
dbPasteImage(circleImageId, 320/2, 320/4, 1);
do {
dbSync();
}
while (waitWindowEvent(1) != WM_CLOSE);
dbCloseScreen();
return 0;
}
Example with sprites:
#include <puregdk/core/puregdk.h>
#include <puregdk/initPureGDK.h>
#include <puregdk/simpleWindow.h>
#include <windows.h>
using namespace std;
int __stdcall WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
int screenWidth = 640;
int screenHeight = 480;
if (!initPureGDK("gdkengine.dll"))
return 1;
HWND hWnd = openWindow(0, 0, screenWidth, screenHeight,
"PureGDK - Game Developer's Toolkit", WS_OVERLAPPED | WS_CLIPSIBLINGS |
WS_CAPTION | WS_SYSMENU | WS_CLIPCHILDREN, true);
dbOpenScreen(hWnd, 0, 0, screenWidth, screenHeight);
ShowWindow(hWnd, SW_SHOW);
dbAutoCamOff();
// Must be called before image is loaded
dbSetImageChromaKey(255, 0, 255);
// Get circle
dbInk(dbRGB(255, 0, 255), 0);
dbBox(0, 0, 320, 320);
dbInk(dbRGB(0, 0, 0), 0);
dbCircle(320/2, 320/2, 150);
int circleImageId = dbGetImage(0, 0, 320, 320, 0);
// Set background color
dbInk(dbRGB(133,194,122),0);
dbBox(0, 0, screenWidth, screenHeight);
int imageBackdropId = dbGetImage(0, 0, screenWidth, screenHeight);
dbTextureBackdrop(imageBackdropId);
int surface = dbCreateObjectPlane(2, 2, 0);
dbPositionCamera(0, 0, 2);
dbPointCamera(0, 0, 0);
dbTextureObject(surface, circleImageId);
dbSetObjectTransparency(surface, kGDK_DrawFirstWithAlpha);
do {
dbSync();
}
while (waitWindowEvent(1) != WM_CLOSE);
dbCloseScreen();
return 0;
}
Example with 3d:
#include <puregdk/core/puregdk.h>
#include <puregdk/initPureGDK.h>
#include <puregdk/simpleWindow.h>
#include <windows.h>
using namespace std;
int __stdcall WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
int screenWidth = 640;
int screenHeight = 480;
if (!initPureGDK("gdkengine.dll"))
return 1;
HWND hWnd = openWindow(0, 0, screenWidth, screenHeight,
"PureGDK - Game Developer's Toolkit", WS_OVERLAPPED | WS_CLIPSIBLINGS |
WS_CAPTION | WS_SYSMENU | WS_CLIPCHILDREN, true);
dbOpenScreen(hWnd, 0, 0, screenWidth, screenHeight);
ShowWindow(hWnd, SW_SHOW);
dbAutoCamOff();
// Must be called before image is loaded
dbSetImageChromaKey(255, 0, 255);
// Get circle
dbInk(dbRGB(255, 0, 255), 0);
dbBox(0, 0, 320, 320);
dbInk(dbRGB(0, 0, 0), 0);
dbCircle(320/2, 320/2, 150);
int circleImageId = dbGetImage(0, 0, 320, 320, 0);
// Set background color
dbInk(dbRGB(133,194,122),0);
dbBox(0, 0, screenWidth, screenHeight);
int imageBackdropId = dbGetImage(0, 0, screenWidth, screenHeight);
dbTextureBackdrop(imageBackdropId);
int surface = dbCreateObjectPlane(2, 2, 0);
dbPositionCamera(0, 0, 2);
dbPointCamera(0, 0, 0);
dbTextureObject(surface, circleImageId);
dbSetObjectTransparency(surface, kGDK_DrawFirstWithAlpha);
do {
dbSync();
}
while (waitWindowEvent(1) != WM_CLOSE);
dbCloseScreen();
return 0;
}