zoukankan      html  css  js  c++  java
  • win7配置opengl

    Qt本身不包括glut工具库,如果要使用glut库,该怎么做呢?

    下面来简述一下Qt下怎么安装glut库:

     

    1.首先需要去opengl的官网下载glut库:

    http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip

     

    2.解压后,将glut32.lib和glut.lib两个文件拷贝到qt目录下的./lib文件夹中;

     

    3.将glut.dll和glut32.dll两个动态链接库拷贝到C:windowssystem32中;

     

    4.将glut.h文件拷贝到qt目录下的includeQtOpenGL中,并建立glut文件【内容写上 #include "glut.h"】,保存为没有后缀名的文件;

     

    5.切换到自己的程序中,在 **.pro 文件中添加:

       LIBS += -lgut32

       LIBS += -LC:glut

     

    6. 在main.cpp中加入“#include<glut>”或者“#include<glut.h>”,这样就可以使用glut中的函数了。

     

    7. 下面来看一个简单的例子:

    #include <windows.h>
        #include <glut.h>
        void init(void)
        {
          glClearColor(1.0, 1.0, 1.0, 0.0);
          glMatrixMode(GL_PROJECTION);
          gluOrtho2D(0.0, 200.0, 0.0, 160.0);
        }
        void lineSegment(void)
        {
          glClear(GL_COLOR_BUFFER_BIT);
          glColor3f(1.0, 0.0, 0.0);
          glBegin(GL_LINES);
          glVertex2i (180, 15);
          glVertex2i (10, 145);
          glEnd();
          glFlush();
        }
        int main(int argc, char **argv)
        {
          glutInit(&argc, argv);
          glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
          glutInitWindowPosition(50, 100);
          glutInitWindowSize(400, 300);
          glutCreateWindow("Example OpenGL Program");
          init();
          glutDisplayFunc(lineSegment);
          glutMainLoop();
        }

     

  • 相关阅读:
    Bundle 机制
    三次握手和四次挥手
    SparseArray
    ThreadLocal ——android消息机制handler在非主线程创建not called Looper.prepare() 错误的原因
    怎么去除重复代码
    ClassLoader
    android的四种线程池
    LeetCode#50 Pow(x, n)
    LeetCode#49 Anagrams
    LeetCode#48 Rotate Image
  • 原文地址:https://www.cnblogs.com/wlcaption/p/3868743.html
Copyright © 2011-2022 走看看