zoukankan      html  css  js  c++  java
  • outdated: 1.1LineSegment

     1 #include <windows.h>
     2 #include <gl/glew.h>
     3 #include <gl/glut.h>
     4 #include <cstdio>
     5 #include <cstdlib>
     6 #include <cmath>
     7 
     8 void Init(void)
     9 {
    10     glClearColor(1.0, 1.0, 1.0, 0.0);  // Set display-window color to white
    11     // Drawing two-dimensional graphics is a special case of rendering 3D graphics 
    12     // The two dimensional matrix of the world coordinate system is projected onto the screen. 
    13     glMatrixMode(GL_PROJECTION);
    14     gluOrtho2D(0.0, 200.0, 0.0, 150.0);
    15 
    16 }
    17 
    18 void lineSegment(void)
    19 {
    20     // glClearColor() does not allow the display window appears on the screen
    21     // GlClear function allows assignment of the window to appear on the screen 
    22     glClear(GL_COLOR_BUFFER_BIT);    // Clear displaye window
    23     
    24     glColor3f(1.0, 0.0, 0.0);        // Display the color of the window object 
    25     glBegin(GL_LINES);               // GL_POINTS GL_LINES GL_LINE_STRIP GL_LINE_LOOP
    26     glVertex2i(180, 15);             // Specify line_segment geometry
    27     glVertex2i(10, 145);
    28     glEnd();
    29 
    30     glFlush();                       // Process all OpenGL rountines as quickly as possible
    31 }
    32 
    33 int main(int argc, char* argv[])
    34 {
    35     glutInit(&argc, argv);                 // Initialize GLUT
    36                                            // Set the cache and color model of the display window, and so on
    37     glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);   
    38     glutInitWindowPosition(50, 100);  // Display the location of the specified pixel 
    39     glutInitWindowSize(400, 300);     // Set the initial width and height of the display window
    40     glutCreateWindow("An Example OpenGL Program");      // Title
    41     
    42     Init();
    43     // LineSegment for the creation of the graph, 
    44     // passed to the function, and the graph is assigned to the display window
    45     glutDisplayFunc(lineSegment);  // Display callback function
    46     // The original display window has not yet appeared on the screen, 
    47     // glutMainLoop () will display the window and its content activation, and must be the last function 
    48     glutMainLoop();
    49     return 0;
    50 }

  • 相关阅读:
    数字图像-概述
    Python-python打包编译成pyd或者.so,保护代码。
    计算机组成原理-概述
    9大开源云管理平台(CMP)
    计算机组成原理-CPU-CPU知识科普:秒懂主频、核心、线程、缓存、架构详解
    svn git协同管理
    DEVTMPFS
    关于flash擦除的方法
    SQLServer强制保存
    360极速浏览器无法正确getHours
  • 原文地址:https://www.cnblogs.com/clairvoyant/p/5519821.html
Copyright © 2011-2022 走看看