I Want To Learn GL Should I Learn C++

I really want to learn GL ive used basic Pascal in the past, The big Q is, Is C++ still the main language used to code OpenGl Games etc or is there another Language, Any tips on the best route to take, Where to start, What software to use, Recommended Readings would be really helpful and appreciated. It is mainly game creation i am intersed in.

Yes, C++ is in any case the best choice. I programmed for years now majorly with Delphi and only rarest in C++, but now after moving completely to C++ I’m very happy about that I finally did this step. I personally think Delphi/Pascal is far easier than C++, but latest, if you want to do anything professional or fast, you should take C++. Our last project was done with Delphi, 150,000 lines, but we detected unfortunately too late that Delphi is a one way street and ended with writing all of our time critical code in 100% assembler using SSE and 3dnow to even out the sucky Delphi compiler. So well… if you want to do it right, use C++ from the beginning on or you might be later very sorry about it.

BlackJack

p.s. You should stay away of the GLUT and GLU helper units. They save time and support dumbness, but if you ever want to port your engine or what ever you are going to do to DirectX you’ll be very sorry then .

I feel like starting a flamewar so I have to say that you’d be better off with plain old C(and maybe some assembly later for optimizations).I can imagine how C++'s bloatedness and complexity(that is design-complexity not difficulty of use) can be overlooked in favour of the organization(classes and stuff) and the easier team programming in an equally big and bloated project(like those custom software ordered by organizations or the army),but for low-level programming such as graphics programming I can’t see why one would use C++.Maybe just because the ++ and the fact that it’s newer makes it sound ‘better’ thn old C.Or maybe because it’s regarded as easier than C.Well easier doesn’t always mean better,usually means worse.Maybe it’s just a matter of taste…

Let The Flames Begin…

PS:If in fact you’re not conquered by the dark side of the force and you do choose C.Get the book by Richie and Kerningham which covers all of c and is very small compared to some “Learn C++ in 666 days” monsters.You can easily read it two or three times in no time.Bear in mind thouh that it is a C manual not a programming manual.If you don’t know much about programming you might want to do some some pascal tutorials and simple programms first to get the hang of it and then move on to C.You won’t regret it.If this looks like a long procedure also bear in mind that you won’t go far into graphics programming w/o patience.

PS2 amn I love it when I talk like I know everything when in fact I learned C myself just 2.5 years ago.

[This message has been edited by zen (edited 06-30-2002).]

In regards to the flame war respones id have to say go with C++ rathen C in the respect that when using API’s such as OpenGL and DirectX 8.1 youll run into some case scenario where the API doesnt support the simple C format any longer and requires the use of a C++ class or method. if you have any more questions or need help learning the language contact me at DerrekMC@hotmail.com

Thanx all above, So i feel that C++ is the road to take (Sorry Zen…). Can any one recommend a compiler to start on. Is MS Visual C++ the best. Price dosnt matter just what ever one is easiest to get started on and is unrestricted in its features i suppose.

Zen… I personally would be very surprised, if C is faster than C++. Afer all C++ allows a lot more perverse constructions which are surely far better optimizeable than if you would write them into tons of single lines. And if your code is clean or not depends after all on you, not on the language. Same about teamwork.

And if you want speed, well, in that case I use anyway pure assembler if even the optimizations the VC++ compiler does are still too bad.

BlackJack

Hi Blackjack,
I never reffered to speed as an advantage of C versus C++.Speed depends on the coder mostly.Even if some features of C++ are be slow you don’t have to use them(or at least not in the inner loop).The fact that you don’t write tons of single lines doesn’t mean that the compiler doesn’t do that for you.I think you will agree that the more low-level something is the more optimizable it is(for all situations).That is because you have more freedom to do optimizations suited for your specific situation instead on relying on the compiler to do so who usually doesn’t know anything about your specific situation.That is also why you resort to pure assembly to optimize what the compiler can’t.This of course assumes that the programmer is capable of optimizing the code so,as I said,speeds depends on the coder and not the language.And besides the only thing that might make C++ a bit faster than ANSI C is the inline statement but most C compilers have this feature anyway.Most other things like overloading etc. are just there to make the code more readable and to help the programmer.
I also didn’t say anything about the code you write.It can be clean or dirty in any language.I mentioned teamwork because OOP with classes etc. might make it easier to break up a very big and complex programm into smaller parts which can be then allocated among the available programmers.But as you said this mostly depends on the design of the application.What I said is that I like C because of it’s design simplicity.It has everything that is needed to make everything you can do with just about any high-level language and only that.This gives you the most control of your code which,of course you can get with C++ if you don’t use it’s fancy features,but then C++ becomes C.
Lucifer:I don’t know about DirectX but opengl doesn’t use classes or methods or anything OOP-related.This gives the programmer the freedom to choose wether his app will be OOP or not.If DX forces you to use OOP then it’s DX that has the problem not C.

Learn C++, if you know C++, you’ll surely know C. Operator overloading, inheritance, class, constructor and destructor, default parameter, polymorphism etc is enough to convice you to learn C++.

ANYTHING JUST DON’T LEARN VB.

Originally posted by Questions Burner:
Learn C++, if you know C++, you’ll surely know C. Operator overloading, inheritance, class, constructor and destructor, default parameter, polymorphism etc is enough to convice you to learn C++.

That sounds as a good reason to NOT learn C++ as a first step in learning OpenGL. AFAICT, there ain’t such thing as a C++ binding for OpenGL. And, of course, the above terms characterize object-oriented design approach, not C++, and are equally applicable to design’s implementation in any (sensible) language. That is not to say C++ is bad, it is not, it is just a bit harder to create an efficient program in C++ IMHO, the extra care needed around not so apparent (copy) constructors, completely eliminates the convenience adavantage of the syntactic support (a.k.a sugar :stuck_out_tongue: ) for OO concepts.


ANYTHING JUST DON’T LEARN VB.

I can only second that. Amen.

Regards,
-velco

I’ll have to agree with velco.Also regarding VB sadist’s initial question was wich language to learn.Since VB doesn’t(IMHO) really qualify as a language it shouldn’t be an option in the first place.So:

ANYTHING JUST DON’T LEARN VB.

I’ll …um third that

you should learn CPP it’s the best there is.

and to help you learn CPP and opengl try these tutorials at www.gametutorials.com . There are a lot of very good tutorials for both CPP and OpenGL there.

Have fun

[This message has been edited by svc2211 (edited 07-01-2002).]

Amazing! Some people are still coding with str8 C?

I haven’t done that since I was at Uni. Hmmmm. I’ve used VB - which is great for rapid application development - at work I’m currently using VC++. The C++ features are extremely useful. Its a balance between code speed, readability and ease of maintenance. C++ offers advantages in all of these areas. If you want killer speed, you’d better write in Assembler and write a different function for each processor type you encounter (that means, you’d better be a whizz at Microelectronics) - I think Carmack said that the Assembler crews really amuse him. Hes just using str8 C++ now. If its good enough for him, its good enough for me

If you look at the assembly output of a C++ class with that of a C module written to do the same thing, you probably won’t see any difference. Copy constructor semantics make a difference when performing a deep copy, but with C you don’t even get the option to do that! If you don’t understand C++, you’ll have a hard time writing efficient code, same as with C, same as with Assembler, same as, even with VB.

Note: VB is not something you should stay away from' - its an excellent way to quickly prototype GUI programs and for writing GUIbusy’ programs in general as quickly as possible. Some of us live in the real world, where every hour a programmer is typing away at his desk costs lots of $$$.

Having said that, I wouldn’t write an OpenGL app with VB - a DirectX app would be a slightyl different matter. If you want to learn graphics programming concepts, then sure you can use VB because you already know it so your learning curve won’t be OpenGL AND C++, it’ll just be OpenGL.

To quote the glossary in “the red book” OpenGL Programming guide Third Edition

C Gods programming language

C++ The object-oriented programming language of a pagan deity

I guess programming languages like religion is about personal choice

Julian

Originally posted by Robbo:

Amazing! Some people are still coding with str8 C?

Amazing ? That some people want the work DONE ? :stuck_out_tongue:

In my experience, a C++ program was often slightly easy to write and slightly harder to write it right, than a C program.

Copy constructor semantics make a difference when performing a deep copy, but with C you don’t even get the option to do that!

Yeah, right! I can surely do deep copy with C.


If you don’t understand C++, you’ll have a hard time writing efficient code, same as with C, same as with Assembler, same as, even with VB.

Sure. And since C is much smaller and much easier to understand compared to C++, it is much easier to write efficient code in C. Glad we are on the same opinion here

Some of us live in the real world, where every hour a programmer is typing away at his desk costs lots of $$$.

Well, VB programmers do not cost THAT much, compared to, e.g., an embedded software engineer, coding in str8 C.

And speaking of real world, how expensive is the actual coding, relative to the other activities in the life cycle of a project. Compared to analysis and design, maintainance, advertisement, etc ?


If you want to learn graphics programming concepts, then sure you can use VB because you already know it so your learning curve won’t be OpenGL AND C++, it’ll just be OpenGL.

That’s the point. Not C++ AND OpenGL but just OpenGL. Of course, one still needs SOME language, so just learn C - small, easy, efficient, portable and a good first step towards C++ or Java or C# or whatever is the fasionable today.

Regards,
-velco

To quote the glossary in “the red book” OpenGL Programming guide Third Edition

C Gods programming language

C++ The object-oriented programming language of a pagan deity

I guess programming languages like religion is about personal choice

Julian

Amen

Does this mean VB is for the atheists amongst us???

Let’s better not turn this thread towards religion.We’re going to make an even bigge mess out of it that it is now.

Oppps, What have i started hear. It can get pretty hot in here but seriously thanx all you guys some good arguments. But im all set now on C++ can any one recommend A good compiler, And any more links to tuturials would be really appreciated?

First thing - Carmack uses C not C++.
Second.
OOP - well it’s a programing model.
You can write apps with OOP technics in pure ANSI C - structures with pointers to unfctions inside them ( and that will be even faster then RTTI in C++ - just assign the pointer to the field in struct - in C++ it is done every time the func is called ).
Now C is better, has better compilers.
Is more cross platform ( well…look at it…some platforms - like consoles don’t have C++ compilers, other have very poor ).
And another thing - C is more standarized - like with C++ you have like MS C++ , Borland C++ etc ( very little diffrence - namless unions etc - I don’t think that this works in GNU g++ ( not in 2.9x.x ) ).

If you’re good and think a bit you will write better ,faster more efficient code in C rather then in C++.
And don’t get me wrong. I know C++, coded it for some time.
But moved to pure C.
Is better.
And the last thing - it not the language counts ( that much ), but the coder skills.

END.

Carmack uses C?How do you know,have you taken a look at the quake2 sources?The variable naming convention he uses in the console(like FirstLetterCapital) looked suspiciously C++ like to me.Anyway you can’t really say that you can write more efficient code with C++ than with C.Remember that code eficiency(as in the microsecond difference) only matters at some points like in the inner loop that get’s called a million times per sec.If you don’t use the slower features of C++ there(i.e. if you use more or less C there) you shouldn’t have much of a speed impact.Of course knowing what is slow and what isn’t is a little tricky.C is much closer to the way the computer works.A struct for example is nothing more than a chunk of memory which holds all it’s members with labels that allow you easy access to them.Something like struct.member is nothing more than *(typeofmember *)(addressofstruct+offsetofmember) (you can even access the member yourself alhough that doesn’t always work as the compiler might insert padding to ensure alignment).You more or less know what the compiler does and therefore can control it much better(and easier).That’s what I initially meant by simplicity in design.C++ can be much more complex and thus more difficult to optimize.Of course you could say something like ‘if you want it to be easy learn VB’ but you don’t get any more power out of this complexity just some ease in organizing your code which can be much more difficult in C.Anyway you can’t say what is better and what isn’t(although C clearly is ) but for me the extra control,freedom and compiler-independence matters more than some syntactic sugar to help me organize my code.Of course the other things copycat has mentioned are important too.

No - ehem. These days your `optimisation’ is usually at the algorithm level, rather than in some loop fragment. Maybe 10, even 5 years ago you could justify spending 2 days figuring out a better\faster way of lerping across a triangle but these days just don’t bother. If the compiler can’t max it out you will discover a problem when you profile your app and can fix it later. Remember that C++ gives you all of the C constructs and some. The lower level you code at the less chance the compiler will have to maximize and optimize your code. Just setting a little asm method in there inline can totally screw the compilers optimisation strategy, so don’t bother.