OpenGL实践之--环境搭建

  地址:https://www.cnblogs.com/xin-lover/articles/8367639.html

  我的OpenGL开发环境为manjaro 的testsing,2021年1月17日最新更新。编辑器vim,gcc版本10.2.0

代码为main.c

 1 //This is c++ program code!
 2 /* *=+=+=+=+* *** *+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 3   * 文档信息: *** :~/WORKM/openGl/main.cpp
 4   * 版权声明: *** :(魎魍魅魑)MIT
 5   * 联络信箱: *** :guochaoxxl@163.com
 6   * 创建时间: *** :2021年01月17日的下午09:42
 7   * 文档用途: *** :C++入门经典(第10版)
 8   * 作者信息: *** :guochaoxxl(http://cnblogs.com/guochaoxxl)
 9   * 修订时间: *** :2021年第02周 01月17日 星期日 下午09:42 (第017天)
10   * 文件描述: *** :自行添加
11  * *+=+=+=+=* *** *=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+*/
12 #include <GL/glut.h>
13 #include <stdlib.h>
14
15 void init(){
16     glClearColor(0.0, 0.0, 0.0, 0.0);
17     glMatrixMode(GL_PROJECTION);
18     glOrtho(-5, 5, -5, 5, 5, 15);
19     glMatrixMode(GL_MODELVIEW);
20     gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0);
21
22     return;
23 }
24
25 void display(){
26     glClear(GL_COLOR_BUFFER_BIT);
27     glColor3f(1.0, 0, 0);
28     glutWireTeapot(3);
29
30     glFlush();
31
32     return;
33 }
34
35 int main(int argc, char **argv)
36 {
37     glutInit(&argc, argv);
38     glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
39     glutInitWindowPosition(0, 0);
40     glutInitWindowSize(300, 300);
41
42     glutCreateWindow("OpenGL 3D View");
43
44     init();
45     glutDisplayFunc(display);
46
47     glutMainLoop();
48
49     return 0;
50 }

Makefile文件:

 1 main:main.cpp
 2     gcc -g -lglut -lGLU -lGL main.cpp -o main

编译命令:

  make

posted @ 2021-01-17 22:15  叕叒双又  阅读(134)  评论(0编辑  收藏  举报