Jump to content


Help: Xcode, C++ and OpenGL; The Tangled Web it Weaves


  • You cannot reply to this topic
2 replies to this topic

#1 noalias

    New Member

  • Members
  • Pip
  • 2 posts

Posted 05 January 2007 - 10:43 AM

I have been doing a lot of searching on the internet in my spare time here during winter break before it's back off to college, and I decided to learn a little about Computer Graphics. In high school, I'd taken classes on HTML, JavaScript, and Java, but didn't get into C++, but I'm learning some now, so I decided to try to learn that along with using OpenGL. So I came across http://nehe.gamedev.net and decided I would start there.

Here's my problem, and it'd be really simple if I understood what I was doing, but I'm used to Java and how simple it is to compile: I can't follow their examples because I can't figure out how to impliment it with Xcode for the Mac. I have Xcode, and done the "Hello World" and that jazz... but that's using .cpp files. And then I go to try out their example, and after reading around on the net, find that I should use this "Carbon C++" Project type; at least I think I should. And I try that and it automatically creates 20 different files, with various extentions such as .app and .c (not .cpp, but it's called "main" so I guess it's where I will put my code in), and there's some frameworks added in. I figured out how to add in the GLUT framework which would logically be needed for the first tutorial (opening a window with OpenGL). I used their exact code, but still couldn't get it to compile; the only lines that didn't give me errors were the #define lines. So here are my questions:

1) Do I really need all those files? In Java, you just have the .java file (.c or .cpp), compile it, and it gives you your .class files (.app). Those are the equivelants, right?

2) I understand it may need frameworks included in the project, but is there some reason it wasn't recognizing the GLUT framework after I imported it?

3) Basically what I want to know is: What's the standard file format they're using in the tutorials at http://nehe.gamedev.net (.c? .cp? .cpp?)?

So that's basically what I'm wondering. Sorry it took so long to say, but I am getting frustrated and I keep going back to it with hopes that I'll figure it out, but I always wind up with more frustration. Thank you very much for your time and (hopefully) answers!

#2 pater

    Valued Member

  • Members
  • PipPipPip
  • 117 posts

Posted 05 January 2007 - 09:13 PM

I haven't ever coded for the mac (mainly because I don't have one, but also because I heard that it was awfully complicated and very few usefull tools are avaiable), but I might try to answer some of your questions anyway.

1) What kind of files do you have in plus? You'll definitelly need at least one c or cpp file, and (99% of the time) also a .h file with the same name. In contrast to java, C++ separates the definition from the implementation. So the h file contains the class definition and the cpp file its implementation. Strictly speaking, you could put everything into the h file like you did with java, but that will cause problems with type declarations sometimes (read up about header files and how they relate to their code files). After compiling, you'll get a binary file (on the mac, these don't really need an extension, but I presume the compiler will use either "exe" or "out" by default)
2) What makes you think it didn't find the GLUT? If you're getting errors on #define lines then there's something very wrong with your compiler setup. Can you print such an error.
3) Depends on the compiler. Most compilers nowadays use .cpp for c++ and there's usually even a compiler option that lets you force the compiler to compile as c++ and not as c only.
4) Carbon should be the right choice, since the compiler (should) then behave much like a unix compiler like gcc, which is a de-facto standard (unlike what older mac compilers did)

#3 noalias

    New Member

  • Members
  • Pip
  • 2 posts

Posted 08 January 2007 - 01:07 AM

Thanks for your help! I decided to go back through the C++ book that I started a few years ago and finish it so I'd have a better understanding. I've already learned enough in the book in the past day to find out what many of my problems and questions were. Unfortuantely, it requires reading, which I'm kinda slow at, but it's doable since I find it so fascinating. They really need to have good, cheap DVD tutorials for people who are terrible readers... But anyway, thanks for the help! Have a good one!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users