Archive for the ‘Ogre’ Category

I made the switch (or I am trying to)…

Wednesday, October 31st, 2007

I have finally done it, I bought a Mac. A few weekends ago, I bought a MacBook Pro and then last weekend I upgraded to Leopard. The computer was expensive (I got an academic discount and the upgrade to Leopard was basically free, but still…) but it sure is a nice machine. I now have a video card with decent shader support, so I am excited to play around with that. It is also nice to have a unix-based machine with decent driver support out of the box. The wireless card actually works! Amazing! However, I really feel lost trying to do development in OS X and in some ways I feel lost just trying to use the computer.

I really have not quite gotten used to the way the filesystem is arranged. I guess I am comfortable with it not being like Windows, but I want it to be like linux. In Windows, there is no “/usr/lib/” or “/usr/local/lib/” for libraries so you put them somewhere else (like “C:\OgreSDK” or in program files or something). In OS X there is a “/usr/lib/” and “/usr/local/lib/” but it looks like the preferred place to install libraries is into “/Libraries/” which is just weird. Which should I use? Should I treat it as a unix machine, or embrace the weird OS X stuff?

The keyboard also is a little annoying. I want a “home” and an “end” key. I want a “del” key that is separate from the backspace key. I guess you can do “command-right” to get to the end of the line, but that does not seem to work consistently in all applications. I also really think only putting one mouse button on the laptops is a poor decision. And no, I don’t buy the argument that using modifier keys for things like that or to get a right-click is somehow more efficient.

I am also trying to figure out how to get dependencies for Protocce installed. Ogre was really easy since they provide a framework. If I remember correctly from his blog, Steve Streeting got a Mac recently so OS X has a higher priority on the Ogre team. The ogg and vorbis packages came with XCode projects to make frameworks, so building and installing them was really easy. I couldn’t find a binary boost distribution, so I built/installed it just like I would have in linux (“./configure && make && make install”). That is what boost recommends, but I’m not sure that is the OS X way to do things. At this point though, I don’t think there is reason to go through the trouble of making a framework (and really figuring out what frameworks are all about, how they differ from bundles, what a bundle is, etc.). Unfortunately, OS X support in CEGUI seems to be lagging behind. CEGUI seems to be kind of quiet lately anyway (Crazy Eddie appears to have left the project, hopefully it can rise from the ashes and continue strongly eventually). I am going to try building it from SVN where I hope the OS X support is a little better.

XCode seems like it will be nice. I need to try a “hello world” project in it, but it looks like CMake can generate XCode projects. That will be save a lot of work, since it will shield me from having to set up a project manually until after I see how Xcode handles projects a little. I’m sure it’ll still take some getting used to, but I’m interested to see how it compares to Eclipse with the CDT and Visual Studio.

Anyway, if you have tips on getting started with development is OS X, let me know. I found Apple’s getting started page and it seems there could be some good stuff in there., but I have a lot to learn.

Why I’m Excited About the Rewrite

Thursday, August 23rd, 2007

I have mentioned that I am really excited about our rewrite several times, but I haven’t ever gone into much detail about why that is. I hope that we have learned from what worked and what didn’t work in the old Crown and Cutlass code, and applied those lessons to the new Protocce code. I’m sure there are still things that we will realize are not well done, but this is a much more stable base for future work. Here are several specific things I’m excited about:

Exception – We implemented the pcce::Exception class which we now use consistently for error reporting. Coupled with our greater focus on RAII (see below), I think we have made some serious progress. We used to use error codes sometimes and throw other times. Unfortunately, sometimes we threw strings, sometimes we threw char *’s, sometimes we threw ints, etc. This is much better. It does not descend from std::exception at the moment, but we are thinking about doing that.

Greater focus on RAIIRAII is really a great idiom for resource management in C++, especially when coupled with smart pointers like boost::shared_ptr. We have design for RAII from the start, so that should make things much more manageable. Again, I’m sure we have more to do in this area, but we have a good start.

Variant – At work, I have gotten used to using the Win32 Variant class in Delphi. While it certainly has its drawbacks, it sure can be helpful for doing things like reading text from a config file. Our variant class is cross platform, and based on boost::variant. I think it will change a little as we use it, but I’m pretty happy with it now. You wouldn’t want to use it when a statically typed variable will do, but for example the config system was really easy to do using Variant.

PropertyBag – Again, at work I got used to using “property bags” which are basically just a map from a string to a variant value. You wouldn’t want to replace all of your normal classes with a property bag (static typing can be nice!), but it can be really useful. For example, our configuration system is an INI file. That gets loaded into a property bag. When you initialize a subsystem, you pass its settings as a property bag. That way, you can change the config options around without changing the config object or the method signature. We have also used property bags to create “game objects” which are just property bags with a couple of predetermined fields for model name, texture, etc. The game programmer can put whatever else he wants in there.

Consistent use of shared_ptr – I really don’t mind managing my own memory, but once you start talking about exceptions and RAII, using some kind of smart pointers really makes sense. We are making pretty serious use of boost::shared_ptr, which has made a lot of things easy. No need to worry about who owns an object, as long as you have a shared_ptr to it, it will stay valid. Of course, we have to think about circular references, but overall I think using smart pointers is a big win.

OGRE – I think it’s pretty clear why I am excited about OGRE. Originally, the project was just an excuse to do OpenGL programming. I enjoyed that, but now I am more interested in other things. I’m a little sad not to get to try that from the ground up, but eventually we can revamp Protocce to use a custom engine if we want. Until then, using OGRE will simplify our code, standardize our models (our old model loading code was really picky), and open up the doors to easily implementing graphical improvements. It will also allow us to focus on the game itself, rather than the details of the graphics.

EventSystem – Our old code used to be very tightly coupled (see the SailingState for an example), so minor changes could not only cause a large number of units to need to be rebuilt, but also end up causing a large number of code changes. The event system is based on what is mentioned in Game Coding Complete and allows us to significantly decouple our code. Once an event is defined, you can register a boost::function to receive that event. Events can be dispatched immediately, or queued to be dispatched once per frame. I expect the way that will work is that game events will be queued, while internal “plumbing” type stuff will be sent immediately. As an example, the input subsystem needs a window handle to receive input. Rather than connecting it directly to the render subsystem (which would force you to initialize the entire render subsystem if you wanted to use the input subsystem), the input subsystem just sends an event that the render system receives. If you don’t want to use the render subsystem for some reason, you could just register a different handler for that event. Collin actually does that in the input test. As I mentioned in my previous post, the sound system is also event driven. It is running in its own thread, and all the main thread does is send an event that says “play sound X” or “stop sound Y”. That data is easily sent out to the other thread, where the actual sound code handles it. We can totally revamp the sound implementation and not touch client code at all. I think the event system is a much more flexible system and I think it will open up a lot of doors for us.

Improved resource management – I mentioned this a little in my last post too. Between the release of Alpha 1.4 and the decision to start the rewrite, I wrote a resource management system. It was pretty good. It would make sure that only one copy of a texture, sound file, or model was loaded at a time and used reference counting to automatically unload the model when it was finished. I have further refined it (partially based on the OGRE resource system) and posted a reply on gamedev explaining the Protocce resource system.

Anyway, there are other things but that is a decent explanation of the things that I am excited about.

New Computer

Wednesday, August 15th, 2007

*Warning* Gloating post ahead!

Over the past 4 years or so, I’ve had some computer drama. I bought a Dell laptop 4 years ago. It was about as good as you could get at the time. Pentium 4, GeForce 4200, 15.4 inch wide screen. It was pretty slick. Unfortunately, almost immediately I started experiencing problems with it. It would be running along happily and suddenly shut down for no apparent reason. No error message, no nothing. I shipped the computer back to Dell and a few weeks later I got it back.

It worked happily for 2 more years, when the video card went bad. It was still under warranty (and I thought it was a waste of money to get the extended warranty) so Dell replaced the video card. Apparently they didn’t have a 4200 any more so it was replaced with a GeForce 5600. Pretty sweet! Except that it ran too hot and my computer would again just shut down when it got too hot. After sending my computer back to Dell 4 or 5 times over 6 months (sometimes they wouldn’t actually change anything), they agreed to replace the laptop with a refurbished machine. Sweet! So again I had a really nice laptop, Core Duo, 17″ screen, GeForce 6800, life was good.

Then, 3 months ago, while playing Winning 11, the video card went bad (weird that its been the video card more than once). At this point it wasn’t under warranty any longer so I was stuck. A new video card from Dell was $300 (not including installation) and if I installed it myself, there would be no returns for a defective product. It wasn’t worth the risk or price.

Which leads us to the new machine. I decided I didn’t want to totally break the bank, but I wanted something I could upgrade later. So I got a pretty sweet processor, a Core 2 Quad. I decided most of the other pieces of a computer are easy to upgrade, but I wanted my processor to last. I don’t think I realized what a difference it made until I compiled Ogre. On David’s machine (which is the exact same laptop I had originally) Ogre takes 25-30 minutes. On my core 2 laptop, it took in the 15 minute range. On my new machine, Ogre compiled in 3 minutes!

All that to say I’m really excited about my new machine.

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.

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.

Trying Ubuntu

Tuesday, November 28th, 2006

I dual-boot my laptop with XP and Linux. I am using Linux more and more lately though. Now I pretty much only use XP to try compiling something in Visual Studio, or to play the occasional game. I have traditionally been a RedHat/Fedora user. However, I am getting tired of downloading 3.5 gigs every 6 months to reinstall Fedora. I haven’t had luck in the past with upgrading from one version to the next, although admittedly I haven’t tried it in a few versions. Anyway, I finally decided to try out Ubuntu. With a few dumb exceptions, it seems pretty slick. It was a single CD download, the install was easy, and I managed to get the old Crown and Cutlass code running successfully. However, I am surprised how much work it is to set up a development box. I expected that I’d be able to just check a box for “Development Tools” in some install dialog. Instead I had to install each piece separately. Some things were installed in the “build_essentials” but that was pretty minimal. It seems like almost everyone who installs gcc will want the autotools at some point. Native Eclipse also seems much slower than in Fedora 5. It is almost unusable. However, since Sun has opened Java, I’m hoping that Eclipse will work better out of the box in the next release.

My main issue with Ubuntu is the age of some development packages in the repositories. For example, the Eclipse CDT is one version out of data while Eclipse itself is the most recent version. Even worse, the version of Ogre in the repository is 1.0.7 which is almost a year old! As you can imagine, a lot has changed between 1.0 and 1.4. Our Ogre test doesn’t even compile with it. As a result, I have had to compile my own version of Ogre. That’s not too bad, but it would make things a little easier if I didn’t have to. We talked about contributing a new package, but decided that since we will need to do some compiling anyway it would be better to use the CVS version of Ogre. That way when 1.4 is released we will not need to unlearn anything, and hopefully we’ll be ready to start releasing some code before any more major version changes in Ogre.

Anyway, it just doesn’t seem like developers are the target audience for Ubuntu. So far things seem to be working well enough that I don’t want to go through the trouble of returning to Fedora, but a little better developer support in Ubuntu sure would be nice.