Contents User Forum Source Index APIs by Task APIs by Level Data


Installing G3D

License Compiling and Linking

Windows XP & Windows 2000

  1. Download the latest g3d-xxx.zip from http://g3d-cpp.sf.net
    Unzip all of the files in the distribution to your library directory (e.g. c:\libraries). Note that the single download contains precompiled binaries for MSVC++ 6, MSVC++ 7, gcc on Linux, and Xcode and gcc on OS X.

  2. Download and install SDL version 1.2.7 from http://www.libsdl.org: Win32, Linux, OS X

  3. Microsft Visual C++ 6.0 and Microsoft Visual C++ 7.0 (which comes as part of Microsoft Visual Studio .NET 2002 and 2003) require different versions of the library, and a few different installation steps. Precompiled binaries for MSVC 6 are located in win32-lib and precompiled binaries for MSVC 7 are in win32-lib7. Figure out which one you're using, and point to the right G3D binaries, or you will have strange trouble, including linker errors and memory leaks.

  4. MSVC++ 6:
    1. Install Service Pack 5. (Service pack 6 does not support the processor pack)
    2. Install the Processor Pack.
    3. (Optional) Add the following lines to your Autoexp.dat file (usually in C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin):

       ;; graphics3D
         G3DQuat=Quat(<x>,<y>,<z>,<w>)
         G3DVector4=Vector4(<x>,<y>,<z>,<w>)
         G3DVector3=Vector3(<x>,<y>,<z>)
         G3DVector2=Vector2(<x>,<y>)
         G3DVector4int16=Vector4(<x>,<y>,<z>,<w>)
         G3DVector3int16=Vector3(<x>,<y>,<z>)
         G3DVector2int16=Vector2(<x>,<y>)
         G3DColor4=Color4(<r>,<g>,<b>,<a>)
         G3DColor3=Color3(<r>,<g>,<b>)
         G3DColor4uint8=Color4uint8(<r>,<g>,<b>,<a>)
         G3DColor3uint8=Color3uint8(<r>,<g>,<b>)
         G3DNetAddress=NetAddress(<addr.sin_addr.S_un.S_un_b.s_b1,u.<addr.sin_addr.S_un.S_un_b.s_b2,u.<addr.sin_addr.S_un.S_un_b.s_b3,u.<addr.sin_addr.S_un.S_un_b.s_b4,u)

         ;; Prevent stepping into certain functions
          [ExecutionControl]
          std::*=NoStepInto
         

    4. In Tools:Options:Directories, add the g3d include directory (e.g. c:\libraries\g3d-6_00\include) to the include list. Make sure it preceeds all other include directories.
    5. In Tools:Options:Directories, add the g3d lib directory (e.g. c:\libraries\g3d-6_00\win32-lib) to the library list.

  5. MSVC++ 7 / .NET:
    1. Go to Tools:Options. Select the Projects heading, and within that heading, Visual C++ Directories.
    2. In that panel, select "Show Directories For: Include files."
    3. Add the G3D include directory, G3D_ROOT/include, and the SDL include directory (e.g. C:/SDL-1.2.7/include)
    4. In the same panel, select "Show Directories For: Library Files." Add the G3D library directory, G3D_ROOT/win32-7-lib.

  6. Dev-C++

    Dev-C++ libraries must be first built. The project files are are in the source directory: Graphics3D.dev and G3DGL.dev. Follow these steps to set up and build the library:

    1. Go to Tools:Check for Updates/Packages. Select the devpaks.org Community Devpaks server, click check for updates, and within the list, select zlib, libjpeg, SDL. Download and install these, then again for libpng. Libpng is dependent zlib so you need to first install zlib before you check libpng.
    2. Go to Tools:Compiler Options, click the directories tab, and the C++ includes under that.
    3. Add the G3D include directory, G3D_ROOT/include.
    4. In the same panel, select "Libraries" tab. Add the G3D library directory, G3D_ROOT/mingw-lib.
    5. Open and compile Graphics3D.dev
    6. Open and compile GLG3D.dev
    7. Copy the libraries G3D_ROOT/../temp/mingw32-lib/libG3D.a and G3D_ROOT/../temp/mingw32-lib/libGLG3D.a to the mingw32-lib directory.

    At this point you can now compile new G3D projects, and the demos included in the demo directories.

  7. For each project you create, copy SDL.dll to your program directory (or put it in Windows/System)

Linux

  1. Download the latest g3d-xxx.zip from http://g3d-cpp.sf.net
    Unzip all of the files in the distribution to your library directory (e.g. ~/lib/).

  2. Make sure that SDL version 1.2.7 is installed on your machine. Try running sdl-config --version. If it returns "1.2.7" then you're all set. (sdl-config is a handy tool that tells you what flags to pass to your compiler and linker to use SDL. If you run into SDL trouble, sdl-config is your friend.) If sdl-config can't be found, or returns something other than "1.2.7", you'll need to install or update SDL. Download and install SDL from http://www.libsdl.org.

  3. We recommend using iCompile, which automatically compiles and links every C++ file in the directory it's run from, so you won't need to edit it to refer to each source file (as you would with a Makefile). It needs the following environment variables, which you can set in your .cshrc file using setenv. If you're using iCompile, you will need to set up some environment variables to point to SDL and G3D. Modify the paths as appropriate for your installation:

    INCLUDE ~me/libraries/g3d/include:/usr/include/SDL
    LIBRARY ~me/libraries/g3d/linux-lib
    LD_LIBRARY_PATH $LIBRARY
    CC gcc-3.2
    CXX g++-3.2

    You are also welcome to use a makefile; set compiler and linker flags to point to SDL and G3D.

  4. Confirm that you've installed G3D correctly by installing and running one of the demos:
    cd g3d/demos/GLG3D_Demo
    icompile --run
    This should run the GLG3D demo; you should see many colored airplanesflying around a pink and blue sky.

Mac OS X

See Setting Up a Project in Mac OS X for complete instructions on getting G3D on the mac running with your own code.

Building G3D

You don't have to build G3D to use G3D; the instructions above walk you through setting up your environment to use the precompiled G3D binaries. You may want to build G3D in order to:
  • Step into library functions while debugging
  • Use an unsupported compiler
  • Customize the library code.

We recommend using Xcode 2.1 or 2.2 to build G3D, and then using the same version of Xcode to build your G3D programs, both using Xcode project files included in the source distribution, and from the command line. Here, we first give instructions to get prerequisites required to build either way, then directions to build with Xcode, then include the instructions for a more traditional, unix/command-line style build.

Common Setup

  1. Install Apple's Xcode Development Environment 2.2, from Apple's Developer Site. (It may seem like you have to pay for the privilege of joining the Apple Developer Connection (ADC), but in fact you can get a web-only membership for free.)
  2. Install the SDL 1.2.9 Development Library.

Building G3D with Xcode

  1. Get a copy of the source tree, either via cvs or via the src zip, available on the downloads page. Expand the zip.
  2. Double-click on G3D/cpp/G3DOSX/G3DOSX.xcodeproj. This will launch Xcode.
  3. In Xcode, locate the main toolbar. At the far left of the toolbar, set the active target to G3DTest. Hit "Build."
  4. Command-Shift-B brings up the "Build Results" window. The last line in the output in that window should be "Build succeeded."
  5. With the active target set to G3DTest, hit the "Run" button. The console should come up and give you lots of interesting information about G3D's performance on your machine. Congratulations, you have built G3D on Mac OS X.
  6. Having built G3D, you will probably want to run a demo. We recommend taking advantage of the *.xcodeproj files included in some of the demo directories. They work, if you leave them in their current directory. Open G3D/cpp/source/demos/VAR_Demo/VAR_Demo.xcode. Hit "Build and Go", and you should see little purple and orange planes flying around in a circle.

Building G3D from the command line

  1. gcc 4.0 is the current version for Mac OS X
  2. Install the Python 2.2.2 tool.
  3. Install the Doxygen 1.3.2 tool.
  4. Install the automake 1.7.5 tool (and the corresponding aclocal version).
  5. Install the autoconf 2.57 tool.
  6. Add the paths for these tools to your PATH environment variable (usually in your .cshrc, .tcshrc, or .bashrc file).

  7. TODO: set up LD_LIBRARY_PATH

  8. Log out so all changes can take effect.

  9. Run "<CODE>chmod u+x build</CODE>" in the cpp directory.
  10. Run "<CODE>./build install</CODE>" in the cpp directory
  11. The library and demos will compile in the source tree
Also see the build instructions.

#defines

G3D pays attention to the following defines.

SSE - Allows the use of Intel PIII SSE instructions for faster math routines. On Win32, you will need the Visual Studio processor pack (Free from http://msdn.microsoft.com/vstudio/downloads/ppack/default.asp) to build with this option. Your code will only run on PIII or later machines. If you have the student edition of MSVC, you must remove the define SSE line from platform.h in order to build or you will get errors like vector3.inl(24) : fatal error C1083: Cannot open include file: 'xmmintrin.h': No such file or directory

_MSC_VER - Use Microsoft x86 assembly when assembly code is needed.

NO_SDL_MAIN - Do not attempt to link against sdlmain.lib.

_DEBUG - Build in debug mode and link against the debug runtime DLLs. This enables debugAssert, debugBreak, debugAssertM, array bounds checks, etc. (Can be overriden by G3D_DEBUGRELEASE)

G3D_DEBUG - Enable debugAssert, debugBreak, debugAssertM, array bounds checks, but relies on the _DEBUG flag to indicate whether to compile in debug or release mode.(Can be overriden by G3D_DEBUGRELEASE)

G3D_DEBUGRELEASE (or G3D_RELEASEDEBUG)- Use the release build of G3D and the standard library, but keep assertions that check for user errors. This mode allows your program to run fast but still be debuggable.

G3D_DEBUG_NOGUI - When building in debug mode, this flag says to use stdout and not popups on Windows for assertion failures and error messages. On Linux the console is always used.

G3D_GL_ARB_multitexture_static - Assume OpenGL 1.3 when compiling the G3D library (specifically for Linux). Must be configured when the library is built.

G3D_WINSOCK_MAJOR_VERSION - Controls the Winsock version used on Win32. Must be configured when the library is built.

G3D_WINSOCK_MINOR_VERSION - Controls the Winsock version used on Win32. Must be configured when the library is built.

_WIN32 - Build using Windows API calls

The static libraries themselves are built without SSE. The -debug versions have _DEBUG, the regular versions do not.

G3D #defines one of the following based on the platform: G3D_WIN32, G3D_MINGW32, G3D_LINUX, G3D_OSX



Generated on Thu Aug 2 11:40:43 2007 for G3D by doxygen 1.5.2
Hosted by SourceForge.net Logo