• opengl学习记录1——矩形绘制


     1 #include <windows.h>
     2 #include <gl/GL.h>
     3 #include <gl/GLU.h>
     4 #include <glut.h>
     5 
     6 #pragma comment( lib, "glut.lib" )
     7 
     8 void display()
     9 {
    10     glClear( GL_COLOR_BUFFER_BIT );
    11 
    12     glColor3f( 1.0, 1.0, 1.0 );
    13     glBegin( GL_POLYGON );
    14         glVertex3f( 0.25, 0.25, 0.0 );
    15         glVertex3f( 0.75, 0.25, 0.0 );
    16         glVertex3f( 0.75, 0.75, 0.0 );
    17         glVertex3f( 0.25, 0.75, 0.0 );
    18     glEnd();
    19 
    20     glFlush();
    21 }
    22 
    23 void init()
    24 {
    25     glMatrixMode( GL_PROJECTION );
    26     glLoadIdentity();
    27     glOrtho( 0.0, 1.0, 0.0,  1.0, -1.0, 1.0 );
    28 }
    29 
    30 int gl001_main( int argc, char **argv )
    31 {
    32     glutInit( &argc, argv );
    33     //glutInitDisplayMode( GLUT_SINGLE | GLUT_RGB );
    34     //glutInitWindowSize( 250, 250 );
    35     //glutInitWindowPosition( 100, 100 );
    36     glutCreateWindow( "Hello " );
    37     init();
    38     glutDisplayFunc( display );
    39     glutMainLoop();
    40     return 0;
    41 }

    运行结果:

  • 相关阅读:
    Codeforces 960B(优先队列)
    “景驰科技杯”2018年华南理工大学程序设计竞赛 H-对称与反对称(逆元)
    AcWing
    POJ
    POJ
    AtCoder
    HRBUST
    CodeForces
    HYSBZ
    HDU
  • 原文地址:https://www.cnblogs.com/MiniHouse/p/3885523.html
Copyright © 2020-2023  润新知