为什么这个程序自己不能动呢?是不是显示模式设置问题,应该如何解决,希望哪位兄弟解释哈....感激不尽啊.....
#include "StdAfx.h"
#include<windows.h>
#include<GL/glut.h>
#include<stdlib.h>
float x=-1.0;
float y=0.6;
float vx=0.01;
float vy=0.01;
void drawOneLine(float(x1),float(y1),float(x2),float(y2))
{
glColor3f(1.0,1.0,1.0);
glBegin(GL_LINES);
glVertex2f((x1),(y1));
glVertex2f((x2),(y2));
glEnd();
}
void drawtriangles(float(x1),float(y1),float(x2),float(y2),float(x3),float(y3))
{
glColor3f(0.0,1.0,0.0);
glBegin(GL_TRIANGLES);
glVertex2f(x1,y1);
glVertex2f(x2,y2);
glVertex2f(x3,y3);
glEnd();
}
void drawplane(void)
{
drawtriangles(x,y,x-0.05,y+0.04,x-0.05,y-0.04);
glColor3f(0.0,0.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(x-0.05,y+0.02);
glVertex2f(x-0.1,y+0.02);
glVertex2f(x-0.1,y-0.02);
glVertex2f(x-0.05,y-0.02);
glEnd();
}
void display(void)
{
glClearColor(0.0,0.0,0.0,0.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
drawtriangles(-0.35,-1.0,-0.4,-0.95,-0.45,-1.0);
drawtriangles(0.05,-1.0,0.0,-0.95,-0.05,-1.0);
drawtriangles(0.45,-1.0,0.4,-0.95,0.35,-1.0);
drawplane();
glEnable(GL_LINE_STIPPLE);
glLineStipple(1,0x0101);
drawOneLine(-0.2,1.0,-0.2,-1.0);
drawOneLine(-0.6,1.0,-0.6,-1.0);
drawOneLine(0.2,1.0,0.2,-1.0);
drawOneLine(0.6,1.0,0.6,-1.0);
glDisable(GL_LINE_STIPPLE);
x+=vx;
y+=0;
glFlush();
}
void main(void)
{
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(800,600);
glutInitWindowPosition(100,100);
glutCreateWindow("huangming");
glutDisplayFunc(display);
glutMainLoop();
}