Showing the changes to interface/src/VoxelSystem.cpp (1 of 1 file). Show all
Unified · Split
| @@ -47,8 +47,8 @@ void VoxelSystem::parseData(void *data, int size) { · 46 unmodified lines | ||
| 47 | 47 | // ignore the first char, it's a V to tell us that this is voxel data |
| 48 | 48 | char *voxelDataPtr = (char *) data + 1; |
| 49 | 49 | |
| 50 | − float *position = new float[3]; | |
| 51 | − char *color = new char[3]; | |
| 50 | + GLfloat *position = new GLfloat[3]; | |
| 51 | + GLubyte *color = new GLubyte[3]; | |
| 52 | 52 | |
| 53 | 53 | // get pointers to position of last append of data |
| 54 | 54 | GLfloat *parseVerticesPtr = lastAddPointer; |
| @@ -75,6 +75,7 @@ void VoxelSystem::parseData(void *data, int size) { · 20 unmodified lines | ||
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | parseColorsPtr += COLOR_VALUES_PER_VOXEL; |
| 78 | + | |
| 78 | 79 | |
| 79 | 80 | voxelsInData++; |
| 80 | 81 | } |
| @@ -139,7 +140,7 @@ void VoxelSystem::render() { · 58 unmodified lines | ||
| 139 | 140 | |
| 140 | 141 | // bind the vertices VBO, copy in new data |
| 141 | 142 | glBindBuffer(GL_ARRAY_BUFFER, vboVerticesID); |
| 142 | − glBufferSubData(GL_ARRAY_BUFFER, vertexBufferOffset * sizeof(float), vertexValuesToDraw * sizeof(float), lastDrawPointer); | |
| 143 | + glBufferSubData(GL_ARRAY_BUFFER, vertexBufferOffset * sizeof(GLfloat), vertexValuesToDraw * sizeof(GLfloat), lastDrawPointer); | |
| 143 | 144 | |
| 144 | 145 | // bind the colors VBO, copy in new data |
| 145 | 146 | glBindBuffer(GL_ARRAY_BUFFER, vboColorsID); |
| @@ -158,9 +159,9 @@ void VoxelSystem::render() { · 12 unmodified lines | ||
| 158 | 159 | |
| 159 | 160 | glBindBuffer(GL_ARRAY_BUFFER, vboColorsID); |
| 160 | 161 | glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0); |
| 161 | − | |
| 162 | − glNormal3f(0, 1, 0); | |
| 163 | − | |
| 162 | + | |
| 163 | + // draw the number of voxels we have | |
| 164 | + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIndicesID); | |
| 164 | 165 | glDrawElements(GL_TRIANGLES, 36 * voxelsRendered, GL_UNSIGNED_INT, 0); |
| 165 | 166 | |
| 166 | 167 | // deactivate vertex and color arrays after drawing |