Using FreeGlut With Code - Blocks - CodeBlocks
Using FreeGlut With Code - Blocks - CodeBlocks
Written By John Mieske ( Also known by his game name as JackDawson 23:43, 10 July 2011 (CEST) )
Contents
1 A little Info on Glut32 and FreeGlut
2 Operating System Info
3 What You Need To Download
4 Installation
5 The wizard.script File
6 The glut.cbp File
7 Time to run the demo code from Code::Blocks itself
http://www.xmission.com/~nate/glut.html
NOTE : The latest version of the Glut32 library is 3.7.6 ( Dated Nov 8, 2001 )
http://freeglut.sourceforge.net/index.php#download
in that link you will see the title : Prepackaged Releases and the first link takes you to the binaries to be downloaded on this link
http://www.transmissionzero.co.uk/software/freeglut-devel/
Its in there where you will see the MinGW download package that Is described in this tutorial. ( NOTE : Latest Binary release is dated May 11th 2013 known as
Martin Payne's Windows binaries. )
This was in reference to Windows and Linux packages according to their website.
When Glut32 was ported over it stopped being updated in 2001. So some folks decided to recreate it and named it FreeGlut. The interesting part is freeGlut and Glut32
can be installed just about the same way for Code::Blocks, with the exception that you would not have to edit the two scripts if your installing Glut32. FreeGlut and
Glut32 are a set of functions for use with OpenGL. It has made graphic software a little easier to code when it comes to programming OpenGL with 3D in mind.
EDIT ( December 4th 2011 ) : Because I am constantly being asked why they cannot see the files to edit that I listed below, well keep in mind its about file
extensions that are hidden. You can change your extensions to show up in your Windows Explorer ORGANIZE. So its ORGANIZE --> FOLDER AND
SEARCH OPTIONS --> VIEW ( TAb ) and then you should see where its saying to hide the file extensions. You do NOT want to hide your extensions except
your protected system files. Leave those hidden.
http://wiki.codeblocks.org/index.php?title=Using_FreeGlut_with_Code::Blocks&printable=yes 1/7
12/10/2017 Using FreeGlut with Code::Blocks - CodeBlocks
3.) FreeGlut (http://freeglut.sourceforge.net) Do NOT get the source code. GET THE BINARIES. [ Example : freeglut-MinGW-2.8.1-1.mp.zip ] ( Latest stable
release dated 2013 )
http://wiki.codeblocks.org/index.php?title=Using_FreeGlut_with_Code::Blocks&printable=yes 2/7
12/10/2017 Using FreeGlut with Code::Blocks - CodeBlocks
Think of freeglut as if it was the Glut32 Binaries, which the original source code to Glut32 was never available since its proprietary. But once you get the
GLUT demo working, you can play with the freeglut source code from their website. You can however still play with the Ported Glut32 source code. It's latest
stable release was back in 2001 though.
Installation
Once you install Code::Blocks, then you can download and unzip the freeglut ZIP file, which will contain this..
Move all of those files and folders into the C:\Program Files (x86)\CodeBlocks\mingw folder. ( This is the folder where you see Include and Lib folders. This is
important. ) If it asks you to overwrite folders, that's OK, say yes. It will not overwrite anything important.
Now copy, do not move, just copy the freeglut.dll file that should currently be in your C:\Program Files (x86)\CodeBlocks\minGW folder into your C:\Windows
folder. The reason to copy this into that folder is because C:\Windows is in your path, and to keep the confusion down, It is easier to just copy it to there. You can
always change it later. It would be highly advised that you add the C:\Program Files (x86)\CodeBlocks\MinGW\bin folder to your path as well.
So now that you have copied the correct files and are ready to setup Code::Blocks, go to this folder : C:\Program Files
(x86)\CodeBlocks\share\CodeBlocks\templates\wizard\glut and in there you will see a file named wizard.script. Its this file where it is looking for Glut32. You just
simply replace any reference to Glut32 with freeglut. And it really is that simple.
NOTE : USE NOTEPADD or NOTEPADD ++, do Not use Microsoft word or WordPad.
// globals
GlutPathDefault <- _T("$(#glut)");
GlutPathDefaultInc <- _T("$(#glut.include)");
GlutPathDefaultLib <- _T("$(#glut.lib)");
GlutPath <- _T("");
function BeginWizard()
{
local intro_msg = _T("Welcome to the new GLUT project wizard!\n\n" +
"This wizard will guide you to create a new project\n" +
"using the GLUT OpenGL extensions.\n\n" +
"When you 're ready to proceed, please click \"Next\"...");
Wizard.AddInfoPage(_T("GlutIntro"), intro_msg);
Wizard.AddProjectPathPage();
if (PLATFORM == PLATFORM_MAC)
{
GlutPathDefault="/System/Library/Frameworks/GLUT.framework";
}
else
Wizard.AddGenericSelectPathPage(_T("GlutPath"), glutpath_descr, _T("Please select GLUT's location:"), GlutPathDefault);
Wizard.AddCompilerPage(_T(""), _T("*"), true, true);
}
////////////////////////////////////////////////////////////////////////////////
// GLUT's path page
////////////////////////////////////////////////////////////////////////////////
function OnLeave_GlutPath(fwd)
{
if (fwd)
{
local dir = Wizard.GetTextControlValue(_T("txtFolder")); // txtFolder is the text control in GenericSelectPathPage
local dir_nomacro = VerifyDirectory(dir);
if (dir_nomacro.IsEmpty())
return false;
http://wiki.codeblocks.org/index.php?title=Using_FreeGlut_with_Code::Blocks&printable=yes 3/7
12/10/2017 Using FreeGlut with Code::Blocks - CodeBlocks
if (PLATFORM == PLATFORM_MSW)
{
if (!VerifyLibFile(dir_nomacro_lib, _T("freeglut"), _T("GLUT's"))) return false;
}
else
{
if (!VerifyLibFile(dir_nomacro_lib, _T("glut"), _T("GLUT's"))) return false;
}
// Debug
local target = project.GetBuildTarget(Wizard.GetDebugName());
if (!IsNull(target))
{
target.SetTargetType(ttConsoleOnly); // ttConsoleOnly: console for debugging
target.SetOutputFilename(Wizard.GetDebugOutputDir() + Wizard.GetProjectName() + DOT_EXT_EXECUTABLE);
target.SetWorkingDir(GlutPath + _T("/bin"));
// enable generation of debugging symbols for target
DebugSymbolsOn(target, Wizard.GetCompilerID());
}
// Release
target = project.GetBuildTarget(Wizard.GetReleaseName());
if (!IsNull(target))
{
target.SetTargetType(ttExecutable); // ttExecutable: no console
target.SetOutputFilename(Wizard.GetReleaseOutputDir() + Wizard.GetProjectName() + DOT_EXT_EXECUTABLE);
target.SetWorkingDir(GlutPath + _T("/bin"));
// enable optimizations for target
OptimizationsOn(target, Wizard.GetCompilerID());
}
return true;
}
Also, this line "if (!VerifyLibFile(dir_nomacro_lib, _T("glut32"), _T("GLUT's"))) return false;" should now say "if (!VerifyLibFile(dir_nomacro_lib,
_T("freeglut"), _T("GLUT's"))) return false;"
NOTE : Because of windows Protections, it will force you to save it somewhere else. Just save it to your desktop and then MOVE the file into the same folder as the
old one and overwrite. It will ask for permission, click continue. ( or yes on some machines ).
http://wiki.codeblocks.org/index.php?title=Using_FreeGlut_with_Code::Blocks&printable=yes 4/7
12/10/2017 Using FreeGlut with Code::Blocks - CodeBlocks
in there you will find glut.cbp
This is the file that is for your project to work off of. You need to edit this too. Here is the code :
See this line "<Add library="Glut32" />" should now say "<Add library="freeglut" />"
NOTE : Because of windows Protections, it will force you to save it somewhere else. Just save it to your desktop and then MOVE the file into the same folder as the
old one and overwrite. It will ask for permission, click continue. ( or yes on some machines ).
http://wiki.codeblocks.org/index.php?title=Using_FreeGlut_with_Code::Blocks&printable=yes 5/7
12/10/2017 Using FreeGlut with Code::Blocks - CodeBlocks
http://wiki.codeblocks.org/index.php?title=Using_FreeGlut_with_Code::Blocks&printable=yes 6/7
12/10/2017 Using FreeGlut with Code::Blocks - CodeBlocks
So yea.. run the demo right out of the original Code::Blocks code and you will see some red spinning objects. :)
http://wiki.codeblocks.org/index.php?title=Using_FreeGlut_with_Code::Blocks&printable=yes 7/7