Benz奔驰商标 源代码

来源:互联网 发布:js获取div的name 编辑:程序博客网 时间:2024/04/27 14:46
#include<windows.h>
#include<math.h>
#include <gl/Glut.h>
#include <iostream>

using namespace std;

struct GLPoint{
    GLdouble x, y;
};

GLPoint pt[6];

void myDisplay(void);
void myInit(void);
void setWindow(GLdouble left, GLdouble right, GLdouble botton, GLdouble top);
void drawCircle(GLint size, GLint angle);

const GLint screenWidth = 640;
const GLint screenHeight = 640;
const GLdouble PI = 3.1415926;
static GLint size = 300;

int main(int argc, char ** argv){
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
    glutInitWindowSize(screenWidth,screenHeight);
    glutInitWindowPosition(100,100);
    glutCreateWindow("benz");

    glutDisplayFunc(myDisplay);
    myInit();
    glutMainLoop();

    return 0;
}

void setWindow(GLdouble left, GLdouble right, GLdouble botton, GLdouble top){
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(left,right,botton,top);
}


void myDisplay(void){
    glClear(GL_COLOR_BUFFER_BIT);
    setWindow(0.0,(GLdouble)screenWidth,0.0,(GLdouble)screenHeight);

    drawCircle(size, 360);
    drawCircle(size+10,360);
}

void drawCircle(GLint size,GLint angle){
    glBegin(GL_LINE_LOOP);
    for(GLdouble i= 0;i< (GLdouble)PI*( angle/180.0 );i=i+0.01){
        glVertex2d(size*sin(i)+320,size*cos(i)+320);
    }
    glEnd();


    size  -= 10;
    for (int i = 0; i< 3; ++i)
    {
        pt[i].x = size*sin((GLdouble)PI*i*120/180.0)+320;
        pt[i].y = size*cos((GLdouble)PI*i*120/180.0)+320;
    }
    for(int j = 3; j<6; j++){
        pt[j].x = 20* sin((GLdouble)PI*((j-3)*120+60)/180.0)+320;
        pt[j].y = 20* cos((GLdouble)PI*((j-3)*120+60)/180.0)+320;
    }

    glBegin(GL_LINE_LOOP);
        glVertex2d(pt[0].x,pt[0].y);
        glVertex2d(pt[3].x,pt[3].y);
        glVertex2d(pt[1].x,pt[1].y);
        glVertex2d(pt[4].x,pt[4].y);
        glVertex2d(pt[2].x,pt[2].y);
        glVertex2d(pt[5].x,pt[5].y);
    glEnd();

    glFlush();
}

void myInit(void){
    glClearColor(1.0,1.0,1.0,0.0);
    glColor3f(0.0f, 0.0f, 0.0f);        
    glLineWidth(2.0);
    glPointSize(1.0);
    

}




原创粉丝点击