• 用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没有智能感知,写的真累。

  • 相关阅读:
    centos 6,7 上cgroup资源限制使用举例
    redis sentinel哨兵的使用
    redis发布-订阅
    Golang cpu的使用设置--GOMAXPROCS
    Golang 端口复用测试
    Golang client绑定本地IP和端口
    Go并发控制--context的使用
    Go 并发控制--WaitGroup的使用
    go thrift报错问题--WriteStructEnd
    secureCRT上传本地文件到虚拟机
  • 原文地址:https://www.cnblogs.com/acm-jing/p/4403476.html
Copyright © 2020-2023  润新知