GLUT C++

// TestFreeGlut.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include
#include
#define M_PI 3.14159265358979323846
int day=0;
void display()
{
    ////glEnable(GL_DEPTH_TEST);
    //glClear(GL_COLOR_BUFFER_BIT/*  |  GL_DEPTH_BUFFER_BIT*/);
    //glMatrixMode(GL_PROJECTION);
    //glLoadIdentity();
    //gluPerspective(80,1, 1, 400000000);
    ////gluOrtho2D(-1000000,-1000000,1000000,1000000);
    //glMatrixMode(GL_MODELVIEW);
    //glLoadIdentity();
    //gluLookAt(0, -200000000, 200000000, 0, 0, 0, 0, 0, 1);
    //// 绘制红色的“太阳”
    //glColor3f(1.0f, 0.0f, 0.0f);
    //glutSolidSphere(69600000, 200, 200);
    //// 绘制蓝色的“地球”
    //glColor3f(0.0f, 0.0f, 1.0f);
    //glRotatef(day/360.0*360.0, 0.0f, 0.0f, -1.0f);
    //glTranslatef(150000000, 0.0f, 0.0f);
    //glutSolidSphere(15945000, 20, 20);
    //// 绘制黄色的“月亮”
    //glLoadIdentity();
    //glColor3f(1.0f, 1.0f, 0.0f);
    //glRotatef(day/30.0*360.0 - day/360.0*360.0, 0.0f, 0.0f, -1.0f);
    //glTranslatef(38000000, 0.0f, 0.0f);
    //glutSolidSphere(4345000, 20, 20);
    //glFlush();
    glClear(GL_COLOR_BUFFER_BIT);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45,1,100,200);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(100,100,100,0,0,0,0,1,0);
    glColor3f(1,0,0);
    glutSolidSphere(10,20,20);

    glColor3f(0,1,0);
    glRotatef(-90,0,1,0);
    glTranslatef(50,0,0);
    glutSolidSphere(10,20,20);

    glFlush();
}

int _tmain(int argc, _TCHAR* argv[])
{

    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);
    glutInitWindowPosition(100,100);
    glutInitWindowSize(400,400);
    glutCreateWindow("fffff");
    //glClearColor(1,1,1,0);
    glutDisplayFunc(&display);
    glutMainLoop();
    return 0;
}

你可能感兴趣的:(Code)