Archive for December, 2006

Reasons for a Rewrite

Saturday, December 16th, 2006

I think we’ve touched on this in our news posts, but perhaps a little more explanation would be good. As I mentioned in my previous post, our code really started from my early attempts to learn OpenGL. While we did some refactoring as we went, the code is not structured well. For example, when I was starting out and I just wanted to see if I could draw a triangle on the screen or if I could actually load a heightmap, I didn’t create a vector class. That just makes for a lot of ugly and duplicated code. A ship is a class that has a “draw()” method with a bunch of OpenGL code, and a few float members for the position, rotation, and speed. A city is similar. It has a “draw()” method with OpenGL code, and members for position and rotation.

It seems like pushing some of that into something like an “Entity” class would have made sense. Also, the way all the raw OpenGL code in methods worked was pretty ugly. Some objects changed the render state in order to achieve a certain effect. As a result, the order things get drawn is very important. All of that works fine if you just want to see if something will show up on the screen, but all of the interdependencies make it really hard to maintain and add new functionality.

Anyway, that’s the kind of thing that made us decide to rewrite from the ground up. We are writing an engine separately in order to force the separation of game logic from the framework code. A lot of our ideas are driven off of Game Coding Complete by Mike McShaffry. We are trying to use existing open-source libraries as much as possible. We could just using an existing game engine, but it seems like this approach is a good mix of our desire to get a good game working and our desire to learn and try out some ideas.

We are making progress on the rewrite, and I think our new foundation will be much more manageable than what we have now. Look for more updates as we make further progress.

History of Crown and Cutlass

Wednesday, December 13th, 2006

Collin recommended this post. He may follow up with his thoughts as well.

Crown and Cutlass started while I was in college. I took a graphics class one semester which I really enjoyed. Unfortunately, it is the only graphics class my school offered, so we didn’t get much more than an introduction to most subjects. We ended by working on OpenGL. That was very cool. I enjoyed seeing the result of my work as images on the screen. However, while our lab machines had decent video cards in them, we ran NetBSD with the OSS drivers. All the OpenGL was done in software and it was slow!

It was frustrating to hardly be able to keep a decent framerate going. My scenes were very simple, but just adding textures killed the framerate. I knew I had played commercial games that ran much better than my projects on much lower spec’d hardware. Also, we didn’t really talk about model loading or animation, so I hard-coded every surface of my scenes. While it was fun for a while and I guess it more or less worked out, I felt like I was missing a lot.

That summer I purchased OpenGL Game Programming by Kevin Hawkins and Dave Astle. I started working on some little demos to get a feel for things. I was excited to try out some terrain rendering. I thought having a project to work on would be a good way to direct my learning. That project eventually became Crown and Cutlass.

I had a little page on my school web page with some screenshots where I occasionally posted the source. I was not using source control or anything. As graduation approached I decided that I would start a project on SourceForge.net. However, at that point, I was still referring to it as either “the pirate game” or “my pirate game”, so I needed an official name. I wrote a webpage that allowed people to suggest and vote for names for the project and asked for input from GameDev.net. Most of the suggestions were not very helpful, but one of my housemates suggested a few names like “Cutlass and Cannon” or “Cannon and Crown”. After a few minutes of playing with those ideas, I settled on “Crown and Cutlass”.

After graduation, I registered for a sourceforge project. A little while later, Collin agreed to join. We made substantial progress (you can see it in the screenshots), but it was still all based on the code that I started while I was learning how to use OpenGL, and in many ways still learning some basics of how to program. Recently we have decided to rework from the ground up to attempt to lay a better foundation that eliminates a lot of issues with our existing code. We are attempting to write an engine to separate the game code from the underlying engine code. We are calling it “Protocce” for now. I’ll talk more about the rewrite later, though.

That’s a quick history. It has been a really interesting process so far, and I’m excited about where we are going.

Thoughts on Engine Design

Wednesday, December 13th, 2006

I just recently discovered GameArchitect.net. I’m not sure how I haven’t seen it before, it has been around for a long time. Anyway, there is a lot of good stuff there about writing games, including a lot of real world issues the author is facing as a professional game programmer. If you are interested in writing games, that site is worth checking out.

On a semi-related topic, this thread on the Ogre forums is really interesting. That stimulated a lot of good conversation about how we can structure our engine.

Ubuntu and boost::serialization (updated)

Saturday, December 2nd, 2006

We are looking at using boost::serialization for our serialization needs in Protocce. However, I cannot get even a simple test to work in Ubuntu, so I filed a bug. It works fine in Visual C++ 2005 Express, but you do not have to tell VC++ which libraries to link. It handles that automatically using #pragma directives. I’m not sure if I’m doing something dumb like not linking in a library I should, but I tried adding several other boost libraries to the command line. It didn’t seem to make a difference. Collin had the same errors, so it seems like either we are missing a library or there actually is a bug.

Update: Posted to gamedev.net and figured out that I just needed to put the “-lboost_serialization” at the end of the command. That’s good to know!

Ogre

Friday, December 1st, 2006

I have been working on our Ogre test application quite a bit lately. I purchased Pro OGRE 3D Programming by Gregory Junker and finished reading through it over during my flight home for Thanksgiving. While it is a good read, it is very much an introduction. I do not believe there is anything in there that you couldn’t find in the Ogre tutorials or on the wiki. However, it is a good overview of Ogre and I am glad I read it. I have a much better handle on how Ogre is designed and how to approach it now. I’m just not sure it’s worth $40.

As I said in a previous post, I am compiling Ogre from CVS. Since Ogre 1.4 is supposed to be out around the end of the year, we decided to just use it directly. It seems to be working well so far, with one exception. However, I think that’s probably something dumb that I am doing, so I’m going to try a little more to fix it. It seems like Ogre 1.4 will be a good change, but I have some concerns about the license change.

I think it is fine for them to have a dual-license to allow use on platforms which don’t allow dynamic linking or in commercial projects that don’t want to abide by the LGPL. However, it is surprising to me that they have asked contributers to agree to this new license without presenting the license itself. I do not expect the Ogre team to do something underhanded, but it is still just not wise to agree to something without seeing it, and not sensible to ask your community to do that. I think that is especially true when the new license will include payment for use under a non-LGPL license. Where will the money go? How will it be used? Will contributors get any kind of share? What about people who contribute in non-coding ways (e.g. documentation, testing, tutorials, etc.)? It seems like those are questions that need to be answered before asking developers to agree to a licensing change.

Note: I have not contributed to Ogre. However, because of these concerns I do not believe I would until they publish the details of the final license.