win7+mingw+opengl+eclipse

来源:互联网 发布:域名主机 编辑:程序博客网 时间:2024/05/22 05:25

1.下载glut

这里就不上传了,百度glut-3.7.6-bin.zip即可

目录

 

 

 

2.用文本新建Demo10.cpp

 

#include <windows.h>#include <GL/glut.h>#include <GL/glu.h> void Init() {       glClearColor(0, 0, 0, 0);       glMatrixMode(GL_PROJECTION);       glOrtho(-5, 5, -5, 5, 5, 15);       glMatrixMode(GL_MODELVIEW);       gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0);} void Display() {       glClear(GL_COLOR_BUFFER_BIT);       glColor3f(1.0, 0, 0);       glutWireTeapot(3);       glFlush();} int main(int argc, char* argv[]) {       glutInit(&argc, argv);       glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);       glutInitWindowPosition(0, 0);       glutInitWindowSize(300, 300);        glutCreateWindow("OpenGL 3D View");        Init();       glutDisplayFunc(Display);        glutMainLoop();       return 0;}


进入命令行

D:\ProgramFiles\MinGW\bin\g++ -o Demo.exe -Wall Demo10.cpp glut32.lib -lopengl32 -lglu32

 

生成Demo10.exe

 

打开运行


 

 

 

0 0
原创粉丝点击