Day -1 of NaGaProMo (October 30) found me trying to familiarize myself with DirectX 11. I wasn't starting on my game yet, but I did want to get a head start on learning how to draw graphics on the screen. The only time I'd used DirectX before was when writing a small test program using Microsoft's XNA tools. XNA is an SDK that works with Visual Studio to simplify the process of making games with DirectX 9. This simplified approach worked well, but I never did get far with my program.
Since then, shaders have taken over the graphics scene and DirectX 10 and 11 have changed drastically to accommodate this new paradigm. I figured this wouldn't be too difficult to relearn because I hadn't really learned the old DirectX 9 / XNA in the first place. So I found a nice looking tutorial on DirectX 11 and got to programming a simple test program. My goal here was to get some cubes and other shapes on the screen and maybe have some user input to either move one of the shapes or the camera around. Using XNA, that was easy enough to do in an hour or so.
After an evening spent going through tutorials with DirectX 11, I had a triangle on the screen (which the tutorial did for me), and I could change the color of it (which I did myself!). I could also change the points of the triangle, or make a second triangle, but user input eluded me. The graphics pipeline that went through all of the various shaders seemed overly complicated and left me more confused than when I had started. Discouraged, I didn't do any more programming until NaGaProMo Day 4 (November 4th).
In the interim, I debated using XNA again, but this had a few downsides. First, it would require me to use an older version of DirectX. By itself this wasn't an issue, but I also look at NaGaProMo as a good chance to learn some new programming skills. I'd prefer to be using and learning the most up-to-date tools. The second issue was that XNA only works with older versions of Visual Studio. Once again, this would be an out-of-date tool. Finally, I've read some posts online that indicate XNA games may not run on Windows 8, which is my current OS. Ultimately, I ruled out XNA for this project.
Once I decided to try again with drawing some graphics, I switched gears to OpenGL. This immediately set me on a search for compatibility between OpenGL and C#. Most graphics libraries tend to be written for C or C++ for performance reasons. Therefore, OpenGL is not directly compatible with the managed framework offered by C#. Fortunately, OpenTK offers a solution to this problem by wrapping the OpenGL libraries in managed code. This makes it a bit difficult to follow OpenGL tutorials and references because the names of most OpenGL methods and variables have changed, but there are some easy tricks to deal with these changes (expect another post with my methodology for this).
OpenTK has a quick tutorial that gets some graphics on the screen in a simple (though not quite as simple) manner that is reminiscent of XNA. It starts out with a basic triangle again, which seems to be the equivalent of "Hello, World" for graphics, but the code was much simpler to understand. This got me excited for my NaGaProMo game again.
My next step was to add some debug capabilities to the window in the form of a text overlay. Initially, I wanted to add a frames-per-second counter in the corner. A couple tutorials talk about text overlays, but none of them seemed to work. They all focus on creating a texture with the desired text and a transparent background, and then applying this texture to a quad (four-sided polygon) that fills the screen. Mostly, this just ended up hiding my "Hello, World" triangle and not showing any text. This consumed the remainder of NaGaProMo day 4 and part of day 5.
While I still don't have the text overlay working, I changed tacks once again and sought out recommendations for better OpenGL instruction. Different people tend to have different favorites, but the overall recommendations I was finding can be summed up by this answer on Stack Exchange. One thing this research indicated is that the OpenTK tutorial seems to be the old, pre-shader method of programming graphics that was common in OpenGL versions 1 and 2. This is known as fixed-function pipeline as opposed to the newer shader pipelines that are used in OpenGL 3 and 4.
Ultimately, I settled on two sources for learning OpenGL 3/4:
OpenGL SuperBible - 5th edition
Learning Modern 3D Graphics Programming (online tutorial by Jason L. McKesson)
I ended up buying the Nook version of the OpenGL Superbible from Barnes & Noble (that whole shopping experience did not go well), and also started working through the tutorials for Learning Modern 3D Graphics Programming. Hopefully, I'll begin making some progress and can actually get to the game portion of this project before the end of the month! If not, maybe December will become NaGaProMo instead.
No comments:
Post a Comment