zoukankan      html  css  js  c++  java
  • 测试程序

    #include <iostream>
    #include <OpenGL/OpenGL.h>
    #include <GLUT/glut.h>

    void display()
    {
        glClear(GL_COLOR_BUFFER_BIT); // 清屏
        glColor4f(0.0, 1.0, 0.0, 0.5);// 绘制矩形
        glRectf(0.1, 0.1, 0.6, 0.6);
        glColor4f(1.0, 1.0, 0.0, 0.7);// 绘制矩形
        glRectf(0.4, 0.3, 0.9, 0.8);
        glFlush(); // 强制绘图完成
    }
    void init()
    {
        glEnable (GL_BLEND);    // 启用融合
        glBlendFunc (GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);//产生融合因子
        glShadeModel (GL_FLAT);// 设置平面明暗处理
        glClearColor (0.0, 0.0, 0.0, 0.0);// 清屏
    }

    void reshape (int w,int h)
    {
        glViewport (0, 0, (GLsizei) w, (GLsizei) h);
        glMatrixMode (GL_PROJECTION);
        glLoadIdentity();
        if (w <= h)
            glOrtho (-1.5, 1.5, -1.5*(GLfloat)h/(GLfloat)w,
                     1.5*(GLfloat)h/(GLfloat)w, -10.0,10.0);
        else{
            glOrtho (-1.5*(GLfloat)w/(GLfloat)h,
                     1.5*(GLfloat)w/(GLfloat)h, -1.5,1.5, -10.0,10.0);
        }
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
    }

    void keyboard(unsigned char key, int x,int y)
    {
        switch (key) {
            case 27:{
                exit(0);
                break;
            }
        }
    }

    int main(int argc,char** argv)
    {
        glutInit(&argc, argv);
        glutInitDisplayMode (GLUT_SINGLE |GLUT_RGB | GLUT_DEPTH);
        glutInitWindowSize (500,500);
        glutInitWindowPosition (100,100);
        glutCreateWindow (argv[0]);
        init ();
        glutDisplayFunc(display);
        glutReshapeFunc(reshape);
        glutKeyboardFunc(keyboard);
        glutMainLoop();
        return 0;
    }

  • 相关阅读:
    normal matrix 正规矩阵
    可解释的机器学习
    Classical wave-optics analogy of quantum-information processing
    java高级性能增强
    nginx、keepalived、lvs了解
    大数据学习之路之Zookeeper
    JAVA中 成员变量和和实例变量一样吗?
    第三章
    Java第二章 基本语法知识点
    java第一章 JAVA语言概述知识点
  • 原文地址:https://www.cnblogs.com/gujianhan/p/3702049.html
Copyright © 2011-2022 走看看