Skip to main content
gamedev.net
🔒 Locked

Rectangle Drawing

Started by Ferinorius Jul 6, 2000 at 5:22 PM 1 replies 400+ views
Original Post
Ferinorius
Ferinorius
Ok, I have a problem. I don''t know much about how to change from 8 bit indexed color to 16+ RGB values, so I''m calling upon all of you. here is what I have so far from Andre''s code
    

int Draw_Rectangle(int x1, int y1, int x2, int y2, int color,
                   LPDIRECTDRAWSURFACE lpdds)
{
// this function uses directdraw to draw a filled rectangle


DDBLTFX ddbltfx; // this contains the DDBLTFX structure

RECT fill_area;  // this contains the destination rectangle

Set_Palette(bitmap8bit.palette);
// clear out the structure and set the size field 

DD_INIT_STRUCT(ddbltfx);

// set the dwfillcolor field to the desired color

ddbltfx.dwFillColor = color; 

// fill in the destination rectangle data (your data)
fill_area.top    = y1;
fill_area.left   = x1;
fill_area.bottom = y2;
fill_area.right  = x2;

// ready to blt to surface, in this case blt to primary
lpdds->Blt(&fill_area, // ptr to dest rectangle

           NULL,       // ptr to source surface, NA            
           NULL,       // ptr to source rectangle, NA
           DDBLT_COLORFILL / DDBLT_WAIT,   // fill and wait                   

           &ddbltfx);  // ptr to DDBLTFX structure


// return success

return(1);

} // end Draw_Rectangle


    
how do I change the function so that it takes in an RGB(...) (colorref right?) and display it based on what i send it. I bet that was pretty dang confusing. Someone give me a pointer to the right direction.
djsteffey
djsteffey
where you are sending the function the int color....
take out that argument and place this instead
BYTE r, BYTE g, BYTE b
then when you call the functionsend it the r g and b values of the color you want
ddbltfx.dwFillColor = RGB(r, g, b);

this will work for 24 bit surfaces
for 16 bit surfaces you need to create something similar to RGB(r, g, b) but convert to a 16 bit color because RGB() produces a 24 bit color


"Now go away or I shall taunt you a second time"
- Monty Python and the Holy Grail
themGames Productions

Ferinorius
Ferinorius
Thanks, but I figured it out with an easier way. I sent it a COLORREF color. Then did


ddbltfx.dwFillPixel = color



and that did it. Thanks for the help and quick response!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.