Sunday, September 6, 2009

Building OpenSG in Linux

I am writing this post from my first laptop which is at the moment running XUbuntu (a light weight version of linux) coz its standards measure to "Under Powered" PCs in todays world. But i still stick to it for all my experimental stuff :)
Anyway, I have been busy with shaders for the past few months. I've stalled the development of Pulse3D coz of lack of maturity of design of the game engine. I've moved my attention to shaders for a change, and have been facinated by the visual shader editing softwares. They are fast, easy to create content, and also come at a cost of low optimization.
Being a low budget freelancer, I've always hunted for opensource tools to help me with my hobby projects. I've tried ShaderFx, MentalMill etc. but all are some or the other way not free in their availability. ShaderFx totally depends on 3DSMax for its operations, hence cannot be used freely after the demo version of 3DSMax has expired.
On the text based creation/editing, I've been using FxComposer; but it too has its limitations on the kind of control I wish to have over the scene created. Since I cannot extend FxComposer, I have decided to create a small tool for loading effects and creating worlds using those effects. I am targetting to make this tool available for Linux, Mac besides windows, so that I can hopefully contribute to the OpenSource community.
I initially thought that NvSG would be a great starting point for the tool, but ran into a road-block even before leaving the runway. Nvidia has not provided any libraries for Mac; and not being open-source, I cannot compile any also. Looking for another solution i hit OpenSG. This SceneGraph is opensource, and i've compiled it on Mac, currently compiling on Linux and hopefully it will compile on Windows also.

Compiling on Linux, and on this ancient system brought up a number of problems. Thought that sharing them here will save some people a little frusturation.

1. If you want to have the libs/include/bin of OpenSG at a customized location, use the --prefix=BUILD at the ./configure cmdline. On executing "make install" the files will be copied to OpenSG/Builds//.

2. If your compilation fails with an error pointing to a file named something like SkelParser.tabs.h make sure that you have "bison" installed on your system. It was missing on my sytem and once I got it, I passed this error as though it were never there.

3. If your build process is terminated with "Killed" message; even though you did not hit Ctrl+C or kill some process... then it means that your build process was taking up too much memory and the kernel decided to snap its neck before it caused any instability problems to the OS operations. Causes include that your swap space is not properly setup, or you need more memory (swap space).
I checked my /etc/fstab file to see for the entry of the swap partition that I had created during installation of Linux. Everything there seemed fine, so I drew a conclusion that the memory + swapspace wasn't enough.
Solution: Since I didn't have a free partition, I create a new swapfile, and offer it to the kernel as added space for the build process.
How: http://www.redhat.com/docs/manuals/linux/RHL-8.0-Manual/custom-guide/s1-swap-adding.html
For a 300Mb swap file,count=1024*300
dd if=/dev/zero of=/swapfile bs=1024 count=307200

mkswap /swapfile
swapon /swapfile

Making this swapfile load on startup, add this line to /etc/fstab
/swapfile swap swap defaults 0 0

For checking the swap partitions, type
cat /proc/swaps

No comments: