• Advertisement

Archived

This topic is now archived and is closed to further replies.

ddraw question

This topic is 5984 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello i''m a complete Direct Draw noobie for the last few days i''v been trying to just draw a rectangle on screen can anybody tell me if this is possible or are you just allowed to use bitmaps?? cause all the tutorials i''v found just show you how to load bitmaps. if it can be done could someone post some quick code please to start me along

Share this post


Link to post
Share on other sites
Advertisement
Yes there is a way

You can use the Blit Function to blit a rect to a screen, though I don''t believe you need a source rect and the DDBLTFX structure you pass to the function at the end should contain the info on how the rect is filled

I think this is how you do it - I''m quite tired right now

Also go check out the DirectX7 docs for more info on the blit function if your having problems... and if you having problems all together - get a book !

Have Fun!

Destroyer

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Yes there is a way

You can use the Blit Function to blit a rect to a screen, though I don''t believe you need a source rect and the DDBLTFX structure you pass to the function at the end should contain the info on how the rect is filled

I think this is how you do it - I''m quite tired right now

Also go check out the DirectX7 docs for more info on the blit function if your having problems... and if you having problems all together - get a book !

Have Fun!

Destroyer

Share this post


Link to post
Share on other sites
To blit a rectangle to the screen, get an HDC from the backbuffer using DDSurface->GetDC(), then call rectangle() to draw it. You will need to use SelectObject() to set the pen and brush, I dont have the code on hand though I''m sure the DX7SDK samples can point u in the right direction.

  Downloads:  ZeroOne Realm

Share this post


Link to post
Share on other sites
DDBLTFX fx;
ZeroMemory(&fx, sizeof(fx));
fx.dwSize = sizeof(fx);
fx.dwFillColor = Color;
BackBuffer->Blt(&Rect, NULL, NULL, DDBLT_COLORFILL, &fx);

Share this post


Link to post
Share on other sites
well it depends on what kind of rectangle you want to draw. If you just want to plot 4 lines then you must follow SikCiv method, although u can also draw filled rectangles with the same method as well. Or if u r only interested in Filled rectangles then u may follow Beer Hunters Method.

example:

HDC dc

// creating a white solid pen of 1 pixel width

HPEN newPen = CreatePen(PS_SOLID,1,RGB(255,255,255));
HPEN oldPen;

pDDBackBuffer->GetDC(&dc);
oldPen = (HPEN)SelectObject(dc,(HPEN)pen);
rectangle(dc,x1,y1,x2,y2);
SelectObject(dc,oldPen);
pDDBackBuffer->ReleaseDC(dc);

// hope this will get u started

Share this post


Link to post
Share on other sites
Thanks for all your reply''s after reading one can''t remeber which cause i tried both ways and finally got it to work
thx again

Share this post


Link to post
Share on other sites

  • Advertisement