[go: up one dir, main page]

0% found this document useful (0 votes)
14 views3 pages

How To Install CodeBlocks and MinGW For OpenGL

This document provides a step-by-step guide on installing Code::Blocks and MinGW for OpenGL, C++, and GLUT on Windows XP. It includes instructions for downloading necessary files, installing the software, configuring settings, and creating a console application. The document also includes a sample code for a simple OpenGL program that displays a red square.

Uploaded by

josh1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views3 pages

How To Install CodeBlocks and MinGW For OpenGL

This document provides a step-by-step guide on installing Code::Blocks and MinGW for OpenGL, C++, and GLUT on Windows XP. It includes instructions for downloading necessary files, installing the software, configuring settings, and creating a console application. The document also includes a sample code for a simple OpenGL program that displays a red square.

Uploaded by

josh1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

How to install CodeBlocks and MinGW for Using OpenGL, C++

and GLUT in Windows Xp

Code::Blocks is a free and open source, cross-platform IDE which supports multiple
compiliers including GNU Compiler Collection (GCC) and Microsoft Visual C++ (MSVC
or VC++). It is developed in C++ using wxWidgets as the GUI toolkit. Using a plugin
architecture, its capabilities and features are defined by the provided plugins.
Currently, Code::Blocks is oriented towards C/C++. GNU is a UNIX-like operation
system.

MinGW (Minimalist GNU for Windows) is a native software port of the GCC and GNU
Binutils (Binary Utilities) for use in the development of native Microsoft Windows
applications on Windows itself or as cross compiler. It is deployed along with a set of
freely distributable import libraries and header files for the Windows API. MinGW
allows developers to create native Microsoft Windows applications. Included in
MinGW are extensions to the Microsoft Visual C++ runtime library to support C99
functionality.
As a consequence, a predominant feature of MinGW that may not be apparent to
Open Source users at first, is that it does not use the GNU libc (C Library), but
attempts to directly utilize the MS C Runtime Library (MSVCRT). Hence it aims to be
as native as possible, in contrast to Cygwin. For languages other than C, MinGW uses
the GNU libraries (for example, GNU libstdc++ for C++).

Step 1
Download CodeBlocks and MinGW from the CodeBlocks website. Be sure to select
the binary installer (.exe file) which comes with the MinGW compiler (the file you
need is: ‘codeblocks-10.05mingw-setup.exe’ ).

Step 2
Download the GLUT file for MinGW gcc. You’ll need by click here and downloading
‘glut.zip’

Step 3
Install CodeBlocks and MinGW in the floder ‘C:\Program Files\CodeBlocks’ by
running the ‘.exe’ file you downloaded in Step 1. The default install options are
sufficient.

Step 4
Extract the ‘Glut.zip’ file you downloaded in Step 2 and do the following:-
- Copy glut.dll into your ‘C:\Windows\System32’folder (or
‘C:\Windows\SysWOW64’ if you’re using Win7 64 bit).
- Copy glut.h into the ‘C:\Program Files\CodeBlocks\MinGW\include\GL’ floder.
- Copy libglut32.a into the ‘C:\Program Files\CodeBlocks\MinGW\lib’ folder

1
Step 5
Starup CodeBlocks and select “Settings >Compiler and debugger >Toolchain
executables”. When a window is shown, you make sure that the compiler’s
installation directory is set in “C:\Program Files\CodeBlocks\MinGW”. That will let
your compiling, linker and debugging run correctly.

Step 6
Select “Settings >Compiler and debugger >Global complier settings >Linker setting”
- Click “Add” button which is located under the Text area of Linker libraries.
Then add “libopengl32” into the libraries.
- Click “Add” button again.
Add “libglu32” into the libraries.
- Click “Add” button one more time.
Add “libglut32” into the libraries.

Step 7
- Select “View >Manager”
in order to let you view your project being displayed in the Workspace explorer
frame on the left of the screen when you work on a project.
- Select “View > Logs”
in order to let you view the compiling information being displayed in the Logs &
other frame on the bottom of the screen when you compile or run your project.

Now you have all the required software installed. You can create a new console
application for your OpenGL and GLUT project.

How to Create a Console Application for OpenGL and GLUT


- Startup CodeBlocks and select ‘File > New > Project…’.
- In the new project window select ‘Console application’ and click the ‘Go’ button.
- In the Console application window select ‘C++’ and click ‘Next’ button.
- In the Console application window type your project name in the text field of
‘Project title:’ In the text field of ‘Folder to create project in:’ type an appropriate
folder path in which you want your project to be located as well. Then click ‘Next’
button.
- In the next window just click ‘Finish’ button to accept all default settings. You
should note that the text field of Compiler is GNU GCC compiler.

2
- Your project should be displayed in the Management frame on the left of the
screen. When you double click the ‘source’ item of the project tree In the Projects
window, you will see a main.cpp icon is attached below the source icon.
- Double click the ‘main.cpp’ icon; you will see the template of ‘Hello world!’
program shown on the Working frame in left part of the screen.
- Now you can rewrite the main.cpp by your own application program such as the
one shown below. Build and run the program which displays a red square on a
black window.

// A simple testing program for OpenGL with GLUT


#include <GL/glut.h>
void mydisplay()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd();
glFlush();
}
int main()
{
glutCreateWindow("simple");
glutDisplayFunc(mydisplay);
glutMainLoop();
return 0;
}

You might also like