b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

opengl超级宝典第五版_opengl编程指南第八版_direct3d(2)

电脑杂谈  发布时间:2017-02-16 03:05:07  来源:网络整理

 1 #include <iostream>
 2 #include "StdAfx.h"
 3 
 4 GLuint Buffer_ID;
 5 const int BUFFER_NUMBER = 1;
 6 
 7 GLuint VAO_ID;
 8 GLuint VAO_NUMBER = 1;
 9 
10 const int VERTICES_NUMBER = 6;
11 const int vPosition = 0;
12 
13 void Initialize()
14 {
15     //---------------------准备数据-------------------------------
16     GLfloat vertices[VERTICES_NUMBER][2] = 
17     {
18         { -0.90, -0.90 },
19         {  0.85, -0.90 },
20         { -0.90,  0.85 },
21 
22         {  0.90, -0.85 },
23         {  0.90,  0.90 },
24         { -0.85,  0.90 }
25     };
26 
27     // 生成缓存对象
28     glGenBuffers(BUFFER_NUMBER, &Buffer_ID);
29 
30     // 绑定缓存对象
31     glBindBuffer(GL_ARRAY_BUFFER, Buffer_ID);
32 
33     // 填入数据
34     glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
35 
36     //-------------------设置顶点数据属性------------------------------
37     // 生成顶点数组对象
38     glGenVertexArrays(VAO_NUMBER, &VAO_ID);
39 
40     // 绑定顶点数组对象
41     glBindVertexArray(VAO_ID);
42 
43     // 设置顶点属性
44     glVertexAttribPointer(vPosition, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
45     glEnableVertexAttribArray(vPosition);
46 }
47 
48 void display()
49 {
50     glClear(GL_COLOR_BUFFER_BIT);
51 
52     glBindVertexArray(VAO_ID);
53     glDrawArrays(GL_TRIANGLES, 0, VERTICES_NUMBER);
54 
55     glFlush();
56 }
57 
58 int main(int argc, char **argv)
59 {
60     glutInit(&argc, argv);
61     glutInitDisplayMode(GLUT_RGBA);
62     glutInitWindowSize(512, 512);
63     glutInitContextVersion(3, 3);
64     glutInitContextProfile(GLUT_CORE_PROFILE);
65     glutCreateWindow(argv[0]);
66 
67     glewExperimental = TRUE;
68     if (glewInit())
69     {
70           std::cerr << "Unable to initialize GLEW... Exiting..." << std::endl;
71         std::exit(EXIT_FAILURE);
72     }
73 
74     Initialize();
75     glutDisplayFunc(display);
76     glutMainLoop();
77 }


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-32683-2.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...