I'm working on a "breakout" game and everything worked fine until i tried to add in double buffering.
I tried to take out double buffering since i couldn't get it to work and now, it draws everything from the top left corner of the screen instead of in the client area.
g_hwnd isnt 0

This is the code that's doing the drawing

void C_Graphics::DrawAll(C_Brick Bricks[])
{
    hbr = CreateSolidBrush(RGB(0,0,0));
    RECT r;
    r = Player.Get_BallInfo();
    Ellipse(hdc, r.left, r.top, r.right, r.bottom);
    FillRect(hdc, Player.Get_PlankInfo(), hbr);
    for(int i = 0; i < 20; i++)
    {
        if (Bricks[i].Get_Life() > 0)
            FillRect(hdc, Bricks[i].Get_Info_ptr(), hbr);
    }
    DeleteObject(hbr);
}

void C_Graphics::ClearScreen()
{
    hbr = CreateSolidBrush(RGB(255, 255, 255));
    RECT r;
    GetClientRect(g_hwnd, &r);
    FillRect(hdc, &r, hbr);
    DeleteObject(hbr);
}

http://cboard.cprogramming.com/showthread.php?t=87786

Recommended Answers

All 2 Replies

Think you'll have to attach complete code (including that of Player, Brick etc classes). From teh code you've posted all looks well.
PS: Please do ATTACH and not paste the whole code here.

Another thing, if i open it by double clicking the app, the client area is all grey and nothing gets drawn
It only draws from the top left of the screen when i press run on Codeblock

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.