Friday, May 9, 2014

Simple line drawing in OpenGl



#include <GL/glut.h>         

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT); 
glColor3f(1.0,1.0,0.0);
glBegin(GL_LINES);
glVertex2f(0.5, -0.5);
glVertex2f(-0.5, 0.5);
glEnd();
glFlush(); 
}
void init(){
glClearColor(0.0,0.5,0.2,0.8);
}

int main(int argc, char** argv)
{
glutCreateWindow("simple line"); 
glutDisplayFunc(display);
init();
glutMainLoop();

}