zoukankan      html  css  js  c++  java
  • 用openGL实现用黑白相间的棋盘图案填充多边形

    #include<gl/glut.h>
    #include<windows.h> 
    int n=0;  
    float a0=200,b0=200,a1=400,b1=200,a2=400,b2=400,a3=200,b3=400; 
    int winWidth=600,winHeight=500;
    
    void Initial(void) 
    {  
        glClearColor(1.0f,1.0f,1.0f,1.0f);  
    } 
    
    void ChangeSize(int w,int h)
    {  winWidth=600,winHeight=550; 
        glViewport(0,0,w,h);  
        glMatrixMode(GL_PROJECTION);  
        glLoadIdentity();   
        gluOrtho2D(0.0,winWidth,0.0,winHeight); 
    } 
    
    void Display() 
    {  
        glColor3f(0.0f,0.0f,0.0f);  
        GLubyte fly[]=  
        {   0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,  
            0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,  
            0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,  
            0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,   
            0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff, 
            0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,  
            0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,  
            0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,  
            0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,  
            0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,  
            0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,  
            0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,  
            0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,  
            0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,  
            0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,  
            0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,  
        };
        glEnable(GL_POLYGON_STIPPLE);  
        glPolygonStipple(fly);  
        glRectf(5,5,800,800);  
        glutSwapBuffers();  
    }
    int main(int argc,char *argv[]) 
    {  glutInit(&argc,argv);
       glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
       glutInitWindowSize(400,300);
       glutInitWindowPosition(100,100);
       glutCreateWindow("用黑白相间的棋盘图案填充多边形");
       glutDisplayFunc(Display);
       glutReshapeFunc(ChangeSize);
       Initial();
       glutMainLoop();
       return 0;
    }
    View Code

     参考了别人的代码,刚接触这个东西,感觉函数名真多。。。尤其是vc++6.0没有智能感知,写的真累。

  • 相关阅读:
    laravel faker,种子文件,数据工厂,数据填充
    phpstorm2020 修改快捷注释时的斜杠的位置
    rbac 4表 常规设计
    laravel 模型迁移文件常规字段设计
    php artisan 常用基础命令一
    MySQL查询(下)
    mysql的增删改查(列子)
    python-面向对象的一些简单操作
    PHP版本新特新历史
    日志文件分析常用总结
  • 原文地址:https://www.cnblogs.com/acm-jing/p/4403476.html
Copyright © 2011-2022 走看看