It’s late 1995, and the transition from DOS to Windows 95 is a nightmare for game developers. In DOS, we had total control-we could write directly to video memory at 0xA0000 and get every ounce of performance. In Windows, we’re stuck with GDI, which is about as fast as a snail on a cold day. But Microsoft has finally released the "Game SDK," and at its heart is DirectDraw.
Bypassing the GDI
DirectDraw isn't a high-level drawing API. It’s a hardware abstraction layer that gives us a pointer to the "surface" of the video memory. It allows for hardware-accelerated "blits" (block transfers) and page flipping, which are essential for smooth animation.
// DirectDraw: Getting a pointer to the front buffer
DDSURFACEDESC ddsd;
ddsd.dwSize = sizeof(ddsd);
lpDDSPrimary->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
unsigned char* pVideoMemory = (unsigned char*)ddsd.lpSurface;
// Now we can write to pixels just like in DOS!
pVideoMemory[y * ddsd.lPitch + x] = color_index;
lpDDSPrimary->Unlock(NULL);
The End of the "DOS Prompt"
For the first time, we can write a game that runs in a window or full-screen without losing that raw speed. It’s not perfect-COM (Component Object Model) is a bit of a chore to work with, and the documentation is sparse-but it’s the bridge we needed.
A New Playground
We’re seeing the first wave of "DirectX" games hitting the shelves. If this takes off, the PC might finally become a unified gaming platform instead of a collection of incompatible sound cards and video drivers. I’ve spent my weekend rewriting our sprite engine to use DirectDraw surfaces, and the frame rate on my Pentium 90 has doubled. The DOS era is officially closing.