Quake(one) to C++

Discuss programming topics for any language, any source base. If it is programming related but doesn't fit in one of the below categories, it goes here.
Feared
Posts: 95
Joined: Fri Jun 11, 2010 11:58 pm
Location: Wylie, TX

Quake(one) to C++

Post by Feared »

Okay, this is a unstable port of Quake (one) to C++, the code is based on FitzQuake and is just a quick port to the C++ compiler. At the moment it's nothing special but I am releasing this so I can hopefully get some feedback about the project.

This project is aimed for developers who want to work solely with C++, easier/cleaner code, and just a overall more updated Quake. Here is a list of what is changed and a list of thing's to possibly change in the future.

Changes:
Ported to C++ compiler (NOT MANAGED C++)

Future Changes:
Object Oriented code
Optimize/Speed
Updated OpenGL renderer

Known bugs:
Video menu not working
No confirmation on quitting the game
Weapon models seem to not render properly

Feel free to comment, submit bugs, or criticize.
Edit:
I forgot to mention, the port is also using Visual Studio 2010 project files
http://bfeared.com/archives/22
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

if I were to port my engine to C++, the first thing I'd do with it is to change cvars to self-register at start!
Good luck with all the tweeking.
mh
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Post by mh »

Spike wrote:if I were to port my engine to C++, the first thing I'd do with it is to change cvars to self-register at start!
Good luck with all the tweeking.
First thing I did. :D
Second was commands.

Best of luck from here too. I'm not a major C++ fan - far too many people use it to write elaborate class hierarchies than to write useful programs - but it does have some advantages that are worthwhile exploiting.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
Feared
Posts: 95
Joined: Fri Jun 11, 2010 11:58 pm
Location: Wylie, TX

Post by Feared »

Thanks, I'll look into doing that.

Edit:
I've updated QuakeCPP (this release actually has a binary included)
http://bfeared.com/archives/42

I also have created a Google code project
https://code.google.com/p/quakecpp/
dreadlorde
Posts: 268
Joined: Tue Nov 24, 2009 2:20 am
Contact:

Post by dreadlorde »

Eww.
Ken Thompson wrote:One of my most productive days was throwing away 1000 lines of code.
Get off my lawn!
mh
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Post by mh »

dreadlorde wrote:Eww.
:?: Please elaborate.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
dreadlorde
Posts: 268
Joined: Tue Nov 24, 2009 2:20 am
Contact:

Post by dreadlorde »

mh wrote:
dreadlorde wrote:Eww.
:?: Please elaborate.
Coders at work article, Some nice quotes by some of the best C hackers (not really proof of anything, but a fun read), and here is a quote by rob pike that isn't about C++, but applies to it.
Rob Pike wrote:object-oriented design is the roman numerals of computing.
Ken Thompson wrote:One of my most productive days was throwing away 1000 lines of code.
Get off my lawn!
mh
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Post by mh »

dreadlorde wrote:
mh wrote:
dreadlorde wrote:Eww.
:?: Please elaborate.
Coders at work article, Some nice quotes by some of the best C hackers (not really proof of anything, but a fun read), and here is a quote by rob pike that isn't about C++, but applies to it.
Rob Pike wrote:object-oriented design is the roman numerals of computing.
I wouldn't disagree. I've had my own experiences with D3D (specifically the D3DX library) where the designers wrote classes for things that would have been better (and more clearly) represented as procedural code. I've also written on my blog about what I call the "OOP zombies", and have had Real-Life encounters with programmers who can regurgitate OOP jargon so well that they could compete in it if it was an Olympic sport, but would crap themselves in horror if ever faced with some real code.

See also my previous comment about "far too many people use it to write elaborate class hierarchies than to write useful programs".

However, there are plenty of valid technical reasons for using C++ (even with some mild OOP) that don't involve going down the full OOP route. Self-registering cvars is one that both Spike and myself have already mentioned, and I actually believe that the stronger typing, lack of default-int, requirement to declare function prototypes (and requirement for them to actually match the real function) are all factors in it's favour and which lead to better and more robust code. Encapsulating (there I go!) functionality like sound and video inside classes is also a great way to make your subsystems more self-managing, as well as avoiding the "globals, globals everywhere" trap that Quake so often falls into.

Overall I think the "C goooooood, C++ baaaaaad" (or "procedural goooooood, OO baaaaaad" if you want to be more general) attitude is not a healthy one. Each camp has useful things to learn from the other, and shutting yourself entirely off from one will only limit the richness of your own experience.

Given the choice I would actually pick C++ over C any day. You can write C-like procedural code in C++ too, you don't have to use classes.

At the end of the day a programming language or design methodology is just a tool. OOP zombies who can't even write "Hello world" without designing a class hierarchy would do well to remember that, but so would the anti-OOP camp. :D

Anyway, I'm tootling off to read that link, it looks like good fun (I love me a good argument against those OOP zombies).
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
Sajt
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Post by Sajt »

dreadlorde, relaying quotes does not advance an argument! You even seem to favour the worst, the sassy, superficial jingoistic quotes that don't really convey any actual idea or criticism. They aren't even taken out of context: they were written without context in the first place! (Except for the time they were written, which for the majority of these quotes is decades ago...)

That said... I agree with your sentiment, of course. I don't think a game engine is the best application of OOP. I myself stick with C for that. For game code (entity implementations), or especially GUI coding, OOP is a plausible choice, but C++ is insufficient. Actually, especially when it comes to game code, OOP with its monolithic inheritance scheme (or convoluted multiple inheritance scheme) is archaic and limiting. I'm trying to figure out what would work better on that front...

To this day I haven't found a good use for C++. The real article you linked to is right when it talks about the necessity of "subsetting" C++'s features. Some of C++'s features which aren't related to OOP could be useful (e.g. a limited subset of templates).

I'm not saying C (C89) is the best language to use. It certainly is archaic. (For the record, I avoid even checking out C99 for poorly-thought-out reasons.) But I supposed I'm arguing for paradigms here, not individual languages. For the engine code, you want a low-level language with little or no data hiding, that compiles to efficient code. And for the gamecode, you want a high-level language that is simple and easy to understand, and isn't multi-paradigm, doesn't have features you don't need. For both, you (well, I) want a static-typed language with as many errors caught at compile-time as possible, ruling out the huge wave of dynamic languages in the last decade...

And C++ doesn't even come to mind when thinking about paradigms. It somehow exists outside of paradigms (splayed awkwardly and diagonally across the table of paradigms). In games programming, I don't think it has any place at all, it should drop off the face of the earth (though I can't speak for other types of applications), leaving something like C on the one hand and some sophisticated high-level language on the other.
mh wrote:I actually believe that the stronger typing, lack of default-int, requirement to declare function prototypes (and requirement for them to actually match the real function) are all factors in it's favour and which lead to better and more robust code.
These in particular are not so much strengths of C++ as they are deficiencies of C (because of backwards compatibility)... But when it comes to this I do like to periodically compile my C code as C++ code to see if any of these sort of errors will be caught.

But a real forward-looking language dispenses with function prototypes altogether. Header files in C++, whose only benefit is that they can be used as reference or documentation, are something of an atrocity, since all the private things (which in C would be static and only in the source file) must be in the header file, and because things have to be defined twice. A modern language would sever this ugly requirement, and if you wanted the "documentation", you would use a fancy IDE or, for the more primitive, a tool like Doxygen.
Last edited by Sajt on Tue Aug 10, 2010 10:36 pm, edited 1 time in total.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
dreadlorde
Posts: 268
Joined: Tue Nov 24, 2009 2:20 am
Contact:

Post by dreadlorde »

Sajt wrote:dreadlorde, relaying quotes does not advance an argument! You even seem to favour the worst, the sassy, superficial jingoistic quotes that don't really convey any actual idea or criticism. They aren't even taken out of context: they were written without context in the first place! (Except for the time they were written, which for the majority of these quotes is decades ago...)
I did say they weren't really proof of anything, I merely linked to them for comedic value.
Ken Thompson wrote:One of my most productive days was throwing away 1000 lines of code.
Get off my lawn!
Sajt
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Post by Sajt »

Okay. But I also took into account your signature. Aaand I confused you with someone else too, until I had halfway written my post...
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
mh
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Post by mh »

Sajt wrote:I confused you with someone else too
...and actually so did I...!
Sajt wrote:
mh wrote:I actually believe that the stronger typing, lack of default-int, requirement to declare function prototypes (and requirement for them to actually match the real function) are all factors in it's favour and which lead to better and more robust code.
These in particular are not so much strengths of C++ as they are deficiencies of C (because of backwards compatibility)... But when it comes to this I do like to periodically compile my C code as C++ code to see if any of these sort of errors will be caught.
Yes, you're correct and I should have noted that. :D

One thing I do like here is the combination of stronger typing with the ability to arbitraliy cast. Not necessarily C++ specific either, but C++ does have it all the same, and the lack of it is a major source of annoyance whenever I have to work with a strongly-typed language that lacks this ability.

But given a strict choice between C or C++, I do think there is enough reason to use C++ as the language-of-choice all the time, even when writing purely procedural code.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
dreadlorde
Posts: 268
Joined: Tue Nov 24, 2009 2:20 am
Contact:

Post by dreadlorde »

Who was I being confused with?
Ken Thompson wrote:One of my most productive days was throwing away 1000 lines of code.
Get off my lawn!
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Post by Baker »

I always think it is cool when there is +1 engine coders. :D

Don't really have anything useful to say regarding the engine, I was gonna try it but I see no .exe to try.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

Sajt wrote:I don't think a game engine is the best application of OOP.
Huh... What about the Source engine ? :roll:
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Post Reply