写了个dome,执行结果只显示窗口,但是窗口内什么都没有,有没有哪位知道这是为什么?
#include<GL/glut.h>
#include<GL/glu.h>
#include<GL/gl.h>
#define GLfloat float
void myinit()
{
glClearColor(0.0, 0.5, 0.5, 1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,50.0,0.0,50.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(25.0, 0.0, 50.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 0.0, 0.0);
GLfloat vertices[3][2]={{0.0, 0.0 }, {25.0, 50.0 }, {50.0, 0.0 }};
GLfloat p[2]={7.50, 5.0 };
int j,k;
glBegin(GL_POINTS);
for(k=0;k<500;k++)
{
j=k%3;
p[0]=(p[0]+vertices[j][0])/2;
p[1]=(p[1]+vertices[j][1])/2;
glVertex2fv(p);
}
glEnd();
glFlush();
}
void main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(500, 500);
glutInitWindowPosition(0, 0);
glutCreateWindow("实验一");
myinit();
glutDisplayFunc(display);
glutMainLoop();
}
#include<GL/glut.h>
//#include<GL/glu.h>
//#include<GL/gl.h>
#include <stdlib.h>
//#define GLfloat float
void myinit()
{
glClearColor(1.0, 1.0, 1.0, 1.0);
glColor3f(1.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,50.0,0.0,50.0);
glMatrixMode(GL_MODELVIEW);
//glLoadIdentity();
//gluLookAt(25.0, 0.0, 50.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
}
void display()
{
// glColor3f(0.0, 0.0, 1.0);
GLfloat vertices[3][2]={{0.0, 0.0 }, {25.0, 50.0 }, {50.0, 0.0 }};
int i,j,k;
//int rand();
GLfloat p[2]={7.50, 5.0 };
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POINTS);
// glVertex2fv(p);
// glColor3f(0.0,1.0,0.0);
for(k=0;k<5000;k++)
{
j=rand()%3;
// j=k%3;
p[0]=(p[0]+vertices[j][0])/2.0;
p[1]=(p[1]+vertices[j][1])/2.0;
// p[2]=(p[2]+vertices[j][2])/2;
glVertex2fv(p);
}
glEnd();
glFlush();
}
void main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500, 500);
glutInitWindowPosition(0, 0);
glutCreateWindow("实验一");
glutDisplayFunc(display);
myinit();
glutMainLoop(); //进入事件循环
}