环境: windows10,mingw,CLion
1.下载压缩包里的东西
百度网盘链接: /s/1oGpR3EieX7kUWEvIgNt8Mw 提取码: 1hvt
2.将glut37里的lib和include文件夹分别复制合并到mingw的lib和include
3.CLion中新建project,修改文件,在最后加上一行:
target_link_libraries(project -lopengl32 -lglut32 -lglu32)
- 1
其中,project替换为自己的工程名
然后就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
测试程序
*注意头文件的顺序不能错,这两个一定都要按顺序include,否则跑不了。
#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