Configuring a GLUT Development Environment Using Eclipse in Windows
It's no secret that Eclipse is my IDE of choice these days - It's also not a secret that Linux is my preferred development environment. However recently I found myself requiring to develop an OpenGL application in Windows XP.
Despite being free Visual Studio Express was not an option at the time. So I set about looking for a way to tie Eclipse and GLUT together in a way that would suit me (i'm not going to get into alternatives to GLUT just now - suffice to say this is the OpenGL toolkit I prefer).
The following is a guide to demonstrate how simply Eclipse can be configured for OpenGL development.
1. Install Eclipse
I have assumed that if you are reading this tutorial, then you are already an Eclipse user. If not you can download the latest build on the Eclipse download page. At time of writing I am using Eclipse SDK 3.2.2.
2. Install Eclipse C/C++ Development Tooling (CDT)
This plugin is accepted by most as the best C/C++ solution for Eclipse, and I agree whole heartedly. Installing the CDT plugin is the same as most other Eclipse plugins and does not need to get covered here. A plugin installation guide can be found in the Eclipse Documentation.
3. Install W32 gcc Compiler and Tools (MinGW and MINSYS)
- Download the current WinGW and MSYS distribution from the MinGW download page.
- Run MinGW-x.x.x.exe. I recommend using the current packages and installing at least 'MinGW base tools', 'g++ compiler' and 'MinGW Make'. Be careful not to install to a path containing spaces.
- Run MINSYS-x.x.x.exe. When asked, be careful to fill in the path to MinGW correctly using forward slashes (/).
- Add the bin directory of both MinGW and MINSYS to the PATH environment variable. e.g:
';C:\msys\1.0\bin;C:\mingw\bin'. - Open a command prompt and test the installation with the following commands:
make --version
g++ --version
4. Install GLUT for MinGW
- Download and unzip glutming.zip
- Copy glut32.dll to '\Windows\System32' folder. This is the glut library and allows glut built openGL applications to run.
- Copy glut.h to '\MinGW\include\GL' folder.
- Copy libglut32.a to '\MinGW\lib' folder.
FIN
Creating a project
- Start Eclipse and create a new project of type 'Managed Make C++ Project'
- Add the GLUT libraries to the project in the Project Properties page (Project -> Properties)
- Select 'C/C++ Build'
- Select 'Libraries' under 'GCC c++ Linker'
- Click the add entry icon and add the following entries
glut32
glu32
opengl32 - Accept the changes and return to the project
- Create a new source file (File -> New -> Other... -> C++ -> Source File) with the extension '.cpp'
- Copy and paste the following source code:
#include <windows.h>
#include <gl/glut.h>void render(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(-1.5f,0.0f,-6.0f);
glBegin(GL_TRIANGLES);
glVertex3f( 0.0f, 1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glEnd();glutSwapBuffers ( );
}void reshape(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(80, (float)w/(float)h, 1.0, 5000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);glutInitWindowSize(500, 500);
glutCreateWindow("GLUT Test");glutDisplayFunc(render);
glutReshapeFunc(reshape);glutMainLoop();
return 0;
} - Save the file. This automagically triggers the compile process. No errors should be reported and an exe file produced. When run a window with a white triangle should be seen confirming the installation was a success.
- FIN -
2042About this entry
You’re currently reading “Configuring a GLUT Development Environment Using Eclipse in Windows,” an entry on ReloadSystems
- Published:
- 05.25.07 / 2pm
- Category:
- OpenGL
No comments
Jump to comment form | comments rss [?] | trackback uri [?]