Advertisement

using sole GDI to build games

Started by April 06, 2020 06:58 PM
7 comments, last by SuperVGA 4 years, 9 months ago

Has anyone tried making game based on GDI? With no other aids. (I`m talking about MFC GDI, I know people don`t use MFC these days, but I`m sure there is a matching library for modern win apps )

My project`s facebook page is “DreamLand Page”

If your graphics are so simple that GDI works and doesn't slow the game to an unplayable extent then go for it. You end up supporting all the way to Win 95 and perhaps even before.

Advertisement

Yes, this is in fact how people made games for Windows 3.11 and earlier. Late in Win 3.1x WinG was introduced, which was a precursor to and replaced by DirectX (DirectDraw) in Win95. Note that I believe WinG was completely deprecated in Windows 98, so you definitely don't want to go that route these days. Some of those concepts from WinG did remain, though (Device-Independent Bitmaps, for one).

If you google “win32 wing” you'll get some good info on why that came into being, and what the drawbacks to GDI were for games.

As stated above, it's completely possible to make games using plain old GDI. And especially with computing power being what it is these days, I'd imagine you'd have to move past moderately involved graphics to see any perceptible performance impact (i.e.; simple 2D games without a lot of DC updates should be no problem).

I'm using GDI as fallback for simple 2d games.

AFAIK WinG was incorporated into plain GDI. So not futzing with BitBlt and similar, but using DIB sections.

CreateDIBSection is your friend. You get access to the bitmap data and can (or rather, have to) modify the bytes/bits yourself.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

MFC is mostly a wrapper providing a C++ OOP wrapper over parts of the Windows API. You can create Windows, use GDI, etc. with or without it.

You can certainly use it for games, animations, etc. as you can redraw the whole thing or a part whenever you like, not only when requested by the system (resize, when a window on top moves, etc. especially historically, before the "Desktop Window Manager"). Performance is obviously less than say D3D or OpenGL, but modern computers are fast, and many programs don't need high framerates.

As mentioned you can use all the GDI drawing functions for shapes, text, etc. or get a bitmap and create your own utilities to draw directly into that.

wxWidgets is an alternate option that comes to mind that wraps the native API, with real native child windows, I think including using GDI for a complete drawing solution rather than implementing is own custom renderer on top a simple “top level window” as a lot of libraries do.

I was wandering how far people went with it (with using GDI). If you think about it, being able to access individual pixels, as Endurion pointed, means that you could even write a 3d renderer (software/without GPU support of course)

So from what you`re saying it looks like the only limitation is speed.

[Edit] I don`t want to stir the water too much with this topic (when you get overwhelming response people expect you thread in the same direction which I`m not going to do). People begin to know me and I don`t want to pose as someone who throws himself in 1000 topics and has no followup on any of them.

My project`s facebook page is “DreamLand Page”

Advertisement

Win 3.x was essentially the era of “here's framebuffer memory, write your pixels", and most games were DOS games doing exactly that. Some games were ported to win32/GDI and just used GDI to get at the “framebuffer", which in this case was the display memory for a window. However, pre-DirectX, this involved making copies to give you to write into, along with other Windows overhead that at the time was often prohibitive for performance-intensive games. Keep in mind that at that time, people would be doing things like writing hand-tuned assembler to do 32-bit memcpy for updating framebuffer memory and highly-optimized Blt operations. The targets for optimization these days are MUCH higher-level, and copying a 64k texture would not even appear as a blip in the profiler respective to what other computations games do these days. Heck, we spend as much computational power shading a single pixel these days as we did for a whole game loop back then.

Sure - not recently, though, but I did use GDI from 2003 until around 2009. I won't say I miss it, but I do look back upon the projects with nostalgia. I'm sure we all feel like that about the projects we made our early games with. HDCs will always have a special place in my heart, as will bitblt.

This topic is closed to new replies.

Advertisement