Colorkey mit DDraw funktioniert nicht
-
Hallo,
ich weiss, das Thema wurde schon sehr häufig diskutiert und habe einiges in der Suche gefunden. leider funktioniert folgendes nicht bei mir:
do { ... lpddsBitmap = DDLoadBitmap(lpDirectDraw, "pics\\grounds\\1-weg.bmp", 64, 64);} AddColorKey(lpddsBitmap[i], 0, 0); SetRect(&rectbitmap[i], x1, y1, x2, y2); ... }while(...); lpddsBack->Blt(&fill_area, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT , &ddbltfx); int i=0; //dann beim Malen... do { ... lpddsBack->Blt(&rectbitmap[i], lpddsBitmap[i],NULL, DDBLT_WAIT | DDBLT_KEYSRC, NULL); lpddsBack->Blt(&rectobject[i], lpddsObject[i], NULL, DDBLT_WAIT | DDBLT_KEYSRC, NULL); i=i+1; }while(i<=300);Kann mir jemand bitte helfen?
Liegt es evtl. [i]LPDIRECTDRAWSURFACE7 lpddsBitmap[2000];* bzw. lpddsBitmap[i]Danke für Eure Hilfe
Edwart
-
Hmmm ColorKeys sind eh Müll...
-
Definiere "funktioniert [...] nicht".
Bye, TGGC
-
ich verwende das 2 mal.
erst zeichne ich den Hintergrund, und dann objecte
wenn ich das AddColorKey für die Objekte verwende, stürtz es ab:
lpddsObject[i] = DDLoadBitmap(lpDirectDraw, "pics\\objects\\2-baum.bmp", 64, 64); } AddColorKey(lpddsObject[i], 0, 0); SetRect(&rectobject[i], x1, y1, x2, y2);und wenn ich es für den Hintergrund verwende, wirds nicht transparent:
lpddsBitmap[i] = DDLoadBitmap(lpDirectDraw, "pics\\grounds\\1-weg.bmp", 64, 64);} AddColorKey(lpddsBitmap[i], 0, 0); SetRect(&rectbitmap[i], x1, y1, x2, y2);Hier die Funktion, wo ich blite:
while(running) { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { if (msg.message == WM_QUIT) break; TranslateMessage(&msg); DispatchMessage(&msg); lpddsBack->Blt(&fill_area, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT , &ddbltfx); int i=0; do { lpddsBack->Blt(&rectbitmap[i], lpddsBitmap[i],NULL, DDBLT_WAIT | DDBLT_KEYSRC, NULL); lpddsBack->Blt(&rectobject[i], lpddsObject[i], NULL, DDBLT_WAIT | DDBLT_KEYSRC, NULL); i=i+1; }while(i<=300); while(lpddsPrimary->Flip(NULL, DDFLIP_WAIT ) != DD_OK); } }und Hier die AddColorKey Funktion:
void AddColorKey (LPDIRECTDRAWSURFACE7 surface, DWORD Low, DWORD High) { DDCOLORKEY key; ZeroMemory(&key, sizeof(key)); key.dwColorSpaceLowValue = RGB(90,80,5); key.dwColorSpaceHighValue = 0; surface->SetColorKey (DDCKEY_SRCBLT, &key); }Weiss jemand Rat?
Vielen Dank
Edwart
-
Edwart schrieb:
wenn ich das AddColorKey für die Objekte verwende, stürtz es ab:
Wann genau? Sofort nach dem Aufruf von AddColorKey oder erst später beim Zeichnen?
Schonmal den Debugger verwendet?
-
Edwart schrieb:
void AddColorKey (LPDIRECTDRAWSURFACE7 surface, DWORD Low, DWORD High) { DDCOLORKEY key; ZeroMemory(&key, sizeof(key)); key.dwColorSpaceLowValue = RGB(90,80,5); key.dwColorSpaceHighValue = 0; surface->SetColorKey (DDCKEY_SRCBLT, &key); }Weiss jemand Rat?
Japp, AddColorKey reparieren. Setzt ja sonst nur irgendwelche Werte.
Bye, TGGC
-
ALso, das AddColorKey wird nur einmal aufgerufen, dann stürzt es ab. Hab mal ne MessageBox eingabut, und die wird einmal angezeigt. Dann crash.
Hier die FUnktion, mitden Shcleifen:void paint_objects() { int i; int x1,y1, x2,y2; x1=0; y1=0; x2=64; y2=64; int x=0; int y=0; i=0; do { do { if (map_object[x][y] == 1) { lpddsObject[i] = DDLoadBitmap(lpDirectDraw, "pics\\objects\\1-baum.bmp", 64, 64); } else if (map_object[x][y] == 2) { lpddsObject[i] = DDLoadBitmap(lpDirectDraw, "pics\\objects\\2-baum.bmp", 64, 64); } AddColorKey(lpddsObject[i],0,0); SetRect(&rectobject[i], x1, y1, x2, y2); MessageBox(NULL,"funktioniert","M",MB_OK); x1=x1+64; x2=x2+64; i=i+1; x=x+1; }while(x<=15); x1=0; x2=+64; y1=y1+64; y2=y2+64; y=y+1; x=0; }while(y<=16); }Hier das AddColorKey - ist das so jetzt richtig?:
void AddColorKey (LPDIRECTDRAWSURFACE7 surface, DWORD Low, DWORD High) { DDCOLORKEY key; ZeroMemory(&key, sizeof(key)); key.dwColorSpaceLowValue = RGB(255,0,255); key.dwColorSpaceHighValue = RGB(255,0,255); surface->SetColorKey (DDCKEY_SRCBLT, &key); }
-
Genau, jetzt benutzt du andere sinnlose Werte, so muss das sein. Und die Parameter sind gleichsam den APPD Stimmen "für den Müll".
Bye, TGGC
-
Edwart schrieb:
Hier das AddColorKey - ist das so jetzt richtig?:
void AddColorKey (LPDIRECTDRAWSURFACE7 surface, DWORD Low, DWORD High) { DDCOLORKEY key; ZeroMemory(&key, sizeof(key)); key.dwColorSpaceLowValue = RGB(255,0,255); key.dwColorSpaceHighValue = RGB(255,0,255); surface->SetColorKey (DDCKEY_SRCBLT, &key); }Macht es Sinn, wenn man einer Funktion drei Parameter übergibt,
zwei davon aber völlig ignoriert werden?
-
Erster.
Bye, TGGC (Demo or Die)
-
Zweiter
