Environment: windows 10.mingw,CLion
1. Download the contents of the zip
Baidu.com Link./s/1oGpR3EieX7kUWEvIgNt8Mw Extract code: 1hvt
2. Copy and merge the lib and include folders in glut37 into the lib and include folders in mingw.
3.CLionin the new project, modify the file, and add a line at the end:
target_link_libraries(project -lopengl32 -lglut32 -lglu32)
- 1
where project is replaced by the name of your own project.
Then it's OK.
cmake_minimum_required(VERSION 3.12)
project(gltest)
set(CMAKE_CXX_STANDARD 11)
add_executable(gltest )
target_link_libraries(gltest -lopengl32 -lglut32 -lglu32)
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
test program
* Note that the order of the header files can not be wrong, both must be in order to include, otherwise you can not run.
#include <GL/>
#include <GL/>
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 0, 0.5);
glutWireIcosahedron();
glFlush();
return;
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(0, 0);
glutInitWindowSize(600, 600);
glutCreateWindow("My OpenGL");
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24