Monday, March 19, 2007

New Config System

The latest addition to the GE2 is a new config system. Config system is an important part of any game. This is how all the game parameters that game designer wants can be changed.

For my config system, I did a little research to find the most easy to use API for the engine to create. I first decided to use lua which is really impressive scripting language, however it didn't actually suite my needs for the config system well enough.

So I decided to use the good old similar to xml way. Something like this I have already implemented in the first galactic engine. This time I tried to avoid many possible issues and have redesigned it a little.

This is the actual config file I am using right now  (config.cfg) :

<config>
         <video>
                width = 640
                height = 480
                bpp = 32
                fullscreen = true
                vsync = true
                    <texture>
                        compression = false
                        preload = false
                        quality = 1
                        mode = "GL_MIPMAP_LINEAR"
                        anisatropyX = 1
                    </texture>
            </video>
</config>




The primary point here is that the structure of the config shows the dependency of different engine elements, such as the textureManager on the video system. The parsing of such file would be very straightforward and easy to do.

The config itself consists of 2 parts. The ConfigReader and ConfigWriter. Reader - reads the config and writer writes the config, pretty easy. I treat each config as a collection of blocks. Every config has at-least one block - the root block.  Every block can have a number of other blocks - child blocks and fields. Fields are the parameters that block stores.

In order to open the config this is all it is required to do:

ConfigBlock *block = config.reader.Open( filename );
config.reader.Close();


for the writer the operation is mostly the same, however with a few exceptions:

ConfigBlock *block = config.writer.OpenAndReplace(filename);
config.writer.Save();


As you can see here, the config is opened with OpenAndReplace command. It can also be opened with OpenAndMerge command. The difference for the writer is that if the config is opened with replace command, then the old file would be deleted and fully replace with a new one. However if merge is selected, then the data would be merged with an existing config data. This the feature that took me quite some time to make it right, but it is important.

The reason to include merge functionality, was because usually any save in config file doesn't require to save any other data. If we need to save  only a small portion of the file, then why do we need to delete the file. This was also one common problem for the quake series configs, which were automatically rewritten everytime the game ran, very annoyoing, because most of the data was sent back to default values.

Anyway when the config is sucessfully opened  it returns the ConfigBlock - this is what we are going to use for reading / writing parameters of the config.

This is done also in a straightforward way:

int width = block->GetInt("width",  640 );
int height = block->GetInt("height",  480 );


writing :

block->SetInt("width", width);
block->SetInt("height", height);


The other part of using ConfigBlock is to step into another block :

block->StepInto("texture");
block->StepOut();


Thats probably all there is.




Monday, March 05, 2007

Got a new PhysX card

Just recently I got a new PhysX card the Asus PhysX P1




The primary purpose was to support the hardware PhysX in the GE2. I got this card for about 180$ which is not much of a problem for me.

It came with a nice bag for cd disks and 3 games, most notably Ghost Recon and Cellfactor - Combat training. Which I think is a good bonus, for promoting this new product on the market.

The installation process completed without any problems and I have successfully installed it on my machine. I couldn't test it with the games though :) Because cellfactor requires pixel shaders 2.0 and GRAW just shows black screen.

But I did try it and was satisfied with the results. I am planning to make some more detailed tests, especially the accurate testing of the pure software and hardware modes, but this won't be ready soon.