It is an easy procedure to add OpenGL in CodeBlocks and prepare your Windows PC for OpenGL Coding. By the way, those who are thinking OpenGL is a kind of Programming Language, you are wrong. OpenGL is a Graphics Library. It will give you scope to design graphical interfaces with a bunch of code. Lets see, How to add it in CodeBlocks. I hope you have already installed CodeBlocks in your PC.
- Download GLUT (OpenGL Utility Tool) from here.
Unzip the .zip file. There you will find 5 files: glut32.dll
Now you have to do some Copy-Paste works 🙂 .
- Go to Windows > system in your System Drive. Usually its C:\Windows\system. Now copy the glut32.dll file there.
- Go to C:\Program Files directory. Create a new folder and give it a suitable name. I named it “OpenGL Lib“.
- Create 2 folders in C:\Program Files\OpenGL Lib called include & lib. Copy glut32.lib in the lib folder. Create a folder called GL in the include folder and copy glut.h in it. You Are Almost Done 🙂 Now Open CODEBLOCKS. I am giving some Screenshots to help you.
- Create a New Project in CodeBlocks. It should be a Glut Project. Then Click Next.
- Give a Name to your Project. I named it Test Project.
- Select the Location of the Glut from Program Files Directory. Click Next.
- Then this screen will appear. Don’t change anything here. Click Finish.
- Open Management Bar (Shift + F2). Select Project tab. Open main.cpp. It is a sample code provided there.
- Write #include<windows.h> in Line 14. Go to Project> Build Options.
Go to Linker Settings tab and Click Add. A Little Window will Appear saying “Keep this as relative path?”. Select No and press OK.
- Build the project and Run.
If you have done everything correctly you will see this.