1
votes

I know that DirectX and OpenGL are both built into a graphics card and you can access them when you need to so all the rendering will be hardware based accelerated.

I can't find anything about GDI but i'm sure it's not a graphics card based acceleration. How does those technologies differ and what am i missing here?

2
In earlier days you could create applications with DirectX/OpenGL rendering SDK/API's without any actual hardware acceleration (and use limited functionality). The MESA driver implementation for example would manage the opengl rendering calls entirely on the CPU, something linux people have been stuck with for years. WARP10 was an attempt to provide the same thing for DX7. The hardware "dependency" mostly stems from applications using advanced rendering functionality (such as shaders).StarShine

2 Answers

2
votes

The GDI library dates back to the early 90s and the first versions of Windows. It's supports a mix of hardware-accelerated raster ops and software vector graphics drawing. It is primary for drawing 'presentation' graphics and text for GUIs. GDI+ was a C++ class-based wrapper for GDI, but is basically the same technology. Modern versions of Windows still support legacy GDI APIs but modern graphics cards don't implement the old fixed-function 'raster ops' hardware accelerated paths--it's not really accurate to even refer to the video cards of the early 90s "GPUs".

OpenGL and Direct3D are graphics APIs built around pixels, lines, and triangles with texturing. Modern versions of both use programmable shader stages instead of fixed-function hardware to implement transform & lighting, texture blending, etc. These enable 3D hardware acceleration, but by themselves do not support classic 'raster ops' or vector-based drawing like styled/wide lines, filled ellipses, etc. Direct2D is a vector graphics library that does these old "GDI-style" operations on top of Direct3D with a mix of software and hardware-accelerated paths, and is what is used by the modern Windows GUI in combination with DirectWrite which implements high-quality text rendering.

See Graphics APIs in Windows, Vector graphics, and Raster graphics.

In short, for modern Windows programming you should use Direct2D/DirectWrite for 'presentation graphics' perhaps via a wrapper like Win2D, and Direct3D for 2D raster "sprite" graphics or 3D graphics rendering (see DirectX Tool Kit).

2
votes

GDI is pure 2D image access and rendering (with very limited acceleration on a raster level if not disabled). So in GDI there are no:

  • textures
  • shaders
  • buffers
  • depth/stencil buffers
  • transform matrices
  • gfx pipeline

The differences are:

  • transparency is done by specific color value instead of alpha channel
  • blending is possible in only per channel add,xor,copy modes
  • you can get direct pixel access
  • got windows font access and text functions support
  • window related GDI calls should be called just from it's main thread (WndProc)