Mercurial > hg > forks > gldragon
comparison glxdragon.cpp @ 16:c134a186912f
Cosmetics.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 05 Nov 2019 09:06:12 +0200 |
parents | 2d2aadfa3df3 |
children | 0fa9302e324d |
comparison
equal
deleted
inserted
replaced
15:2d2aadfa3df3 | 16:c134a186912f |
---|---|
37 #include <fstream> | 37 #include <fstream> |
38 #include <string> | 38 #include <string> |
39 #include <vector> | 39 #include <vector> |
40 #include <cstdio> | 40 #include <cstdio> |
41 | 41 |
42 | |
42 /* Default settings etc. constants | 43 /* Default settings etc. constants |
43 */ | 44 */ |
44 #define SET_DEF_WIDTH 1280 | 45 #define SET_DEF_WIDTH 1280 |
45 #define SET_DEF_HEIGHT 960 | 46 #define SET_DEF_HEIGHT 960 |
46 #define SET_FRAMES (180) | 47 #define SET_FRAMES (180) |
47 | 48 |
48 | 49 |
49 /* Structures | 50 /* Structures |
50 */ | 51 */ |
51 struct Mesh | 52 struct Mesh |
52 { | 53 { |
53 int nvertices, nfaces; | 54 int nvertices, nfaces; |
55 | |
54 std::vector<float> vertices; | 56 std::vector<float> vertices; |
55 std::vector<unsigned> faces; | 57 std::vector<unsigned> faces; |
56 | 58 |
57 GLuint id_prog, id_fs, id_vs; | 59 GLuint id_prog, id_fs, id_vs; |
58 }; | 60 }; |
197 { | 199 { |
198 int maxIndices; | 200 int maxIndices; |
199 | 201 |
200 glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &maxIndices); | 202 glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &maxIndices); |
201 | 203 |
202 glVertexPointer(3, GL_FLOAT, 24, &mesh.vertices[0]); | 204 glVertexPointer(3, GL_FLOAT, 3 * 4 * 2, &mesh.vertices[0]); |
203 glNormalPointer(GL_FLOAT, 24, &mesh.vertices[3]); | 205 glNormalPointer( GL_FLOAT, 3 * 4 * 2, &mesh.vertices[3]); |
204 | 206 |
205 for (int n = 0; n < mesh.nfaces; n += maxIndices) | 207 for (int n = 0; n < mesh.nfaces; n += maxIndices) |
206 { | 208 { |
207 const int count = std::min(maxIndices, int(mesh.nfaces - n)); | 209 const int count = std::min(maxIndices, mesh.nfaces - n); |
208 glDrawElements(GL_TRIANGLES, count * 3, GL_UNSIGNED_INT, &mesh.faces[n * 3]); | 210 glDrawElements(GL_TRIANGLES, count * 3, GL_UNSIGNED_INT, &mesh.faces[n * 3]); |
209 } | 211 } |
210 } | 212 } |
211 | 213 |
212 | 214 |