Game Engine Gems

Game Engine Gems 1 By Eric Lengyel is a book I discovered on Amazon, but really hadn’t heard of or seen talked about anywhere else. I do recognize the editor, Eric Lengyel, as the creator of the C4 Engine and author of the classic textbook Mathematics for 3D Game Programming and Computer Graphics. So I was going in with high hopes. The book is a compilation of various short chapters focusing on a specific topic pertinent to game engine development. The contributors all appeared to be seasoned game developers from the likes of EA, Codemasters, NaughtyDog, and so forth. Really a great pool of talent and lots of interesting tidbits lay on these pages (or on the screen, rather, since I read it on my Kindle Fire tablet).

Some of the 28 different topics covered include: evaluating middleware, the game asset pipeline, volumetric rendering, path-finding, sound culling, stereoscopic 3d, multi-threading, memory pools, fluid dynamics, physically-based rendering, screen-space ambient occlusion, and some various odds and ends. Just looking at the list of topics you would think the work would be a 1,000 page tome. Unfortunately (or not, depending on your preference), the book is only around 350 pages. That did make for a quick light read, and I finished the whole thing within a few days. On the other hand, I felt like some of the topics were too brief and could have used more detail. In particular, the chapter on stereoscopic 3d was a joke and didn’t even touch upon how to write a stereo renderer. It talks about some different 3d methods used in films (active vs. passive 3d, etc.), which is interesting, but has nothing to do with game development. Seeing as that was one of the main reasons I picked up the book, I couldn’t help but feel slightly cheated. To be fair, many of the chapters are done well and did add to my knowledge of game engine development.

Most useful, I felt, were the chapters on multi-threading (there were a few) since this is a field I am pretty weak in. I also very much liked the chapter on sound culling, as it presents a pretty complete implementation and is something I never even considered but seems like a great optimization. One thing to keep in mind, is that this is not a cookbook. There is code in many chapters (well usually pseudo-code) but rarely is there anything you can expect to straight cut and paste. The way the book is organized, its more like general concepts and algorithms, in a manner to give you enough information to do your own research or implementation. I realize some people just want drop in solutions, and they probably won’t find that here. But if you are intelligent enough, you can take a concept and run with it. It’s up to you.

To be clear: Game Engine Gems won’t give you all you need to know to create a game engine. Far from it. It really doesn’t discuss a lot of basic things (like DirectX or OpenGL, which are barely touched upon) but chooses to highlight some specific narrow topics. I think it’s a great complement to more technical books you might find on game engine architecture or graphics programming in general. For sure, it is a worthy addition to my growing game development library. I’m also very much looking forward to the second book in the series, and really hope they deliver with the stereoscopic 3d coverage. Another one to recommend.


Today I have finally gotten a simple sort of animation working. It looks easy, but I made my life a lot harder by implementing by own math library. So far I have a Vector3D and a Matrix4x4 class almost finished. Well the Vector class is pretty much done. The Matrix class still needs some fleshing out, but I got it working well enough to spin a triangle. I realize I could have used the D3DX library (which is deprecated), or XNAMath (also deprecated), or DirectXMath (safe for now), but I thought making my own math functions would be a good learning experience. I did also have to reimplement D3DXMatrixLookAtLH and D3DXMatrixPerspectiveFovLH, but Microsoft is nice enough to list the equations in their documentation (thanks!).

In addition, I got a lot of help from this book, 3D Math Primer for Graphics and Game Development, which may be one of the best I’ve seen for 3D math. While there are other books, this text has very clear explanations, equations, and actual C++ implementations. I did try my best not to “cheat” and just copy the code, and instead based it on the equations listed. Unfortunately, I got cocky and wrote the length function without checking the reference, and left out the square root function call by accident (resulting in about a hour of debugging). Eventually I figured it out, but not after checking pretty much everything else with a fine-toothed comb. No worries, it’s working now.

Feels nice to see some movement on the screen. For this week I’d like to get a textured cube spinning. Also, I realized that DirectX 11 doesn’t come with a way to import models out-of-box. So pretty soon I will probably have to write a model importer (I’m looking at COLLADA now). Sometimes I wonder if all this work is really worth it, especially with Unreal Engine 4 at $19/month at the moment. I guess I do realize I can likely never hope to compete with the big commercial engines, but I still think this is a great exercise of the mind. We’ll see how long I can keep my faith.

engine zero triangle

So I buckled down and spent the better half of the day actually getting something to show on the screen. Yes, it’s still just a triangle, but it feels pretty satisfying after struggling to get it to work all morning. While there are tons of triangle tutorials online, and it would seem like a 20 minute hack, I ended up having some difficulty for a few reasons.

One, I decided last night to upgrade to Visual Studio 2013 so I could take advantage of C++11 and the 64-bit compiler. Right off the bat, this resulted in a bunch of warnings. I eventually found the instructions to clean this up here, and it ended up not being a big deal.

The second issue was with compiling the HLSL shader (currently, it just passes along the position and color attributes without any fancy math). It turns out the D3DX11CompileFromFile is deprecated as is the whole D3DX library. I guess I could have still used them anyway, but what fun is that? So I decided to remove the D3DX dependency and either move to newer functions, or reimplement certain classes completely.

Luckily there is a function called D3DCompileFromFile, which does the heavy-lifting of compiling a HLSL shader file. However, for some reason shader files from tutorials I was following did not seem to work correctly with the new additions. After tweaking it for a bit, and a lot of trial-and-error, I was able to get something built. I know it seems rather silly to have spent hours on this, but hopefully once I get this foundation built things will become easier. Here is the (dirt simple) shader file if anyone is having similar problems.

struct VS_OUTPUT {
   float4 pos : SV_POSITION;
   float4 color : COLOR0;

VS_OUTPUT VS(float4 pos : POSITION, float4 color : COLOR) {
   VS_OUTPUT output;
   output.pos = pos;
   output.color = color;
   return output;

float4 PS(VS_OUTPUT input) : SV_Target {
   return input.color;

Next up, I want to get in texture mapping, finish the Vector and Matrix classes, and make a spinning cube. Stay tuned.

Beginning D3D11

Beginning DirectX 11 Game Programming by Allen Sherrod is, what I’d consider, a great introduction into DirectX programming. Just to be clear, it’s really only an overview of the DirectX APIs (Direct3D, DirectInput, etc.) and not really a graphics or game programming book (despite the title). So there is very little in the way of actual gameplay type programming, as you never really get to the point of having any sort of game demo. In that same respect, you don’t really deal too much with computer graphics theory, though there is some brief coverage of lighting models in regards to shader programming. That said, what is in the text is a good start to learning the DirectX 11 API and getting some foundation knowledge of the Windows platform.

The book covers basic Win32 window creation, initializing Direct3D, error handling, basic 2D graphics concepts, font rendering, input handling (with Win32, DirectInput, and XInput), fundamental 3D math (vectors, matrices, coordinate systems), cameras, and 3D models. Overall a good amount of topics, and decent coverage of the building blocks for working with the DirectX 11 SDK. While I wouldn’t say the book is for “beginners” (as nothing involving DirectX or Win32 is really for novices), it doesn’t go into as deep a depth as something like the Frank Luna book (which covers more interesting topics like normal mapping and shadow maps). However, I did find the discussion at the end about loading the OBJ 3D file format into Direct3D to be unique, as most books do not go into this.

So do I think Beginning DirectX 11 Game Programming is worth reading? Certainly. It was an approachable read and the Kindle e-book was moderately priced at around $25. For sure, if you are working with the DirectX 11 SDK you will want all the help you can get. Granted, I think some of the other titles I’ve seen had more impressive demos, or deeper coverage, but I felt this was a fine introductory text. I’d even go as far to say that you should read this book first, as it presents the basic knowledge in a way that is much more to the point and not as daunting as some other resources.

The one thing, which is both exciting and sad, is that I believe this was the last DirectX 11 book available on Amazon that I haven’t read. I see there are a few newer books covering DirectX 11.1 or later, but I’d really like to stick to straight 11 due to Windows 7 compatibility. So, at this point, I think I maybe have got as far as the introduction books will take me and I will have to just start developing with it and learning as I go. Not a bad problem to have. Although I still have a few general game engine books in my backlog, I’m feeling more confidant about getting into the trenches of development with my engine and this book has definitely helped.

I know it has been quite some time since the last update, and I thought I would be much further by now. Truth be told, I have been a little distracted the last few months with things totally tangential to graphics programming. In any case, I’ve had some motivation recently to continue on the 3D game engine and began doing further research and reading. However, research doesn’t get results on it’s own. 90% of the time, you just have to start doing whatever it is you want to do whether you think you’re ready or not. So that brings us here, to this totally underwhelming screen shot.

Engine Zero Blank

Yes, it is a blank pink screen. You can calm down. What you are not seeing is some basic boiler-plate code to initialize DirectX 11, clear the back-buffer to a plain color, and the basic Win32 message pump. I have also started to give some structure to the application, with a namespace and class that encapsulates the Direct3D related code. Right now it is a bit hard-coded for a lot of stuff, but I wanted to get it working first and then I can refine and refactor as needed. I’m actually feeling really excited about the prospects of having my own 3D engine, and hope to power through a lot of this foundation stuff so I can get some interactive demos up and running. If everything goes well, I plan to publish updates in this series more frequently as I progress. Thanks for watching.

technolustNow this is my kind of game: a cyberpunk first-person adventure set in a dystopian future. Native Oculus Rift support. A NSFW TRON poster (though I bet they will take that out). This just looks too awesome for words. I backed the Kickstarter for $50 bucks, but I’m willing to up the ante later in the campaign if necessary. Really anyone with an Oculus Rift, or that plans to buy a Rift, should throw some money down on this project. Of all the things I’ve played in VR, I think this is my favorite. And I’ve played a LOT. Get on this.