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
47 // ignore the first char, it's a V to tell us that this is voxel data47 // ignore the first char, it's a V to tell us that this is voxel data
48 char *voxelDataPtr = (char *) data + 1;48 char *voxelDataPtr = (char *) data + 1;
49 49
50 float *position = new float[3];50 GLfloat *position = new GLfloat[3];
51 char *color = new char[3];51 GLubyte *color = new GLubyte[3];
52 52
53 // get pointers to position of last append of data53 // get pointers to position of last append of data
54 GLfloat *parseVerticesPtr = lastAddPointer;54 GLfloat *parseVerticesPtr = lastAddPointer;
@@ -75,6 +75,7 @@ void VoxelSystem::parseData(void *data, int size) { · 20 unmodified lines
75 }75 }
76 76
77 parseColorsPtr += COLOR_VALUES_PER_VOXEL;77 parseColorsPtr += COLOR_VALUES_PER_VOXEL;
78
78 79
79 voxelsInData++;80 voxelsInData++;
80 }81 }
@@ -139,7 +140,7 @@ void VoxelSystem::render() { · 58 unmodified lines
139 140
140 // bind the vertices VBO, copy in new data141 // bind the vertices VBO, copy in new data
141 glBindBuffer(GL_ARRAY_BUFFER, vboVerticesID);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 // bind the colors VBO, copy in new data145 // bind the colors VBO, copy in new data
145 glBindBuffer(GL_ARRAY_BUFFER, vboColorsID);146 glBindBuffer(GL_ARRAY_BUFFER, vboColorsID);
@@ -158,9 +159,9 @@ void VoxelSystem::render() { · 12 unmodified lines
158 159
159 glBindBuffer(GL_ARRAY_BUFFER, vboColorsID);160 glBindBuffer(GL_ARRAY_BUFFER, vboColorsID);
160 glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0);161 glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0);
161 162
162 glNormal3f(0, 1, 0);163 // draw the number of voxels we have
163 164 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIndicesID);
164 glDrawElements(GL_TRIANGLES, 36 * voxelsRendered, GL_UNSIGNED_INT, 0);165 glDrawElements(GL_TRIANGLES, 36 * voxelsRendered, GL_UNSIGNED_INT, 0);
165 166
166 // deactivate vertex and color arrays after drawing167 // deactivate vertex and color arrays after drawing