Game Tutorials

Sage
Posts: 1,066
Joined: 2004.07
Post: #1
I am working on the first OpenGL tutorial at gametutorials.com and I'm running into trouble. I downloaded the SDL port of the code and copied it into Xcode. I made sure to add the SDL and OpenGL frameworks to my project. I then changed the include part to be <OpenGL/gl.h> <OpenGL/glu.h>. I compile the project and get no errors on the code but I get an error and warning during the linking phase I believe. I can't see what the problem is so does anyone have any advice?

**Edit**
I tried to compile it once more and now its telling me the error. I get an "Undefined symbols: _SDL_main" error and a warning telling me "warning prebinding disabled because of undefined symbols". I figure that fixing the 1st one will fix the 2nd but I don't know how to fix the 1st one. Any help?
Quote this message in a reply
Member
Posts: 72
Joined: 2006.10
Post: #2

- Sohta
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #3
That didn't fix the problem. This is exactly whats its telling me:

SDLOGL:0: Undefined symbols: _SDL_main
SDLOGL:0: warning prebinding disabled because of undefined symbols

I changed the main() from int main(void) to int main(int argc, char *argv) but I still get the error. I read the FAQ listed at the end of that thread and did all of those three things but I still get the error. I noticed that their errors were about _main() whereas mine is about _SDL_main. If any one has any idea let me know.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
you need to include SDL.h in the file that has your main function, and you need to include SDLmain.m in your project.
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #5
I did that. At the top of main.cpp I have #include <SDL/SDL.h> and the SDLmain.m and SDLmain.h are both in the project.
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #6
Either I found the solution or the problem just went away, but if I also put in the GLUT framework I no longer get this error. I just thought I'd post that in case anyone else was having the same trouble.
Quote this message in a reply
Member
Posts: 233
Joined: 2003.05
Post: #7
That's a bizarre solution. In many ways the GLUT framework would be an alternative to SDL and not something you would normally use in addition to SDL.

I tried the same tutorial and this is what I did to get it to work:

File->New Project.
Choose SDL OpenGL Application
Remove the dolphin files from the project and the main file AND the glut framework.
Put the tutorial main in your new project folder and then add it to the project.
Make the following changes to this outdated tutorial:
Change the two GL includes to one:
#include "SDL_opengl.h"
(this does not include "OpenGL/glext.h" in case you need that later, but it is nice and cross platform compilable)
Change int main(void) to:
int main(int argc, char*argv[])

build and go. Smile

If you don't use Xcode but command line instead, you were still at the same place as I was as far as errors, perhaps you didn't change main correctly?

incidentally, there is no real magic in using the OpenGL SDL app template... they just included the OpenGL framework and a bunch of code to delete. :/

If none of this works... try the FAQ or newsgroup

One more tip. Using the CVS version will eventually be a good idea because there is a stupid problem in fullscreen mode that flips your mouse y coordinates in the release version right now.

"Pay no attention to that man behind the curtain." - Wizard of Oz
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #8
I think I'm going to go with that solution because I keep getting that error over and over again even though I'm doing the same thing with each tutorial. Thanks a lot.
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #9
Do the tutorials use C++?
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #10
The tutorials use C++ but were made with .Net so another person ported them to SDL.
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #11
Trying putting:
Code:
#ifdef __cplusplus
extern "C"
#endif
Right before your int main(int argc, char *argv[]) .
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #12
what does that code do?
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #13
My understanding is that it tells the compiler to compile the next line as C instead of C++. The Mac OS X implementation of SDL requires that main be a C function. If the project is C++, then obviously that's a problem and SDL won't be able to find main.

Hopefully that made some sense and is the cause of the problem Wink

Edit: I have the PB project for some of the GameTutorials.com tutorials and they compile fine so I know it is possible.
Quote this message in a reply
Member
Posts: 233
Joined: 2003.05
Post: #14
As far as I know the extern "C" statement is not needed to compile your main and use C++. I've never needed it.

"Pay no attention to that man behind the curtain." - Wizard of Oz
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #15
I think somebody needs to update these tutorials so that they are current and compile better on Macs.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  GLUT game tutorials for OSX Joseph Duchesne 6 4,663 Jun 11, 2003 05:32 PM
Last Post: blb
  2d game with opengl tutorials roka-tarat 3 10,557 May 1, 2002 03:30 PM
Last Post: Jeff Binder