|
-
Direct Draw
I am coding a game in direct draw.
Since 8 bit color is pretty cruddy (for games) I wish to use 32 bit (24 is not an option since it doesn't work for me)
how do you set up a palette for 32 bit color
(all the tutorials use 8 bit, no higher
note: I am using C++
-
please anyone
-
There has got to be one of the 22000 members who programs direct draw in C++ with more than 265 color
PLEASE HELP ME (within a couple days would work)
-
Goldfish
Did you check out the link I posted in my thread, Ironblayde's tutorials? They're quite good and deal with 16-bit towards the middle and end (I assume 16-bit is OK too because you said you didn't want 8-bit).
What specifically do you want, BTW? There are no palettes in 32-bit (AFAIK), so I don't know what exactly you're looking for when you say 'setting up a palette'.
-
all the examples of DDraw are in 8 bit color (which does need a palatte)
now that I want to code in 32 I don't know what to do
do I even need to attach a palette to the surfaces for just go for it and start the blting
-
Goldfish
Nope, no palettes or anything, just create the surfaces and blit.
-
-
Goldfish
Well, this is basically what I do in normal circumstances for loading 16-bit bitmaps, it's the same as in the tutorials I linked to.
Code:
int LoadBitmapFile(LPDIRECTDRAWSURFACE7
lpdds, int xDest, int yDest)
{
HDC hSrcDC; // source DC - memory device context
HDC hDestDC; // destination DC - surface device context
HBITMAP hbitmap; // handle to the bitmap resource
BITMAP bmp; // structure for bitmap info
int nHeight, nWidth; // bitmap dimensions
// first load the bitmap
if ((hbitmap = (HBITMAP)LoadImage(hinstance,"C:\pic.bmp",
IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION))
== NULL)
return(FALSE);
// create a DC for the bitmap to use
if ((hSrcDC = CreateCompatibleDC(NULL)) == NULL)
return(FALSE);
// select the bitmap into the DC
if (SelectObject(hSrcDC, hbitmap) == NULL)
{
DeleteDC(hSrcDC);
return(FALSE);
}
// get image dimensions
if (GetObject(hbitmap, sizeof(BITMAP), &bmp) == 0)
{
DeleteDC(hSrcDC);
return(FALSE);
}
nWidth = bmp.bmWidth;
nHeight = bmp.bmHeight;
// retrieve surface DC
if (FAILED(lpdds->GetDC(&hDestDC)))
{
DeleteDC(hSrcDC);
return(FALSE);
}
// copy image from one DC to the other
if (BitBlt(hDestDC, xDest, yDest,
nWidth, nHeight, hSrcDC,
0, 0, SRCCOPY) == NULL)
{
lpdds->ReleaseDC(hDestDC);
DeleteDC(hSrcDC);
return(FALSE);
}
// kill the device contexts
lpdds->ReleaseDC(hDestDC);
DeleteDC(hSrcDC);
// return success
return(TRUE);
}
That ought to work.
Is that the code you were looking for, or do you want stuff on creating surfaces etc.
IIRC there isn't anything special in 16-bit as opposed to 8-bit, just no palette attaching. Come to think of it I've completely forgotten palettes !
[EDIT]Oops, wrong function name and obsolete argument!
Last edited by DarkAvenger; 04-12-2002 at 04:52 PM.
-
thanks for the code
do you know if using DCs is slower than loading the bitmap yourself and using bltfast
-
Goldfish
By bitmap loading yourself you mean actually opening the file and manually reading in all the data? I think that method is what many people use, but I haven't had any need to use it just yet, because bitmap loading is fast enough for me.
BltFast() is definitely the way to go, unless you need to use any special effects via the DDBLTFX structure.
-
Originally posted by DarkAvenger
unless you need to use any special effects via the DDBLTFX structure.
like clipped sprites
-
Goldfish
I don't think clipping is via the DDBLTFX structure (I've never studied them in detail), IIRC it's through the LPDIRECTDRAWCLIPPER structure. DDBLTFX is mainly used for filling surfaces with a colour, or even for rotation. I only use Blt() when I want to fill my surfaces, everywhere else it's BltFast().
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|