Advertisement

C++ Programmer/Newbie to OpenGL

Started by February 10, 2002 05:42 PM
4 comments, last by fuzzhead 23 years ago
I''ve been formally studying C++ for about a year now, and I was wondering whether I can use my knowledge to easily program using OpenGL. I''ve read that lot of the code is in C, so is there going to be a problem in following the tutorials? What caveats am I going to encounter along the way? Will I have to unlearn anything to get things to work? Also, I am using MacOSX with project builder. Can I use Project Builder and code in C++ with the OpenGL libraries that simply? Furthermore, is it worthwhile to instead take up ObjectiveC and start from scratch? So thanks in advance for everything. I know I''ve asked a lot of questions, so please forgive my ignorance! Thanks, -fuzzhead
C++ is perfect - going back to C is somewhat of a step backwards.

OpenGL can be used in virtually any programming language or operating system, so you don''t have to unlearn anything.

Since it is compatible with several languages including c, it isn''t object oriented. It is implimented by invoking functions in the order you desire - not that this prevents you from putting OpenGL code into your classes, if that''s what you want to do.

In C/C++, drawing a horizontal line using OpenGL is as simple as
  glBegin(GL_LINES);glVertex2f(-1.0, 0.0);glVertex2f( 1.0, 0.0);glEnd();  


The hardest part is starting the program and getting OpenGL ready to use, which is mostly OS dependent. You can use GLUT to take care of things like that, making your programs OS independent, but I don''t.

You should really check the OpenGL Tutorials at nehe.gamedev.net if you haven''t already.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
Advertisement
Great!

My intentions are to start the tutorials and get into OpenGL. It seems a lot of the code is procedural, but when I start defining objects in my game and actually building an environment, I''m sure OOP techniques will suit the task.

Thanks
-Chris
Trust me, an OOP approach to developing using OpenGL works just nicely. However, I will mention that should you be developing a 3d game engine, 'they' say that the core graphics rendering code should be written in pure C because it's easier and helps you to make your code more robust and efficient.



-------- E y e .Scream Software --------
----------------------------------------
                                  /-\
    http://www.eyescream.cjb.net | * |
                                  \-/
----------------------------------------



Edited by - TheGilb on February 12, 2002 7:50:40 PM
anyone who says anything SHOULD be writting in C instead of C++ is an idiot ... (exceptions granted for situations with buggy c++ compilers) ... C is a great language, it will survive for a long time to come (what other language is so well suited to embedded work) ... but I have the proof that you CAN do things just as well in C++ ...

And the winner is ... BeOS

The single most promising desktop operating system to go kaput in history. But if you''d ever writting desktop apps for it, and then gone back to using Windows or Linux ... then you know of what I speak ...

Anyone who doubt''s that C++ can handle the task hasn''t read "Modern C++ Deesign" by Andrei Alexandrescu, and they also probably haven''t read "Design Patterns ... " "The C++ Language", nor have they experimented extensively with function objects, or the STL ... C++ has everything you need to build large complex systems such as a 3D engine ...

it can be done in C, it can be done in C++, it can even be done in Java or ASM ... it can be done wrong (and has been) in every language ever invented ... so just because many people will always program poorly, and you can cite examples after example of failed (insert language here) projects ... they do not prove the inappropriatness of the language itself ... just the development team.
Ok Xai, thanks for your statements, which I''m assuming were in your humble opinion because you are not the definitive say on programming ;D

Let''s just keep the accusations to ourselves hmm? The last thing NeHe needs right now is a flame war between C and C++ on his message board right now.

If you''re looking for information on the differences between C and C++, or you just want a useful reference on the languages I personally recommend "Thinking in C++" by Bruce Eckel. Certainly showed me some interesting advantages and disadvantages of the different languages!



-------- E y e .Scream Software --------
----------------------------------------
/-\
http://www.eyescream.cjb.net | * |
\-/
----------------------------------------

This topic is closed to new replies.

Advertisement