Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

GDI+ Help.

9 views
Skip to first unread message

commodorec...@googlemail.com

unread,
Dec 18, 2011, 6:09:12 PM12/18/11
to
Hi all,

I'm struggling with some GDI+ principles, in particular, my routines
or functions or sub-routines or methods are drawing so that you can't
see the drawing process. This might be that there's not enough data
being shunted around (I'm only doing 2d stuff at the mo) and if I had
more going on, I'd see things been drawn maybe? But it'd be helpful if
I could see what's been drawn as my program runs through. When I use
the standard Windows stuff to draw to a canvas or bitmap then I can
actually see it update... so is GDI+ just too damn efficient for its'
own good?

I've used pastebin for the code, the CPP source files are here (or at
least the unique ones):

http://pastebin.com/eCf6ae2z

and the header files unique are here:

http://pastebin.com/DBYpeBu0

Anyway, in my Rasterizer class or something, I have a routine that
draws squares as follows:

void Rasterizer::DrawSquare(Vertex square[4], bool Update, HWND _hWnd)
{
HWND hWnd;
hWnd=_hWnd;
Pen pen(Color(255,12,48,150));
for (int i=0; i<4; i=i+1)
{
if (i+1==4)
{
_graphics->DrawLine(&pen, square[i].GetX(), square[i].GetY(),
square[0].GetX(), square[0].GetY());
}
else
_graphics->DrawLine(&pen, square[i].GetX(), square[i].GetY(),
square[i+1].GetX(), square[i+1].GetY());
}
if(!Update)
{
return;
}
else
InvalidateRect(_hWnd, NULL, FALSE);
}

And something that draws lines from point x0, y0 to x1, y1, like:

void Rasterizer::LineTo(int col[4],int x0, int y0, int x1, int y1,
bool Update, HWND _hWnd)
{
HWND hWnd;
hWnd= _hWnd;
Pen pen(Color(col[0],col[1],col[2],col[3]));
_graphics->DrawLine(&pen, x0, y0, x1, y1);
if(!Update)
{
return;
}
else
InvalidateRect(_hWnd, NULL, FALSE);
}

So, anyway, I call the above routines or whatever they're called
nowadays like:

for (int j=0; j<360;j=j+1) // j=j+1 is more like the Mathematics I'm
all about!
{
for (int i=0; i<4; i=i+1)
{
square[i]=square[i]-point;
square[i]=_matrixRotate*square[i];
square[i]=square[i]+point;
}
_rasterizer->DrawSquare(square, true, _hWnd); //draw scaled square
}
int blue[4]={255, 0, 0, 255};
int red [4]={255, 255, 0, 0};
int y=256;
for (int x=0; x<256; x=x+5)
{
_rasterizer->LineTo(blue, 0, y, x, 0, true, _hWnd);
_rasterizer->LineTo(red, 256, x, y, 256, true, _hWnd);
y=y-5;
Paint (_hdc);
ReleaseDC(_hWnd, _hdc);
}

Any tips will be useful. Thanks in advance.
0 new messages