openGL painting lines

#include " the stdafx.h " 

#include <GL / glut.h> void the init ( void ) 
{ 
    glClearColor ( 1.0 , 1.0 , 1.0 , 1.0 );
     // transferred into white     glMatrixMode (the GL_PROJECTION);
     // set the projection parameters 
    gluOrtho2D ( 0.0 , 200.0 , 0.0 , 150.0 ); 
} // adjust the projection size void LineSegment ( void ) 
{ 
    the glClear (GL_COLOR_BUFFER_BIT); // Clear screen









    
    glColor3f ( 0.0 , 0.4 , 0.2 );
     // make green line color 
    the glBegin (GL_LINES,); 

    glVertex2i ( 180 [ , 15 );
     // determine the position of the line (endpoints) 
    glVertex2i ( 10 , 145 ); 

    glEnd (); 

    glFlush () ; 
    
} 


void main ( int argc, char ** the argv) 

{ 
    glutInit ( & argc, the argv);
     // initialization of GLUT 
    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
     // set model
    glutInitWindowPosition ( 50 , 100 );
     // screen position 
    glutInitWindowSize ( 400 , 300 );
     // screen size 
    glutCreateWindow ( " An Example the OpenGL Program " );
     // build window 
    the init ();
     // initialization programs are executed 
    glutDisplayFunc (lineSegment);
     // make the graphics appear in the window 
    glutMainLoop (); 
} // display, wait

 

Guess you like

Origin www.cnblogs.com/pqhuang/p/11268916.html