Skip to content
May 11, 2011 / racoonacoon

Preping for cross-platform development

So about a week ago I started thinking. Being that we are going to remake The Sphere and Claudius with OpenGL, why not take it a step further and provide cross-platform support to all those *nix systems out there? I mean, it seems like a pretty cool idea and it would allow us to gain a lot of experience, scars, and (hopefully) customers. Plus it would be cool to show some love to the undervalued Linux community. With this idea stuck in my head, CJ and I went on a search for all the different applications and code stuffs that we will need to undertake this task and work cross-platform effectively. I also started reading a bit into OpenGL and all the stuff that it includes (or rather lacks.)

When coming from DirectX, OpenGL can seem a bit…bare I suppose. OpenGL lacks texture loading capabilities, sound playback abilities, input capabilities, and, what gets me the most, it lacks any sort of vector math library. It just seems inane to me to have an API of this sort without a decent math library to help you actually get the graphics on the screen. Still, I suppose this is necessary for OpenGL to be as cross-platform as possible, however painful that may be. Overall though, I love what I have seen of the actual library so far; it feels much more natural and streamlined than DirectX does.

Thankfully, CJ and I were able to get a pretty good list together of all our cross-platform necessities. The first item on the list was the IDE(s) (the application we use to program and compile our programs in) that we are going to be using. I really wish Microsoft Visual Studio was cross platform, because that is what we are both familiar with (I have been using it since the 2003 edition!) and we both just really like it. Instead, we begrudgingly decided to use the next best thing: CodeBlocks (which really is worlds away from the holy grail that is Visual Studio but we don’t have much of a choice.) I’m also looking into using MonoDevelop in case I get a C# fancy while running my newly installed Ubuntu partition.

With that out of the way, we had to pick some software libraries that could fill some of the gaps of OpenGL. CJ suggested I look into SDL for the window management stuff, as it handles all the nasty, extremely gritty, low-level stuff required to create a window. Better yet, it does it all in a cross-platform way, so if you are careful about things you can get a window up and running across multiple platforms. Which, *surprise surprise*, I have already done!

#define TANGENT

I am trying my hardest to make Claudius as smart as possible when it comes to this low-level stuff. If I don’t set everything up correctly now, it will be nearly impossible to do so once a game has been built on top of it. So far I have got it to where Claudius can return a list of supported resolutions and automatically clamp your resolution request to the bounds of these supported resolutions. It worked fine under Win7, but it failed initially under Linux. Apparently the backbuffer I was requesting had too high a bit depth for the Linux OpenGL driver. My next step then is to make sure the backbuffer parameters are queried and set to something legal if the requested one doesn’t exist. After that, the next significant thing that needs  set up is an event system so that buffers can be notified when the device is lost or reset (I assume this can happen under OpenGL) so they can rebuild themselves without user intervention.

#undef TANGENT

For sound we plan to use OpenAL, which seems like it could be a nice replacement to XAudio2. I believe CJ wanted to take advantage of SDL’s media features as well. For texture loading there exists both DevIL and FreeImage, but their licenses aren’t all that clear so this is still up in the air. For general stuff we plan to take advantage of the Boost C++ library, which should prove extremely useful, esp. in the threaded areas of the engine. The math library is something I’m not so sure on at the moment. There is glm, which looks great, but I might end up writing my own library so I can fool around a bit with lady SIMD. For those who don’t know, SIMD is the ability for an x86 processor (an Intel or Intel Clone (AMD)) to execute a single instruction on multiple pieces of data simultaneously. This can be used to make 3D math execute crazy fast. I think it will be a good learning experience.

This was a very long winded post, but I had a lot of stuffs to cover. Hope to see you back next time!



Leave a Comment
  1. Geoffrey H / May 11 2011 10:06 pm

    Have you considered using the Eclipse IDE? I hear its very good for Java development, but it also has C++ components as well. I plan on trying it over the summer on my project i.e. making Claudius. Haven’t thought of a cool fear inducing name that causes the heavens to cry in agony for it yet though.

  2. racoonacoon / May 12 2011 12:00 am

    Hey there Geoffrey, nice to see that you came to our blog! And you even followed! +10 cool points!
    I’ve looked a bit at Eclipse, and I’ve actually used a bit for Python & Java development, but I have never downloaded the C++ extensions as of yet. My initial impression of it was that it seemed a bit slow and somewhat confusing to navigate, but perhaps I just didn’t spend enough time with it. Thanks for the suggestion though, I’ll go download the C++ extensions and see how things roll.

    You should name your engine the FREY COMPUTING ENGINE. or GeoTech, or anything else that involves portions of your name. Good luck!

    • Geoffrey H / May 12 2011 5:48 am

      I got Eclipse up and running with OpenGL and SDL on the GCC/MinGW compiler.

      I already had the compiler installed but if you wanted to use the one I’m using I followed this guide and if I remember correctly it was only a little painful.

      OpenGL was already supported so i can just #include and the other headers, unless I messed with it to get it working before, no idea don’t remember.

      SDL was pretty painless except for one thing that I happened to stumble upon. I followed this. Even though its for code blocks I got it working for Eclipse relatively easy. Just add file paths to Project->Properties->C/C++ General->Paths and Symbols, the include and library path tabs. Also make sure you select “All Configurations” and have the “GNU C++” language selected.

      After doing this I build my program(just a main function that returns 0) with SDL included and I got a compiler error saying that WinMain@16 was undefined in some file way off in the boonies of GCC/MinGW. It took me a bit of poking but I found out that MinGW auto-includes some header files. I turned this off and my main function now works fine. If you have this problem go to… Project->Properties->C/C++ Build->Settings and in the Tool Settings tab go to MinGW C++ Linker->General and select the “No startup or default libs” check box.

      Hopefully this is somewhat useful to you if you decide to try Eclipse, just posted this so you might not have to go through some of what I did to get stuff working properly.

      P.S. I found a coding styles option that allows you to set a profile of how it should (I guess) auto-complete code for you. Wish I could have run Travis’s and Mikes code through something like this. Oh well, I digress.

      • jh / May 12 2011 6:04 am

        You can also fix the undefined function by using these linker flags:

        -lSDL -lgdi32 -lwinmm -lmingw32 -lSDLmain

        The -lmingw32 is the one that takes care of the WinMain error. GCC on windows is a little picky sometimes about linking order, so the way the -l flags are specified makes a difference.

      • Geoffrey H / May 12 2011 6:14 am

        You are an infinite source of knowledge Jim. That was in the guide but I didn’t know how to specify linking order in Eclipse, thanks

      • jh / May 12 2011 6:33 am

        Under Project -> Properties , C++ build, settings, libraries, and there you go.

        I found this from a programmer’s blog — I’ve used Eclipse very little, so I can’t say if this will work or not. But it sounds good… 😉

      • Geoffrey H / May 12 2011 7:08 am

        This combo works for me as of right now.

        Project->Properties->C/C++ Build->Settings and in the Tool Settings tab go to MinGW C++ Linker->Libraries in the “Libraries (-l)” box I added

        opengl32 glu32 mingw32 SDLmain SDL

        this works for the sdl/opengl functions i use right now, might have to link more later though. Depends on where opengl tutorials/research take me.

      • racoonacoon / May 14 2011 1:29 am

        So I got the C++ extension stuff set up for Eclipse. I think I like the layout and color scheme a lot better than CodeBlocks. For some reason the CodeBlocks ‘intellisense auto-completion’ dropdown was unreadable on my Ubuntu build, and given that is the OS I’ve been using recently, it was a major downer.

        I also looked at NetBeans, but the fonts don’t render all that well, so I think I’m going to stay away from it.

  3. jh / May 12 2011 2:17 am

    OpenGL’s philosophy is indeed to be as minimal as possible. That’s always been something that’s kind of annoyed me as well, but it does give you the freedom to mix and match components according to what does its job the best. And there are quite a few free libraries out there for images, sound, etc.

    Netbeans also has a C++ module. Depending on your tastes, it might be useful.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: