29{
30
33
34
36 vertex_count= mesh.vertex_count();
37
38
40 mesh.bounds(pmin, pmax);
41 camera.lookat(pmin, pmax);
42
43
44
45
46
47
48
49 glGenBuffers(1, &vertex_buffer);
50
51 glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
52
53
54 glBufferData(GL_ARRAY_BUFFER,
55 mesh.vertex_buffer_size(),
56 mesh.vertex_buffer(),
57 GL_STATIC_DRAW);
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73 glGenVertexArrays(1, &vao);
74
75 glBindVertexArray(vao);
76
77
78 GLint attribute= glGetAttribLocation(program, "position");
79 if(attribute < 0)
80
81 return -1;
82
83
84
85 glVertexAttribPointer(attribute, 3, GL_FLOAT,
86 GL_FALSE,
87 0,
88 0);
89
90 glEnableVertexAttribArray(attribute);
91
92
93
94
95
96
97
98 glBindVertexArray(0);
99 glBindBuffer(GL_ARRAY_BUFFER, 0);
100
101
102 glClearColor(0.2f, 0.2f, 0.2f, 1);
103 glClearDepthf(1);
104
105
106 glDepthFunc(GL_LESS);
107 glEnable(GL_DEPTH_TEST);
108
109 glFrontFace(GL_CCW);
110 glCullFace(GL_BACK);
111 glEnable(GL_CULL_FACE);
112 return 0;
113}
representation d'un objet / maillage.
Mesh read_mesh(const char *filename)
charge un fichier wavefront .obj et renvoie un mesh compose de triangles non indexes....
GLuint read_program(const char *filename, const char *definitions)
int program_print_errors(const GLuint program, const char *filename)
affiche les erreurs de compilation.
representation d'un point 3d.