//
// main.cpp
// OpenGL-final
//
// Created by John&cat on 2020/4/27.
// Copyright © 2020 John&cat. All rights reserved.
// 旋转的车
#define GL_SILENCE_DEPRECATION
#include <stdio.h>
#include "iostream"
#include <GLUT/GLUT.h>
#include <math.h>
static GLfloat xRot = 0.0f;
static GLfloat yRot = 0.0f;
void Display(void)
{ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(xRot, 1.0f, 0.0f, 0.0f); //绕x轴旋转
glRotatef(yRot, 0.0f, 1.0f, 0.0f); //绕y轴旋转
//车下半部
glBegin(GL_POLYGON);
glColor3f(0.1, 0.1, 0.8);
glVertex3f(-40.0f,0.0f,15.0f);
glVertex3f(40.0f,0.0f,15.0f);
glColor3f(1, 0.5, 0.8);
glVertex3f(40.0f,-15.0f,15.0f);
glVertex3f(-40.0f,-15.0f,15.0f);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.3, 0.2, 0.5);
glVertex3f(40.0f,0.0f,-15.0f);
glVertex3f(40.0f,0.0f,15.0f);
glVertex3f(40.0f,-15.0f,15.0f);