Using glut in CodeBlocks

GLUT is an acronym for OpenGL Utility Toolkit, which is a toolkit that can be used to write OpenGL programs. GLUT is great for learning OpenGL, but it’s not good for developing relatively complex user interfaces. Today I’ll talk about how GLUT is used in Codeblocks.

This topic has been are discussed in both English and Chinese, English version see http://www.sci.brooklyn.cuny.edu/~goetz/codeblocks/glut/, Chinese see “using glut in CodeBlocks (opengl) for Windows”.

Here, paraphrase it again.

Let’s first look at the output of an example program called GLUT.

First, you need to prepare three files, glut32.dll, glut32.lib, Glut.h.
These three files can be downloaded from the Internet. GLUT32 is a dynamically linked library,.h is required at compile time,.lib records the basic information of the library function, and.dll is the implementation of the specific function, which needs to be dynamically loaded when the program runs.
Copy glut32.dll to c:\ Windows /system.
Copy glut32.lib to C :\ Program Files (x86)\codeblocks\mingw\lib.
Copy Glut. h to C :\program files\codeblocks\mingw\include\GL.

Now open Codeblocks, create a new project, and select GLUT Project.

Give the project a name, and then the next step is to specify the location of the GLUT toolkit.

Now that the project is set up, click Compile and run it. It turns out that there are a lot of errors.
To make it work, add the header #include “Windows.h” to the automatically generated main.cpp file, and then compile and run it, and the resulting window will appear. The graphical device interface function is included in Windows.h.

Reproduced in: https://blog.51cto.com/11190017/1762229

Read More: