Please Comment or Leave a Message if this is what you are looking for or if you have any question/comment/suggestion/request.
First of all download Eclipse from the official website:
Download IDE for Java developers (for example) or the one for C/C++ developer. I’ll download the first for this guide.
Unzip the package in your preferred folder.
Now you can start Eclipse. It will ask you for the workspace folder. You can leave the default.
NOTE: If it doesn’t start after setting launcher options then MOVE eclipse in another folder, maybe without any space within the path name.
Install Java SDK
Download the Java SDK (JDK):
I got the “jdk-6u24-windows-i586.exe” installer.
Install it. Easy :).
Install OpenGL Libraries for Java (Mac and Windows)
I use JOGL for this.
It is maintained by jogamp, there: http://jogamp.org/jogl/www/
Download JOGL from: http://jogamp.org/deployment/webstart/archive/
For Windows I Downloaded: jogl-2.0-b23-20110303-windows-i586.7z (http://jogamp.org/deployment/webstart/archive/jogl-2.0-b23-20110303-windows-i586.7z). For Mac I got the “jogl-2.0-pre-20101104-macosx-universal” package.
Extract it in a reasonable place, maybe in a subfolder named “jogl-2.0″… something like “C:libjogl-2.0” (or equivalent in Mac).
Now we have to bind it with Eclipse IDE. I will explain only the minimum amount of work to do for this (just to have it working) because I know that the first thing that someone wants is have t working and looking into the detail later, when we are already happy that it works! :)
Open Eclipse Preferences (e.g. “Windows->Preferences” in Windows Helios or “Eclipse->Preferences” in Mac Galileo).
In the form open:
Java->Build Path->User Libraries
Click the “New…” button and in the dialog type something sensible in the library name box. Something such as “jogl-2.0″:
Select the newly created entry and click on the “Add JARs…” button. Browse where the jogl package has been extracted and enter in the jar folder. Once in the folder you need to select just those files:
Once this is done, you have to set the lib folder for each one of those. Just expand each entry, select the Native library location field, click “Edit…” and browse until you reach the lib folder of the same extracted jogl package:
Repeat this for each entry.
In order to use it in your (any) Java project, go into the project’s properties page (right click on the project in the Project Explorer window and select “Properties”).
In the properties page open the “Java Build Path” page, then select the “Libraries” tab and click the “Add Library…” button. In the selection window select “User Library“:
Click “Next” and select our jogl-2.0 library”
And click “Finish”
Once this is done you are ready to write and run OpenGL Java apps.
Install CDT Plugin for Eclipse (for C/C++ projects)
Help->Install New Software…
From the list select the CDT repository for helios, or add it if it is not there: http://download.eclipse.org/tools/cdt/releases/helios
and select the CDT Main Features:
Then just follow the installation flow (Next, Next, Accept License Agreement, etc)
Restart Eclipse when asked
You can show the icon for quick access clicking on the Open Perspective button or accessing it from the menu Window->Open Perspective. Select “Other…” and select the C/C++ perspective:
Now both Java anc C/C++ perspectives will be available with one click:
Install the C/C++ compiler (Windows)
I use MiniGW to build the project. You can take it from there: http://www.mingw.org/
Install it in an easy-to-reach folder. “C:MiniGW” is perfect for this.
I Install only the C++ Compiler, MSYS Basic System and the MiniGW Developer Toolkit:
This should be enough to meke Eclipse Happy to build our C/C++ projects.
When building C/C++ projects in Windows I use the MiniGW/CDT Toolchain, while In Mac I use MacOSX/GNU.
To set this in Windows, Open Project Preferences and then “C/C++ Build->Tool Chain Editor“. Here select MiniGW GCC, CDT Internal Builder.
Set OpenGL for C++ (Windows)
Before starting, just remember to edit (almost) always the settings for both configuration (Debug and Release) at the same time. This can save some time and problems when switching configuration.
To build OpenGL applications in C/C++ you generally need (at least) gl.h and glu.h headers, glu32 and opengl32 libraries (lib and dll).
Those headers can come with Windows SDK installation and for example you can find them there: “C:Program FilesMicrosoft SDKsWindowsv7.0AIncludeGL” and “C:Program FilesMicrosoft SDKsWindowsv7.0ALib”, while the runtime dlls should already be in the WindowsSystem32 (or equivalent) folder.
You can find the headers in the “C:MinGWincludeGL” folder as well and I have those one set in my environment.
To set the necessary paths open the Project properties, and select “C/C++ General->Paths and Symbols“.
In the “Include tab you can set useful path for headers and in the “Libraries” tab you can do the same for lib files.
To set Includes, select “GNU C/C++” language (if you are building a C++ project) and add all the paths needed.
In my case I have those set:
Remember to set those values for both Debug and Release configurations.
Note that if you installed MiniGW then the libraries files needed to build the solution are already picked up from there. In the specific they are “libglu32.a” and “libopengl32.a” in “C:MinGWlib” in my case. So you have just to tell Eclipse that you want to use them, as we already did just above, and don’t worry about the libraries paths.
When you run it, you will instead need the DLLs, but as already mentioned they will be already in the WindowsSystem32 folder.
Another thing to note is that some settings are available and configurable through different menus… this can be confusing at first, but doing just few experiments can help in acquiring more confidence when touching those settings. One example of this is the setting we just done, the one related to setting headers and libraries folders. In fact, instead of setting them in the way I described, you can set them always using the Project Properties page, but using the “C/C++ Build->Settings” page. The picture shows the Linker Libraries settings in this section (the same set previously through the other menu):
Installing GLUT for C++ (Windows)
If you are serious about doing something with OpenGL, you will probably need to download another piece of software that simplifies the development of a multi-platform window system independent app.
You can find them there: http://www.opengl.org/resources/libraries/glut/
The latest version (quite old as well) is the 3.7, but I worked with the 3.6 and it does the job.
Just grab a version and unzip it a good place. You can use the previously created “C:lib” folder if you prefer.
To build and run your app you need just few files:
I suggest to organise them distributing them in good named folders:
Once this is done, just update the headers and libraries paths to use it.
NOTE: Remember to put the DLL into your app executable folder or in a system folder (WindowsSystem32).
Set OpenGL and GLUT for C++ (Mac)
Setting OpenGL on the Mac is somehow easier from one point of view, but I think that it is trickier to discover how to set-up initially.
It is easier because you should already have all you need (headers and libraries) in your OS.
You can find them in “/System/Library/Frameworks/OpenGL.frameworks/“. So, nothing really to do here.
The nice thing here is that GLUT as well comes with the system, and you should find it in “/System/Library/Frameworks/GLUT.frameworks/” :):
In order to set-up them in Eclipse, open the project properties and go in:
“C/C++ Build->Settings->MacOSX C++ Linker->Miscellaneous” and write this in the Linker flags text box:
“-framework GLUT -framework openGL -framework Cocoa“. This is the tricky step to find initially I recon.
… and you are ready to go!
Bonus – Install Subversive Plugin for Eclipse
Install SVN if you need one.
As already done for CDT use:
Help->Install New Software…
To install Subversive select the Helios entry and Install the option that you prefer. I selected just the Team Provider and Revision Graph options:
I hope that this helped you sorting out some of part of all the settings and the nitty-gritty details that must be addressed in order to successfully build OpenGL applications in Windows or Mac, using Java or C++. In my experience those are often that sort of things that sometime can become frustrating problems when you need to spend hours or days trying to figure out what is missing.
If this helped you or you find this interesting or if you have some tips to share, please leave a comment and link to this page so that other people can benefit from it.