Posted on 2011-07-05 14:21
kongkongzi 阅读(501)
评论(0) 编辑 收藏 引用 所属分类:
gui
#include "glut.h"
#include <math.h>
const int w = 500;
const int h = 500;
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
{
glVertex2f(0.0, 0.0);
glVertex2f(w, 0.0);
glVertex2f(w, h);
glVertex2f(0.0, h);
}
glEnd();
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_LINES);
{
glVertex2f(0.0, 0.0);
glVertex2f(w, h);
}
glEnd();
glColor3f(0.0, 1.0, 0.0);
glBegin(GL_POINTS);
{
for (float n = 4; n < w; n++)
{
glVertex2f(n, n * log(n));
glVertex2f(n, n * n);
}
}
glEnd();
glFlush();
}
void init(int w, int h)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, (GLdouble)w, 0.0, (GLdouble)h);
}
int main(int argc, char *argv[])
{
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(w, h);
glutInitWindowPosition(100, 100);
glutCreateWindow ("O(NlogN)");
init(w, h);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}