In which situations is it a good idea to prefer GDI over DirectX/OpenGL [closed]
Asked Answered
J

2

9

I'm new to graphics programming and I'm wondering why I would ever prefer GDI over the hardware accelerated graphics of DirectX/OpenGL?

Are there still good reasons to use GDI?

Juliennejuliet answered 28/11, 2011 at 22:29 Comment(0)
P
11

It ultimately comes down to what you need. If you just need non-real time 2D graphics, GDI will do exactly what you need.

On the other hand, DirectX and OpenGL take much more work to use and manage (and typically use more system resources), although they allow faster drawing, and 3D.

Remember, keep it simple, you don't need a full 3D system to draw a couple of circles!

Prissy answered 28/11, 2011 at 22:32 Comment(6)
Yeah this. Basically GDI is just simple. If you aren't doing anything extensive whatsoever and you don't understand how OpenGL or DirectX work then it probably isn't in your best interest to learn about them. And GDI is platform specific whereas OpenGL is cross-platform.Ergener
So with GDI the size of my exe file will be smaller, but will have slower drawing? So basically if I want fast drawing, I should use DirectX/OpenGL, else GDI? So for paint programs, 2D/3D games, etc, it would be more efficient to use DX/GL, and for programs that don't need to refresh the window that often, GDI is a better choice?Juliennejuliet
Not exactly. Your program size shouldn't change much as the OpenGL/DirectX libraries are dynamically linked (although of course, you have more code to init them). GDI will be slower than D3D/OpenGL though, as it's indirect rendering. Both D3D and OGL talk straight to the graphics card, GDI has to go through Windows and (I think) is all done in software.Prissy
Actually, I think some more recent versions of Windows try to hardware accelerate GDI. Still though, if you need very fast 2D or 3D graphics, you're going to need D3D/OGL.Prissy
Well, I know how to use DX, but I don't really know GDI that well x) wouldn't it be better if I just always used it then?Juliennejuliet
It depends. As I said, if you need to make it fast, yeah, you're going to need DirectX. If you can take the performance hit and you're not doing anything too complicated, GDI will probably do it. Your best bet may be to try it with both to figure out which fits for you.Prissy
A
0

If you need to render text; GDI is pretty much infinately a better choice. Unless you are ready to learn how to parse font files and draw fonts. SFML does some nice text drawing but uses 32 bits for each character.

Alfieri answered 21/8, 2023 at 4:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.