History

add a missing glBindBuffer that caused client to crash on voxel drawing

Stephen Birarda committed 13 years ago

Commit 012b4a91 parent c68304d1 file · +7 −6Browse files

Showing the changes to interface/src/VoxelSystem.cpp (1 of 1 file). Show all

Unified · Split

interface/src/VoxelSystem.cpp+7−6
@@ -47,8 +47,8 @@ void VoxelSystem::parseData(void *data, int size) { · 46 unmodified lines
4747 // ignore the first char, it's a V to tell us that this is voxel data
4848 char *voxelDataPtr = (char *) data + 1;
4949
50− float *position = new float[3];
51− char *color = new char[3];
50+ GLfloat *position = new GLfloat[3];
51+ GLubyte *color = new GLubyte[3];
5252
5353 // get pointers to position of last append of data
5454 GLfloat *parseVerticesPtr = lastAddPointer;
@@ -75,6 +75,7 @@ void VoxelSystem::parseData(void *data, int size) { · 20 unmodified lines
7575 }
7676
7777 parseColorsPtr += COLOR_VALUES_PER_VOXEL;
78+
7879
7980 voxelsInData++;
8081 }
@@ -139,7 +140,7 @@ void VoxelSystem::render() { · 58 unmodified lines
139140
140141 // bind the vertices VBO, copy in new data
141142 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);
143144
144145 // bind the colors VBO, copy in new data
145146 glBindBuffer(GL_ARRAY_BUFFER, vboColorsID);
@@ -158,9 +159,9 @@ void VoxelSystem::render() { · 12 unmodified lines
158159
159160 glBindBuffer(GL_ARRAY_BUFFER, vboColorsID);
160161 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);
164165 glDrawElements(GL_TRIANGLES, 36 * voxelsRendered, GL_UNSIGNED_INT, 0);
165166
166167 // deactivate vertex and color arrays after drawing