#include <gl/glew.h>
#include <gl/glut.h>
#include <cassert>
GLfloat spin = 0.0;
void change()
{
spin += 1.0;
if (spin > 360.0)
spin -= 360.0;
glutPostRedisplay();
}
void Init()
{
glewInit();
assert(GLEW_VERSION_1_2);
glClearColor(0.0, 0.0, 0.0, 1.0);
glShadeModel(GL_SMOOTH);
glPolygonMode(GL_FRONT, GL_FILL);
glPolygonMode(GL_BACK, GL_LINE);
//glFrontFace(GL_CCW);
//glEnable(GL_CULL_FACE);
//glCullFace(GL_BACK);
glutIdleFunc(change);
}
GLboolean edgeFlag[] = {
GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE,
};
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(spin, 1.0, 1.0, 0.0);
glFrontFace(GL_CCW);
glBegin(GL_POLYGON);
glEdgeFlagv(edgeFlag);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(50.0, 50.0, -20.0);
glVertex3f(-50.0, 50.0, -20.0);
glVertex3f(-50.0, 0.0, 0.0);
glEnd();
glFrontFace(GL_CW);
glBegin(GL_POLYGON);
glEdgeFlagv(edgeFlag);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(50.0, -50.0, -20.0);
glVertex3f(-50.0, -50.0, -20.0);
glVertex3f(-50.0, 0.0, 0.0);
glEnd();
glPopMatrix();
glutSwapBuffers();
}
void reshape(int width, int height)
{
glViewport(0, 0, (GLsizei)width, (GLsizei)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-100.0, 100.0, -100.0, 100.0, -200.0, 200.0);
//gluPerspective(60.0, (double)width / height, 0.1, 550.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//gluLookAt(0.0, 0.0, 400.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowPosition(100, 100);
glutInitWindowSize(600, 600);
glutCreateWindow("");
Init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
}
The result was incorrect. Could anyone help me to change the code? Thanks.