问题描述
- 程序能编译正确连接,但是不能把旋转的正方形画出来
-
#include "stdafx.h"
#include
#include
#define DEG_TO_RAD 0.017453
GLfloat theta = 0.0;
void mydisplay()
{
glClearColor(0.0, 0.0, 1.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glColor3f(1.0, 0.0, 0.0);
glVertex2f(sin(DEG_TO_RAD*theta), cos(DEG_TO_RAD*theta));
glVertex2f(-sin(DEG_TO_RAD*theta), cos(DEG_TO_RAD*theta));
glVertex2f(-sin(DEG_TO_RAD*theta), -cos(DEG_TO_RAD*theta));
glVertex2f(sin(DEG_TO_RAD*theta), -cos(DEG_TO_RAD*theta));
glEnd();
glFlush();
}
void myidle()
{
glutPostRedisplay();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(100, 100);
glutInitWindowSize(450, 400);
glutCreateWindow("sample");
glutDisplayFunc(mydisplay);
glutIdleFunc(myidle);
glutMainLoop();
return 0;
}
这是我根据书上写的一个程序,功能说能画一个旋转的正方形,但是我在vs上运行时什么都没有,求大家帮忙解决一下哈。。
时间: 2024-09-17 03:16:02