GDI Graphics

Started by
9 comments, last by kburkhart84 10 years, 5 months ago

Haven't programmed 2d stuff in awhile, is GDI+ still a decent way to go for 2d graphics? Looking at creating some small games for the windows surface pro and maybe RT, if not gdi what would you recommend?

Would be good if I didn't have to install the directx distributables too if possible...

Thanks,

rh

Advertisement

Well, I can say it's been quite a while since you haven't draw anything with code :)

GDI is no longer an option now, but do you want to go for low level programming or do you want to make a 2D game (for which there are countless free frameworks and engines to choose from)?

Well, I can say it's been quite a while since you haven't draw anything with code smile.png

GDI is no longer an option now, but do you want to go for low level programming or do you want to make a 2D game (for which there are countless free frameworks and engines to choose from)?

Would like to use c++ to design 2d strategy game, can you recommend a good c++ framework or engine for this?

Anyone hear of FTL, something like that, what would you say they used? But would like to incorporate touch screen:

http://www.kickstarter.com/projects/64409699/ftl-faster-than-light

Isn't gdi+ super robust, reliable and and easy to use? Would like to keep things as simple as possible, reach as wide an audience and of course reliable with easy install...

GDI is certainly an option. The API is mature and has aged well since it was introduced thirty years ago.

With the latest few rounds of Windows some features have lost hardware acceleration. If you happen to be throwing around tens of thousands of sprites at once (which is NOT recommended, keep that number to a few hundred at most) then GDI may have some CPU-bound performance concerns.

GDI was semi-replaced by GDI+ a decade ago. Microsoft would prefer if you don't use the original GDI any more but there is so much legacy code that they cannot drop support for it. GDI+ has many features like transparency, antialiasing, and more modern compressed image formats.


There are many newer technologies available that offer newer features and are easier to use. For example, if you are working only with GDI you will likely find yourself spending untold hours manipulating images at a low level, decoding graphics files, working with bitmap parameters, and doing lower-level bit-twiddling that could have been avoided by using newer systems that operate at a higher level.

If you are using C# or managed C++ you will likely discover that the .net framework's graphics libraries are extremely easy to use. They use GDI+ internally and also add a large collection of additional utility features.

Another option, the one that Microsoft currently recommends, is to use Direct2D for advanced 2D graphics. It was part of the DirectX suite, earlier called DirectDraw. Most 3D games rely on its components as 'surfaces', giving things like a Direct Draw Surface and the various DDS image file formats. Some nice things about Direct2D are that is is hardware accelerated through the DirectX drivers, and that it manages to work well with GDI, GDI+, WDM, and various other Windows rendering systems. You can mix and match a surface with a GDI device context with very little transition code.

As for your desire to not ship with DirectX redistributables, that is not really an issue any more. DirectX is no longer an independent component, it has been integrated into the Windows SDK. DirectX 10 was part of Vista. DirectX 11was part of Windows 7 and Vista SP2, DirectX 11.1 was part of Windows 8. DirectX 11.2 is part of Windows 8.1. Microsoft announced years ago that they will not back-port new versions of DirectX to old versions of Windows. It is now just another part of the operating system, not a separate component.

Well, I can say it's been quite a while since you haven't draw anything with code smile.png

GDI is no longer an option now, but do you want to go for low level programming or do you want to make a 2D game (for which there are countless free frameworks and engines to choose from)?

Would like to use c++ to design 2d strategy game, can you recommend a good c++ framework or engine for this?

Anyone hear of FTL, something like that, what would you say they used? But would like to incorporate touch screen:

http://www.kickstarter.com/projects/64409699/ftl-faster-than-light

FTL used SFML http://www.sfml-dev.org/

It takes ages to load and has performance issues on my (ancient i.e. 2006) PC though ;)

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

GDI is certainly an option. The API is mature and has aged well since it was introduced thirty years ago.

With the latest few rounds of Windows some features have lost hardware acceleration. If you happen to be throwing around tens of thousands of sprites at once (which is NOT recommended, keep that number to a few hundred at most) then GDI may have some CPU-bound performance concerns.

GDI was semi-replaced by GDI+ a decade ago. Microsoft would prefer if you don't use the original GDI any more but there is so much legacy code that they cannot drop support for it. GDI+ has many features like transparency, antialiasing, and more modern compressed image formats.


There are many newer technologies available that offer newer features and are easier to use. For example, if you are working only with GDI you will likely find yourself spending untold hours manipulating images at a low level, decoding graphics files, working with bitmap parameters, and doing lower-level bit-twiddling that could have been avoided by using newer systems that operate at a higher level.

If you are using C# or managed C++ you will likely discover that the .net framework's graphics libraries are extremely easy to use. They use GDI+ internally and also add a large collection of additional utility features.

Another option, the one that Microsoft currently recommends, is to use Direct2D for advanced 2D graphics. It was part of the DirectX suite, earlier called DirectDraw. Most 3D games rely on its components as 'surfaces', giving things like a Direct Draw Surface and the various DDS image file formats. Some nice things about Direct2D are that is is hardware accelerated through the DirectX drivers, and that it manages to work well with GDI, GDI+, WDM, and various other Windows rendering systems. You can mix and match a surface with a GDI device context with very little transition code.

As for your desire to not ship with DirectX redistributables, that is not really an issue any more. DirectX is no longer an independent component, it has been integrated into the Windows SDK. DirectX 10 was part of Vista. DirectX 11was part of Windows 7 and Vista SP2, DirectX 11.1 was part of Windows 8. DirectX 11.2 is part of Windows 8.1. Microsoft announced years ago that they will not back-port new versions of DirectX to old versions of Windows. It is now just another part of the operating system, not a separate component.

Thanks a lot frob, that's really good info, much appreciated...

GDI is certainly an option. The API is mature and has aged well since it was introduced thirty years ago.

With the latest few rounds of Windows some features have lost hardware acceleration. If you happen to be throwing around tens of thousands of sprites at once (which is NOT recommended, keep that number to a few hundred at most) then GDI may have some CPU-bound performance concerns.

GDI was semi-replaced by GDI+ a decade ago. Microsoft would prefer if you don't use the original GDI any more but there is so much legacy code that they cannot drop support for it. GDI+ has many features like transparency, antialiasing, and more modern compressed image formats.


There are many newer technologies available that offer newer features and are easier to use. For example, if you are working only with GDI you will likely find yourself spending untold hours manipulating images at a low level, decoding graphics files, working with bitmap parameters, and doing lower-level bit-twiddling that could have been avoided by using newer systems that operate at a higher level.

If you are using C# or managed C++ you will likely discover that the .net framework's graphics libraries are extremely easy to use. They use GDI+ internally and also add a large collection of additional utility features.

Another option, the one that Microsoft currently recommends, is to use Direct2D for advanced 2D graphics. It was part of the DirectX suite, earlier called DirectDraw. Most 3D games rely on its components as 'surfaces', giving things like a Direct Draw Surface and the various DDS image file formats. Some nice things about Direct2D are that is is hardware accelerated through the DirectX drivers, and that it manages to work well with GDI, GDI+, WDM, and various other Windows rendering systems. You can mix and match a surface with a GDI device context with very little transition code.

As for your desire to not ship with DirectX redistributables, that is not really an issue any more. DirectX is no longer an independent component, it has been integrated into the Windows SDK. DirectX 10 was part of Vista. DirectX 11was part of Windows 7 and Vista SP2, DirectX 11.1 was part of Windows 8. DirectX 11.2 is part of Windows 8.1. Microsoft announced years ago that they will not back-port new versions of DirectX to old versions of Windows. It is now just another part of the operating system, not a separate component.

Can gdi+ do semi transparency, like seeing a blue spherical shield around a space ship?

Not sure if by transparency you mean masking for a 2d sprite...


Can gdi+ do semi transparency, like seeing a blue spherical shield around a space ship?

Not sure if by transparency you mean masking for a 2d sprite...

GDI by itself has extremely limited support for transparency. You can copy from one source to a destination ("blitting"). You can use a single key color that is marked as transparent or invisible, basically a "do not copy" color. Drawing lines and filling areas would only work with a single color and no transparency. In all cases writing to the destination obliterated whatever data was there.

GDI+ allows for alpha channels and alpha blending. So it is much more than simple blitting, you could provide a slider from 0-255 that lets you make a translucent copy on top of the destination. GDI+ also allows alpha blending when drawing lines or filling areas, where GDI did not. You can have a line that fades in, is invisible on one endpoint and fully visible on the other. It also has anti-aliased text and anti-aliased lines, using alpha blending on the edges. GDI+ allowed you to preserve some of the information rather than completely obliterate the image.

So if you want to copy a blue bubble around your space ship, using GDI alone would give you a solid blue circle replacing all the old data. With GDI+ you can assign a color matrix with a 50% alpha to the image attributes. When you draw the image with that color matrix assigned it will draw as 50% blue and 50% the old color.

Ok, some frameworks for C++ would be:

SMFL: http://www.sfml-dev.org/

SDL: http://www.libsdl.org/

Allegro: https://www.allegro.cc/

HGE: http://hge.relishgames.com/

Cocos2d-X: http://www.cocos2d-x.org/

Oxygine: http://oxygine.org/

This topic is closed to new replies.

Advertisement