
Ok, so it's not much. There's a blue dot in the upper lefthand corner of the screen.
My understanding was that one would use DirectDraw for 2D sprite rendering and Direct3D for, well, 3D rendering. As it turns out, DirectDraw is completely depricated in DirectX 9, and may have been for several versions now. What I found out was that I should use Direct3D to draw images on flat surfaces. Fortunately this requires no 3D work at all and Direct3D has classes to facilitate this.
This little application bascially requests a full screen from the hardware with a back buffer to draw to. It would seem I do not need to manually draw to the back buffer and flip it to the front like I would in DirectDraw, Direct3D seems to handle that aspect for me. After a full screen has been presented I setup a sprite using a .tga file I created in GIMP (a blue dot in this case). Finally I overloaded the OnPaint event of the (full screen) window and told it to draw my sprite there. The OnPaint event ends by calling this.Invalidate() which basically means that OnPaint will be called immediately again, thus running a very, very game loop. Each time the screen is obliterated and the sprite redraw. Again, there seems to be a back buffer here but I'm not managing it. All the better. Our little application also overloads the OnKeyUp event so that an escape keypress will end the application.
This simple code will form the foundation of the graphics abstration layer. I need to wrap some classes and such around this so that these nuts and bolts aren't something I need to worry about as I write the game presentation and logic. I think I'll work on that next.
Nice work. Sometimes it seems the most trivial stuff can really tear down a progress block so this is a good start. Why are you using Direct X9? Isn't Direct X10 the current hotness? Or is that only with Vista? I don't do a lot of PC gaming so I'm clueless.
ReplyDeleteThat's interesting you went with graphics first. I would have gotten right into logic and planning out classes. Graphics are prettier and more interesting though :)
DirectX 10 is the latest, but yes I'm pretty sure it requires Vista, and I'm developing on an XP machine. DirectX 9 will be more compatible with more systems. Besides, when I downloaded the SDK I only say the DX9 one, so I'm assume the DX10 SDK is for fancy developers only? There's certainly nothing that DX10 offers that I would take advantage of. Gears of War 3 this is not.
ReplyDeleteIn regards to doing some graphics work up front, I wanted to see how the basic game loop would look before I started planning how the game logic itself would be structured. Now that I understand the fundamentals there, I can start to see how a game object is tied to a sprite, and how a sprite is tied to the core guts of the thing.
Silly Eric. Sprite is a drink! No wonder you're so confused.
ReplyDelete:-)
Jk jk, bff. Too bad I'm not as smart as you.