Sign in to follow this  

I hate my base code...

This topic is 4859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been using a windows/ogl base code I wrote for about 6 months but Im really not happy with it. Im just using the raw windows api, and deriving a class for the main loop functions. What I want to know is this: would it be feasable to use mfc for the most part of the engine? Or is there an alternative to mfc? What do you guys normally use? Also, how do you use the windows ini??

Share this post


Link to post
Share on other sites
With OpenGL, i just use SDL for windowing and input (and network and image loading and...). It's cross-platform, but even better it's just simple and nice looking. Can't recommend it enough. With SDL you don't have to touch ANY of the OS-specific calls.

Share this post


Link to post
Share on other sites
Unless you are doing lots of window stuff, there isn't much reason not to just use the basic Win32 API. In general, unless you already know MFC, you should probably use something else, since MFC is on the way out.

Share this post


Link to post
Share on other sites
Not to mention, MFC is hellish to learn and won't offer many (if any) advantages at all over something like wxWindows or SDL.

If you plan to stay in Windows, you could get the new Visual C++ Express Beta and use it for WinForms, which SHOULD interface easily enough with OpenGL.

Other options include WTL, GLUT and Allegro. WTL is an awful lot like MFC though and is becoming obsolete too (I think), GLUT is nicely cross-platform but can be rather stifling to your coding style and Allegro is cross-platform and has lots of other features, like sound, image loading and input and it has a (separate) OpenGL add-in that lets you use GL code normally. It's rather like SDL, but not really object oriented.

-Auron

Share this post


Link to post
Share on other sites
Quote:
Original post by Auron
It's rather like SDL, but not really object oriented.

-Auron


SDL is written in c and not OO at all unlless you right a wrapper for it like I did.

Share this post


Link to post
Share on other sites
Quote:
Original post by Auron
Not to mention, MFC is hellish to learn and won't offer many (if any) advantages at all over something like wxWindows or SDL.

-Auron


I don't think I'd refer to MFC as being "hellish" to learn, but for the non-tools part of game development it's completely useless anyway, it's just not suited for the task at all. For applications it's a mature API that can do just about anything, though in the future it's going to be replaced by .NET.

Share this post


Link to post
Share on other sites
I use win32 for engines and MFC for tools. MFC while borked at some places is the best solution I have found and I've looked at Fox toolkit and wxWidgets and some others like Qt. The only thing so far I don't like about MS is their d3d. Something else I wanted to mention. If you need maximum flexibility you should use win32 but you'll know by then what to use. Don't try to OO win32 as it's not worth it. Use MFC for that. You can also look at .net for usage in tools because it has functionality built in that MFC lacks. Plus, the gui is GC'ed which means no memory leaks. Those are nasty to find since MFC doesn't catch them. You can use and will have to, win32 with MFC.

Share this post


Link to post
Share on other sites
well, I know doom3's editor uses mfc as do most level editors out there (ued?). However, like said, .net will replace mfc in the near future. Anyway though, I need sleep! good night guys.

Share this post


Link to post
Share on other sites
If you want to "OO Win32", why not take a look at WTL, released as Open SOurce by Microsoft. It's essentially a thin OO wrapper for windows but it really helps simplify managing the GUI environment without the bloat and hassle that comes with MFC. You can find a load of tutorials for WFC on CodeProject.

Share this post


Link to post
Share on other sites
Quote:
Original post by yodaman
I have been using a windows/ogl base code I wrote for about 6 months but Im really not happy with it. Im just using the raw windows api, and deriving a class for the main loop functions.
Don't fix it until you're sure it's broken. If it merely offends your senses, suck it up and let it be. Spend your time writing new code instead of rewriting old code. :)

(if, on the other hand, it is making that new code hairy and gross, then it may save more time to dump it than it would to just stick with it)

Quote:
Original post by Ainokea
SDL is written in c and not OO at all unlless you right a wrapper for it like I did.
Why is this a problem?

OO-izing SDL doesn't buy you anything. It's still the same old API, with all the strengths and flaws that come with it, except that you've aged a bunch of hours, and can use this.that() syntax. ;)

(besides, SDL is one of the clearest, most straightforward C APIs I know of. Using it is pretty painless)

Share this post


Link to post
Share on other sites
WTL is a good thing. It's a lot more lightweight than MFC and
straight in use. However it's not good documented (although there are some doc projects in the web) and you end up looking in the WTL source often.

Why not switching to C# where building a GUI is extremly easy and clear (and OO :) For tools I would strongly recommend it and it's a language which I belive has the future.

For your game engine it might be also the solution but there are some things like garbage collection that should be handled carefully if highly optimized code is required.

Give it a try!

-Constantin

Share this post


Link to post
Share on other sites
Quote:
Original post by Ainokea
SDL is written in c and not OO at all unlless you right a wrapper for it like I did.


Oh... my bad... I haven't used SDL in a good long while and completely forgot what it was like.

Quote:
cavemanbob
I don't think I'd refer to MFC as being "hellish" to learn, but for the non-tools part of game development it's completely useless anyway, it's just not suited for the task at all. For applications it's a mature API that can do just about anything, though in the future it's going to be replaced by .NET.


If all you want it for is to set up a window to plunk your OpenGL stuff in and some controls to do some stuff, then I suppose the learning curve for MFC is lower than for Win32.

I was never debunking MFC's power. I know it can do just about anything, but I remember spending hours looking for help on really simple things that it couldn't seem to handle without severely butchering the boiler-plate code from MSVC.

-Auron

Share this post


Link to post
Share on other sites
The good thing about MFC is that it has that message wizard thingy which you would have to replicate in win32 with callbacks or turn it into win32 OO. There is an article on gamedev how to do win32 the OO way. I've done it that way also but didn't like it. I wrote large codebase in win32 and seeing how painful that experience was I switched to MFC. When I switched I realized that MFC while wonderful with msg macros and such can be hard to use at first because you need to know MFC function invocation order so that you can interact with it. Some MFC objects aren't yet created when you think they should be or they pass in invalid window size, etc. Immediately, after switching to MFC from win32 I've noticed that the MFC widgets are much nicer looking. They add more decorations, etc.

You mentioned windows.ini file and if I understand you then you like to save some application properties into that file, correct? .ini files are considered obsolete and I use MFC windows registry functions to save my app data. However, I will probably move that into separate file so that the settings persist across installation/deinstallation of my app. Registry is wiped out each time the app is reinstalled.

I have not used WTL but my understanding is that it lacks some MFC functionality, just not sure which ones. Drag and drop?, etc.

MFC tip: try to keep some names short because MFC wizard dialog boxes in msvc6 IDE can't be resized and thus names won't be fully visible. Is this issue fixed in vc2003 IDE?

Share this post


Link to post
Share on other sites
I think he was actually referring to using INI files in general. If not, then definitely use the registry. windows.ini is obsolete.

If you mean just using INI files in general, don't do that either. You could write your own parser and stuff, or find one online, but really, INI files are getting to be antiquated (at least in my opinion). Use XML files for configuration instead. There are libraries (like TinyXML) that will do most of the hard stuff for you.

-Auron

Share this post


Link to post
Share on other sites
if you want to use ini files without any library, just to make it simple,
check out these functions:
http://msdn.microsoft.com/library/en-us/mslu/winprog/unicode_layer_ini_file_functions.asp
i made my ini class in 21 lines of code

Share this post


Link to post
Share on other sites
Quote:
Original post by Auron
I think he was actually referring to using INI files in general. If not, then definitely use the registry. windows.ini is obsolete.

If you mean just using INI files in general, don't do that either. You could write your own parser and stuff, or find one online, but really, INI files are getting to be antiquated (at least in my opinion). Use XML files for configuration instead. There are libraries (like TinyXML) that will do most of the hard stuff for you.

-Auron

imho, registry is a piece of nonportable crap, and you should make a wrapper for it.
Using xml to store everything is also bad idea(imho).It makes things look "omg,professional" but it's not always necessary (and i personally hate *ml sintax).

It's best to make your own/use something else.

Share this post


Link to post
Share on other sites
I agree that the registry pretty much sucks. And it does create one more awkward non-portable construct if you're trying to port an app. But it is better than using INI files.

Quote:
Original Post by Dmytry
It's best to make your own/use something else.


And you're entitled to your opinion. I agree that XML can often be overkill, especially if all you want is "resolutionx=1024" kind of stuff. Configurations like those are dead easy to parse. If you want more complicated configurations with tidier code for parsing them, then XML, or some configuration parser library, will often be better.

-Auron

Share this post


Link to post
Share on other sites

This topic is 4859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this