Mixing DDraw with GDI a good idea?
Hi, I just wanted to know what people on this board thought about mixing DirectDraw with GDI to do the mundane stuff like loading bitmaps and blitting them to surfaces. Also, is it a good idea to use GDI for line drawing and such?
I find it a lot easier to use GDI for drawing primitives because then I wouldn''t have to worry so much about the pixel depth.
I''d like to hear what you people think.
quote:Original post by phinics
Hi, I just wanted to know what people on this board thought about mixing DirectDraw with GDI to do the mundane stuff like loading bitmaps.
Yes, it''s cool since it''s really easier. Moreover, loading bitmaps is not a very exciting task.
quote:
and blitting them to surfaces.
DirectDraw can do it very easily and at least as fast as GDI. Why don''t you use it ?
quote:
Also, is it a good idea to use GDI for line drawing and such?
No. GDI is so slooooooooooow! But if you don''t need much speed, it can be useful. In fact, just make some speed tests and see if GDI is fast enough for what you want to do.
Prosper / LOADED corporation
Yeah, I used to use GDI for my simple stuff like circles and text, but then I delved into this old game I made, eliminated ALL the GDI calls (except for some I/O). I took out all my ->GetDC(...) calls, and my system requirements dropped from a p233 to a p120 in one simple stroke!
GDI SUCKS for speed
GDI SUCKS for speed
Holly,
I''ve just trid to benchmark the speed of the GDI calls versus pure DirectX drawing functions. GDI is really slow.
On my 433 system, the time it took GDI to plot 1,000,000 pixels in 16 bit was 26 seconds. With DirectX it dropped to 4 seconds.
Guess I''ll stick to locking the surface and then doing my drawing and such.
Now I''ve got to spend lots of time figuring out that circle drawing algorighm. *sigh*
I''ve just trid to benchmark the speed of the GDI calls versus pure DirectX drawing functions. GDI is really slow.
On my 433 system, the time it took GDI to plot 1,000,000 pixels in 16 bit was 26 seconds. With DirectX it dropped to 4 seconds.
Guess I''ll stick to locking the surface and then doing my drawing and such.
Now I''ve got to spend lots of time figuring out that circle drawing algorighm. *sigh*
Just use the circle equation: y = sqrt(r*r-x*x)
do + and -, connect the dots, and you got a circle!
Really fast, too. Used that forever.
do + and -, connect the dots, and you got a circle!
Really fast, too. Used that forever.
There''s an integer based formula for circle drawing that works quite a bit faster.
Obviously will work faster if circlePlot and setPixel aren''t actual function calls. inline to your heart''s content.
void circlePlot(int xCenter, int yCenter, int x, int y) { setPixel(xCenter + x, yCenter + y); setPixel(xCenter + x, yCenter - y); setPixel(xCenter - x, yCenter + y); setPixel(xCenter - x, yCenter - y); setPixel(xCenter + y, yCenter + x); setPixel(xCenter + y, yCenter - x); setPixel(xCenter - y, yCenter + x); setPixel(xCenter - y, yCenter - x);}void circle(int xCenter, int yCenter, int radius) { int x = 0; int y = radius; int p = 1 - radius; circlePlot(xCenter, yCenter, x, y); while (x < y) { x++; if (p < 0) { p += 2 * x + 1; } else { y --; p += 2 * (x - y) + 1; } circlePlot(xCenter, yCenter, x, y); }}
Obviously will work faster if circlePlot and setPixel aren''t actual function calls. inline to your heart''s content.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement