04.05 - Image Transfer

Started by
29 comments, last by Teej 20 years, 7 months ago
I seem to be having trouble with BltFast. When i ran this example, I received no output onto my screen. I tried putting a single BltFast call in my GameMain after the ClearBackground() but it fails. I checked the HRESULT value, which was -2005537098 which is no where near any of the return constants defined in the SDK. I have no idea what is going wrong with this... my call is extremely simple:

G.lpDDSBack->BltFast(0, 0, G.lpDDSRes, NULL, DDBLTFAST_WAIT | DDBLTFAST_NOCOLORKEY);

-Terrax
gme@umich.edu
Advertisement
Terrax: You have got to have a rect that specifies a source if you are to write something on the screen, that "NULL" says that you don''t want to write anything, just use the function for some reason..

G.lpDDSBack->BltFast(0, 0, G.lpDDSRes, &rectSrc, DDBLTFAST_WAIT | DDBLTFAST_NOCOLORKEY); //rectSrc is the source here

..I think, i might add. Also look out if you are using clippers, bltfast doesn''t work with them.

-Lord Maz-
-Lord Maz-
Thanks a bunch Lord Maz, your help was extremly helpful. As it turns out you can leave the source rect parameter NULL if you want to use the entire source (i was trying it both ways) but your second tidbit of knowledge turned out to be the key. I disabled my clipper and BAM! Instant images. I think that''s funny that they wouldn''t have some sort of special return value for that- oh well. Guess I just have to use Blt from now on.

Thanks!
Hey, folks.

Yeah, I know you all already finished Tetris, and I''m a late-comer. I was actually here a few months back when Teej was doing this another time and got to make Pac-man. Anyway, I missed the Tetris project then, too!

But that''s neither here nor there. My real problem is not Tetris. My problem is with this font blitter I''m trying to write, and maybe somebody here can help me out.

The blitter itself isn''t really the problem. It''s a function to draw text to the screen a few letters per second, as in RPG dialogues, for example. In other words, it looks as though it''s being typed (or spoken). I''m convinced I could make it work if only I could get around the problems I''m having with the bit-block transfer.

First of all, I can''t ever get BltFast to work. For testing purposes, I was using code that Teej gave us a while back. Check this out:

G.lpDDSBack->Blt(&rectDest,G.lpDDSFont, &rectSrc, DDBLTFAST_SRCCOLORKEY|DDBLTFAST_WAIT, NULL);

G.lpDDSBack->BltFast(100,100,G.lpDDSFont, &rectSrc, DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY);

The first one works, the second doesn''t. I don''t know why. Do you? When I execute the code using BltFast, I get a black screen. When I execute the code using Blt, my text is right there. In both cases, the left top starting coordinates are 100,100.

Okay, so no big deal. I just won''t use BltFast. Or rather, I''ll figure out why it doesn''t work later, I told myself, and then fix it once I have because I could use the speed. For the time being, I know Blt works, so we''ll go with that.

So now I''ve got my Font Blitting function compiled with everything else, I put a line in the Game_Main() to execute it...nothing happens. Black screen. That''s weird, I think. The logic is solid. It should work. If it''s not the logic, it must be the blitting operation. That prompts me to start looking at what I did differently between my Font Blitter and when I simply executed a blitting operation from within Game_Main itself. The difference was that I explicitly defined the destination rectangle as so.

rectDest.left = rectDest.top = 100;
rectDest.right = 108; (accounting for the width of a letter)
rectDest.bottom = 113; (accounting for the height)

So, thinks I, it must have something to do with my #define''d FONT_WIDTH and FONT_HEIGHT values. So I use those to define my destination RECT instead. As in:

rectDest.right = rectDest.left + FONT_WIDTH - 1;

etc.

Curiously enough, when I make that change, I now get the black screen with no text showing. So I try instead:

rectDest.right = rectDest.left + 8;

Same deal. It *only* works when I explicitly define the destination rectangle. And I STILL have NO clue why BltFast wasn''t working in the first place, though I have to assume it has something to do with the lower right corner not having definition (same problem I''m having with Blt).

If anybody could shed some light on this for me, I could greatly appreciate it. (Yes, I know I could define integer variables to hold the precalculated values for right and bottom, and to be sure, I''m doing that now, but that just shouldn''t be.)
BltFast does not work if you have a clipper. In this exercise, if the clipper is not needed you can remove it, or you can do as you did and just use Blt instead.
I don''t know about your other problem though.
Thanks, Tramp.

Right after I sent that, I realised BltFast wasn't working because I had set a clipper. I'm still not sure what was going on with the other thing, but I've got it working now.

Can anybody tell me why I can't get transparency to work? Is this accomplishable in 16-bit? I mean, it should be, but it always copies over the colour that I'm setting as the color key and for the life of me, I can't figure out why. Is it a problem with my bitmap? I mean, I made sure the RGB values were all 0. I even explicitly defined my high and low colour values as 0x000000. No go, though. I always get black copied over. So I tried white. Same deal. I mean, is this wrong?

DDCOLORKEY black;
black.dwColorSpaceLowValue = 0x000000;
black.dwColorSpaceHighValue = 0x000000;
G.lpDDSFont->SetColorKey(DDCKEY_SRCBLT, &black);

G.lpDDSBack->Blt(&destination, G.lpDDSFont, &rectSrc, DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY, NULL);

EDIT: Okay, I'm almost glad nobody responded to this, because it gives me a chance to save some face. I switched from BltFast to Blt somewhere along the line there and forgot to update my flags.

Edited by - Uatu on August 2, 2001 10:25:05 PM
Double post

Edited by - Unini on August 1, 2001 11:05:20 AM
This might be an easy question, but how do you render 2 bitmaps on the same screen??
Unini:
If you want to render the same image to 2 different places, you just put 2 blit commands before the flip, but you knew that.

If you want 2 different images then you will have to add a new LPDIRECTDRAWSURFACE7 to the G struct in globals.h and initialize it like the others have been by editing the DDInit function in InitTerm.cpp. You can then just do 2 Blit commands, one from each surface.

It may sound complicated, but you will learn how to soon and I am sure that Teej explains it much better than I do (he taught me).

And don''t worry about asking easy questions, those are the ones I can answer best .
I wont try that, cuz I already found out another (easier) way

Right before the flip, you do the same rectdest.***, rect.src.***, the BLT and then you flip.
Just render everything on the back buffer before you flip.

This topic is closed to new replies.

Advertisement