zoukankan      html  css  js  c++  java
  • OPenGL 库文件的添加

    OPenGL使用前必须添加一些必要的库文件:

    需要安装 GLUT 工具包:

    GLUT下载地址   GLAUX下载地址

    Windows 环境下安装 GLUT 的步骤:
    1、将下载的压缩包解开,将得到 5 个文件
    2、在“我的电脑”中搜索“gl.h”,并找到其所在文件夹(如果是 VisualStudio2005,则应该是其安装目录下面
    的“VCPlatformSDKincludegl 文件夹”) 。把解压得到的 glut.h 放到这个文件夹。
    3、把解压得到的 glut.lib 和 glut32.lib 放到静态函数库所在文件夹(如果是 VisualStudio2005,则应该是其安
    装目录下面的“VClib”文件夹) 。

    4、把解压得到的 glut.dll 和 glut32.dll 放到操作系统目录下面的 system32 文件夹内。 (典型的位置为:
    C:WindowsSystem32)

    应用时请加载一些头文件

    #include <GL/glut.h> //必须添加

    #include <stdio.h>

    #include <stdlib.h>

    #pragma comment (lib,"glut.lib")

    #pragma comment(lib,"glut32.lib")

    #pragma comment(linker, "/subsystem:"windows" /entry:"mainCRTStartup"")//如果嫌每次多谈一个窗体出来不爽,可以添加这句

    //以下是测试代码

    void myDisplay(void)
    {
        glClear(GL_COLOR_BUFFER_BIT);
        glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
        glFlush();
    }
    int main(int argc, char *argv[])
    {
        glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
        glutInitWindowPosition(100, 100);
        glutInitWindowSize(400, 400);
        glutCreateWindow("第一个 OpenGL 程序");
        glutDisplayFunc(&myDisplay);
        glutMainLoop();
        return 0;
    }

    效果图:

  • 相关阅读:
    802.11帧
    art中的部分内容,留着慢慢研究
    802.11基础知识
    opkg
    openwrt生成备份文件
    lua中获取时间
    php学习四:数组(一)
    php学习三:函数
    php学习二:表达式
    php学习一:语法规则
  • 原文地址:https://www.cnblogs.com/mqxs/p/3544862.html
Copyright © 2011-2022 走看看