Showing the changes to interface/src/VoxelSystem.cpp (1 of 5 files). Show all
Unified · Split
| @@ -85,9 +85,7 @@ VoxelSystem::VoxelSystem(float treeScale, int maxVoxels) · 84 unmodified lines | |||
| 85 | connect(_tree, SIGNAL(importProgress(int)), SIGNAL(importProgress(int))); | 85 | connect(_tree, SIGNAL(importProgress(int)), SIGNAL(importProgress(int))); |
| 86 | 86 | ||
| 87 | _useVoxelShader = false; | 87 | _useVoxelShader = false; |
| 88 | _useByteNormals = false; | 88 | |
| 89 | _useGlobalNormals = false; | ||
| 90 | |||
| 91 | _writeVoxelShaderData = NULL; | 89 | _writeVoxelShaderData = NULL; |
| 92 | _readVoxelShaderData = NULL; | 90 | _readVoxelShaderData = NULL; |
| 93 | 91 | ||
| @@ -151,42 +149,6 @@ VoxelSystem::~VoxelSystem() { · 57 unmodified lines | |||
| 151 | VoxelNode::removeDeleteHook(this); | 149 | VoxelNode::removeDeleteHook(this); |
| 152 | } | 150 | } |
| 153 | 151 | ||
| 154 | void VoxelSystem::setUseByteNormals(bool useByteNormals) { | ||
| 155 | pthread_mutex_lock(&_bufferWriteLock); | ||
| 156 | bool wasInitialized = _initialized; | ||
| 157 | if (wasInitialized) { | ||
| 158 | clearAllNodesBufferIndex(); | ||
| 159 | cleanupVoxelMemory(); | ||
| 160 | } | ||
| 161 | _useByteNormals = useByteNormals; | ||
| 162 | if (wasInitialized) { | ||
| 163 | init(); | ||
| 164 | } | ||
| 165 | pthread_mutex_unlock(&_bufferWriteLock); | ||
| 166 | |||
| 167 | if (wasInitialized) { | ||
| 168 | forceRedrawEntireTree(); | ||
| 169 | } | ||
| 170 | } | ||
| 171 | |||
| 172 | void VoxelSystem::setUseGlobalNormals(bool useGlobalNormals) { | ||
| 173 | pthread_mutex_lock(&_bufferWriteLock); | ||
| 174 | bool wasInitialized = _initialized; | ||
| 175 | if (wasInitialized) { | ||
| 176 | clearAllNodesBufferIndex(); | ||
| 177 | cleanupVoxelMemory(); | ||
| 178 | } | ||
| 179 | _useGlobalNormals = useGlobalNormals; | ||
| 180 | if (wasInitialized) { | ||
| 181 | init(); | ||
| 182 | } | ||
| 183 | pthread_mutex_unlock(&_bufferWriteLock); | ||
| 184 | |||
| 185 | if (wasInitialized) { | ||
| 186 | forceRedrawEntireTree(); | ||
| 187 | } | ||
| 188 | } | ||
| 189 | |||
| 190 | void VoxelSystem::setMaxVoxels(int maxVoxels) { | 152 | void VoxelSystem::setMaxVoxels(int maxVoxels) { |
| 191 | pthread_mutex_lock(&_bufferWriteLock); | 153 | pthread_mutex_lock(&_bufferWriteLock); |
| 192 | bool wasInitialized = _initialized; | 154 | bool wasInitialized = _initialized; |
| @@ -237,17 +199,12 @@ void VoxelSystem::cleanupVoxelMemory() { · 44 unmodified lines | |||
| 237 | glDeleteBuffers(1, &_vboVerticesID); | 199 | glDeleteBuffers(1, &_vboVerticesID); |
| 238 | glDeleteBuffers(1, &_vboColorsID); | 200 | glDeleteBuffers(1, &_vboColorsID); |
| 239 | 201 | ||
| 240 | if (!_useGlobalNormals) { | 202 | glDeleteBuffers(1, &_vboIndicesTop); |
| 241 | glDeleteBuffers(1, &_vboNormalsID); | 203 | glDeleteBuffers(1, &_vboIndicesBottom); |
| 242 | glDeleteBuffers(1, &_vboIndicesID); | 204 | glDeleteBuffers(1, &_vboIndicesLeft); |
| 243 | } else { | 205 | glDeleteBuffers(1, &_vboIndicesRight); |
| 244 | glDeleteBuffers(1, &_vboIndicesTop); | 206 | glDeleteBuffers(1, &_vboIndicesFront); |
| 245 | glDeleteBuffers(1, &_vboIndicesBottom); | 207 | glDeleteBuffers(1, &_vboIndicesBack); |
| 246 | glDeleteBuffers(1, &_vboIndicesLeft); | ||
| 247 | glDeleteBuffers(1, &_vboIndicesRight); | ||
| 248 | glDeleteBuffers(1, &_vboIndicesFront); | ||
| 249 | glDeleteBuffers(1, &_vboIndicesBack); | ||
| 250 | } | ||
| 251 | 208 | ||
| 252 | delete[] _readVerticesArray; | 209 | delete[] _readVerticesArray; |
| 253 | delete[] _writeVerticesArray; | 210 | delete[] _writeVerticesArray; |
| @@ -332,94 +289,19 @@ void VoxelSystem::initVoxelMemory() { · 78 unmodified lines | |||
| 332 | _readVoxelShaderData = new VoxelShaderVBOData[_maxVoxels]; | 289 | _readVoxelShaderData = new VoxelShaderVBOData[_maxVoxels]; |
| 333 | _memoryUsageRAM += (sizeof(VoxelShaderVBOData) * _maxVoxels); | 290 | _memoryUsageRAM += (sizeof(VoxelShaderVBOData) * _maxVoxels); |
| 334 | } else { | 291 | } else { |
| 335 | if (_useGlobalNormals) { | ||
| 336 | // Global Normals mode uses a technique of not including normals on any voxel vertices, and instead | ||
| 337 | // rendering the voxel faces in 6 passes that use a global call to glNormal3f() | ||
| 338 | qDebug("Using Global Normals...\n"); | ||
| 339 | setupFaceIndices(_vboIndicesTop, identityIndicesTop); | ||
| 340 | setupFaceIndices(_vboIndicesBottom, identityIndicesBottom); | ||
| 341 | setupFaceIndices(_vboIndicesLeft, identityIndicesLeft); | ||
| 342 | setupFaceIndices(_vboIndicesRight, identityIndicesRight); | ||
| 343 | setupFaceIndices(_vboIndicesFront, identityIndicesFront); | ||
| 344 | setupFaceIndices(_vboIndicesBack, identityIndicesBack); | ||
| 345 | } else { | ||
| 346 | if (_useByteNormals) { | ||
| 347 | qDebug("Using Byte Normals...\n"); | ||
| 348 | GLbyte* normalsArray = new GLbyte[VERTEX_POINTS_PER_VOXEL * _maxVoxels]; | ||
| 349 | GLbyte* normalsArrayEndPointer = normalsArray; | ||
| 350 | |||
| 351 | // populate the normalsArray | ||
| 352 | for (int n = 0; n < _maxVoxels; n++) { | ||
| 353 | for (int i = 0; i < VERTEX_POINTS_PER_VOXEL; i++) { | ||
| 354 | *(normalsArrayEndPointer++) = (identityNormals[i] * CHAR_MAX); | ||
| 355 | } | ||
| 356 | } | ||
| 357 | |||
| 358 | // VBO for the normalsArray | ||
| 359 | glGenBuffers(1, &_vboNormalsID); | ||
| 360 | glBindBuffer(GL_ARRAY_BUFFER, _vboNormalsID); | ||
| 361 | glBufferData(GL_ARRAY_BUFFER, | ||
| 362 | VERTEX_POINTS_PER_VOXEL * sizeof(GLbyte) * _maxVoxels, | ||
| 363 | normalsArray, GL_STATIC_DRAW); | ||
| 364 | _memoryUsageVBO += VERTEX_POINTS_PER_VOXEL * sizeof(GLbyte) * _maxVoxels; | ||
| 365 | |||
| 366 | // delete the indices and normals arrays that are no longer needed | ||
| 367 | delete[] normalsArray; | ||
| 368 | } else { | ||
| 369 | qDebug("Using Float Normals...\n"); | ||
| 370 | GLfloat* normalsArray = new GLfloat[VERTEX_POINTS_PER_VOXEL * _maxVoxels]; | ||
| 371 | GLfloat* normalsArrayEndPointer = normalsArray; | ||
| 372 | |||
| 373 | // populate the normalsArray | ||
| 374 | for (int n = 0; n < _maxVoxels; n++) { | ||
| 375 | for (int i = 0; i < VERTEX_POINTS_PER_VOXEL; i++) { | ||
| 376 | *(normalsArrayEndPointer++) = identityNormals[i]; | ||
| 377 | } | ||
| 378 | } | ||
| 379 | |||
| 380 | // VBO for the normalsArray | ||
| 381 | glGenBuffers(1, &_vboNormalsID); | ||
| 382 | glBindBuffer(GL_ARRAY_BUFFER, _vboNormalsID); | ||
| 383 | glBufferData(GL_ARRAY_BUFFER, | ||
| 384 | VERTEX_POINTS_PER_VOXEL * sizeof(GLfloat) * _maxVoxels, | ||
| 385 | normalsArray, GL_STATIC_DRAW); | ||
| 386 | _memoryUsageVBO += VERTEX_POINTS_PER_VOXEL * sizeof(GLfloat) * _maxVoxels; | ||
| 387 | |||
| 388 | // delete the indices and normals arrays that are no longer needed | ||
| 389 | delete[] normalsArray; | ||
| 390 | } | ||
| 391 | 292 | ||
| 392 | GLuint* indicesArray = new GLuint[INDICES_PER_VOXEL * _maxVoxels]; | 293 | // Global Normals mode uses a technique of not including normals on any voxel vertices, and instead |
| 393 | 294 | // rendering the voxel faces in 6 passes that use a global call to glNormal3f() | |
| 394 | // populate the indicesArray | 295 | qDebug("Using Global Normals...\n"); |
| 395 | // this will not change given new voxels, so we can set it all up now | 296 | setupFaceIndices(_vboIndicesTop, identityIndicesTop); |
| 396 | for (int n = 0; n < _maxVoxels; n++) { | 297 | setupFaceIndices(_vboIndicesBottom, identityIndicesBottom); |
| 397 | // fill the indices array | 298 | setupFaceIndices(_vboIndicesLeft, identityIndicesLeft); |
| 398 | int voxelIndexOffset = n * INDICES_PER_VOXEL; | 299 | setupFaceIndices(_vboIndicesRight, identityIndicesRight); |
| 399 | GLuint* currentIndicesPos = indicesArray + voxelIndexOffset; | 300 | setupFaceIndices(_vboIndicesFront, identityIndicesFront); |
| 400 | int startIndex = (n * VERTICES_PER_VOXEL); | 301 | setupFaceIndices(_vboIndicesBack, identityIndicesBack); |
| 401 | |||
| 402 | for (int i = 0; i < INDICES_PER_VOXEL; i++) { | ||
| 403 | // add indices for this side of the cube | ||
| 404 | currentIndicesPos[i] = startIndex + identityIndices[i]; | ||
| 405 | } | ||
| 406 | } | ||
| 407 | |||
| 408 | // VBO for the indicesArray | ||
| 409 | glGenBuffers(1, &_vboIndicesID); | ||
| 410 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesID); | ||
| 411 | glBufferData(GL_ELEMENT_ARRAY_BUFFER, | ||
| 412 | INDICES_PER_VOXEL * sizeof(GLuint) * _maxVoxels, | ||
| 413 | indicesArray, GL_STATIC_DRAW); | ||
| 414 | _memoryUsageVBO += INDICES_PER_VOXEL * sizeof(GLuint) * _maxVoxels; | ||
| 415 | |||
| 416 | // delete the indices and normals arrays that are no longer needed | ||
| 417 | delete[] indicesArray; | ||
| 418 | |||
| 419 | } | ||
| 420 | 302 | ||
| 421 | // Depending on if we're using per vertex normals, we will need more or less vertex points per voxel | 303 | // Depending on if we're using per vertex normals, we will need more or less vertex points per voxel |
| 422 | int vertexPointsPerVoxel = _useGlobalNormals ? GLOBAL_NORMALS_VERTEX_POINTS_PER_VOXEL : VERTEX_POINTS_PER_VOXEL; | 304 | int vertexPointsPerVoxel = GLOBAL_NORMALS_VERTEX_POINTS_PER_VOXEL; |
| 423 | glGenBuffers(1, &_vboVerticesID); | 305 | glGenBuffers(1, &_vboVerticesID); |
| 424 | glBindBuffer(GL_ARRAY_BUFFER, _vboVerticesID); | 306 | glBindBuffer(GL_ARRAY_BUFFER, _vboVerticesID); |
| 425 | glBufferData(GL_ARRAY_BUFFER, vertexPointsPerVoxel * sizeof(GLfloat) * _maxVoxels, NULL, GL_DYNAMIC_DRAW); | 307 | glBufferData(GL_ARRAY_BUFFER, vertexPointsPerVoxel * sizeof(GLfloat) * _maxVoxels, NULL, GL_DYNAMIC_DRAW); |
| @@ -730,7 +612,7 @@ void VoxelSystem::copyWrittenDataSegmentToReadArrays(glBufferIndex segmentStart, · 304 unmodified lines | |||
| 730 | memcpy(readDataAt, writeDataAt, segmentSizeBytes); | 612 | memcpy(readDataAt, writeDataAt, segmentSizeBytes); |
| 731 | } else { | 613 | } else { |
| 732 | // Depending on if we're using per vertex normals, we will need more or less vertex points per voxel | 614 | // Depending on if we're using per vertex normals, we will need more or less vertex points per voxel |
| 733 | int vertexPointsPerVoxel = _useGlobalNormals ? GLOBAL_NORMALS_VERTEX_POINTS_PER_VOXEL : VERTEX_POINTS_PER_VOXEL; | 615 | int vertexPointsPerVoxel = GLOBAL_NORMALS_VERTEX_POINTS_PER_VOXEL; |
| 734 | 616 | ||
| 735 | GLintptr segmentStartAt = segmentStart * vertexPointsPerVoxel * sizeof(GLfloat); | 617 | GLintptr segmentStartAt = segmentStart * vertexPointsPerVoxel * sizeof(GLfloat); |
| 736 | GLsizeiptr segmentSizeBytes = segmentLength * vertexPointsPerVoxel * sizeof(GLfloat); | 618 | GLsizeiptr segmentSizeBytes = segmentLength * vertexPointsPerVoxel * sizeof(GLfloat); |
| @@ -880,17 +762,11 @@ void VoxelSystem::updateNodeInArrays(glBufferIndex nodeIndex, const glm::vec3& s · 143 unmodified lines | |||
| 880 | } | 762 | } |
| 881 | } else { | 763 | } else { |
| 882 | if (_writeVerticesArray && _writeColorsArray) { | 764 | if (_writeVerticesArray && _writeColorsArray) { |
| 883 | int vertexPointsPerVoxel = _useGlobalNormals ? GLOBAL_NORMALS_VERTEX_POINTS_PER_VOXEL : VERTEX_POINTS_PER_VOXEL; | 765 | int vertexPointsPerVoxel = GLOBAL_NORMALS_VERTEX_POINTS_PER_VOXEL; |
| 884 | for (int j = 0; j < vertexPointsPerVoxel; j++ ) { | 766 | for (int j = 0; j < vertexPointsPerVoxel; j++ ) { |
| 885 | GLfloat* writeVerticesAt = _writeVerticesArray + (nodeIndex * vertexPointsPerVoxel); | 767 | GLfloat* writeVerticesAt = _writeVerticesArray + (nodeIndex * vertexPointsPerVoxel); |
| 886 | GLubyte* writeColorsAt = _writeColorsArray + (nodeIndex * vertexPointsPerVoxel); | 768 | GLubyte* writeColorsAt = _writeColorsArray + (nodeIndex * vertexPointsPerVoxel); |
| 887 | 769 | *(writeVerticesAt+j) = startVertex[j % 3] + (identityVerticesGlobalNormals[j] * voxelScale); | |
| 888 | if (_useGlobalNormals) { | ||
| 889 | *(writeVerticesAt+j) = startVertex[j % 3] + (identityVerticesGlobalNormals[j] * voxelScale); | ||
| 890 | } else { | ||
| 891 | *(writeVerticesAt+j) = startVertex[j % 3] + (identityVertices[j] * voxelScale); | ||
| 892 | } | ||
| 893 | |||
| 894 | *(writeColorsAt +j) = color[j % 3]; | 770 | *(writeColorsAt +j) = color[j % 3]; |
| 895 | } | 771 | } |
| 896 | } | 772 | } |
| @@ -1002,7 +878,7 @@ void VoxelSystem::updateVBOSegment(glBufferIndex segmentStart, glBufferIndex seg · 105 unmodified lines | |||
| 1002 | glBindBuffer(GL_ARRAY_BUFFER, _vboVoxelsID); | 878 | glBindBuffer(GL_ARRAY_BUFFER, _vboVoxelsID); |
| 1003 | glBufferSubData(GL_ARRAY_BUFFER, segmentStartAt, segmentSizeBytes, readVerticesFrom); | 879 | glBufferSubData(GL_ARRAY_BUFFER, segmentStartAt, segmentSizeBytes, readVerticesFrom); |
| 1004 | } else { | 880 | } else { |
| 1005 | int vertexPointsPerVoxel = _useGlobalNormals ? GLOBAL_NORMALS_VERTEX_POINTS_PER_VOXEL : VERTEX_POINTS_PER_VOXEL; | 881 | int vertexPointsPerVoxel = GLOBAL_NORMALS_VERTEX_POINTS_PER_VOXEL; |
| 1006 | int segmentLength = (segmentEnd - segmentStart) + 1; | 882 | int segmentLength = (segmentEnd - segmentStart) + 1; |
| 1007 | GLintptr segmentStartAt = segmentStart * vertexPointsPerVoxel * sizeof(GLfloat); | 883 | GLintptr segmentStartAt = segmentStart * vertexPointsPerVoxel * sizeof(GLfloat); |
| 1008 | GLsizeiptr segmentSizeBytes = segmentLength * vertexPointsPerVoxel * sizeof(GLfloat); | 884 | GLsizeiptr segmentSizeBytes = segmentLength * vertexPointsPerVoxel * sizeof(GLfloat); |
| @@ -1065,57 +941,42 @@ void VoxelSystem::render(bool texture) { · 56 unmodified lines | |||
| 1065 | glBindBuffer(GL_ARRAY_BUFFER, _vboColorsID); | 941 | glBindBuffer(GL_ARRAY_BUFFER, _vboColorsID); |
| 1066 | glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0); | 942 | glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0); |
| 1067 | 943 | ||
| 1068 | if (!_useGlobalNormals) { | ||
| 1069 | glEnableClientState(GL_NORMAL_ARRAY); | ||
| 1070 | glBindBuffer(GL_ARRAY_BUFFER, _vboNormalsID); | ||
| 1071 | glNormalPointer((_useByteNormals ? GL_BYTE : GL_FLOAT), 0, 0); | ||
| 1072 | } else { | ||
| 1073 | glNormal3f(0,1.0f,0); // hack for now | ||
| 1074 | } | ||
| 1075 | |||
| 1076 | applyScaleAndBindProgram(texture); | 944 | applyScaleAndBindProgram(texture); |
| 1077 | 945 | ||
| 1078 | // for performance, enable backface culling | 946 | // for performance, enable backface culling |
| 1079 | glEnable(GL_CULL_FACE); | 947 | glEnable(GL_CULL_FACE); |
| 1080 | 948 | ||
| 1081 | if (!_useGlobalNormals) { | 949 | // draw voxels in 6 passes |
| 1082 | // draw the number of voxels we have | 950 | |
| 1083 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesID); | 951 | glNormal3f(0,1.0f,0); |
| 1084 | glDrawRangeElementsEXT(GL_TRIANGLES, 0, VERTICES_PER_VOXEL * _voxelsInReadArrays - 1, | 952 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesTop); |
| 1085 | 36 * _voxelsInReadArrays, GL_UNSIGNED_INT, 0); | 953 | glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1, |
| 1086 | } else { | 954 | INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0); |
| 1087 | // draw voxels in 6 passes | 955 | |
| 1088 | 956 | glNormal3f(0,-1.0f,0); | |
| 1089 | glNormal3f(0,1.0f,0); | 957 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesBottom); |
| 1090 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesTop); | 958 | glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1, |
| 1091 | glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1, | 959 | INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0); |
| 1092 | INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0); | 960 | |
| 1093 | 961 | glNormal3f(-1.0f,0,0); | |
| 1094 | glNormal3f(0,-1.0f,0); | 962 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesLeft); |
| 1095 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesBottom); | 963 | glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1, |
| 1096 | glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1, | 964 | INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0); |
| 1097 | INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0); | 965 | |
| 1098 | 966 | glNormal3f(1.0f,0,0); | |
| 1099 | glNormal3f(-1.0f,0,0); | 967 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesRight); |
| 1100 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesLeft); | 968 | glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1, |
| 1101 | glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1, | 969 | INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0); |
| 1102 | INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0); | 970 | |
| 1103 | 971 | glNormal3f(0,0,-1.0f); | |
| 1104 | glNormal3f(1.0f,0,0); | 972 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesFront); |
| 1105 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesRight); | 973 | glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1, |
| 1106 | glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1, | 974 | INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0); |
| 1107 | INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0); | 975 | |
| 1108 | 976 | glNormal3f(0,0,1.0f); | |
| 1109 | glNormal3f(0,0,-1.0f); | 977 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesBack); |
| 1110 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesFront); | 978 | glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1, |
| 1111 | glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1, | 979 | INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0); |
| 1112 | INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0); | ||
| 1113 | |||
| 1114 | glNormal3f(0,0,1.0f); | ||
| 1115 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesBack); | ||
| 1116 | glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1, | ||
| 1117 | INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0); | ||
| 1118 | } | ||
| 1119 | 980 | ||
| 1120 | 981 | ||
| 1121 | glDisable(GL_CULL_FACE); | 982 | glDisable(GL_CULL_FACE); |
| @@ -1126,10 +987,6 @@ void VoxelSystem::render(bool texture) { · 4 unmodified lines | |||
| 1126 | glDisableClientState(GL_VERTEX_ARRAY); | 987 | glDisableClientState(GL_VERTEX_ARRAY); |
| 1127 | glDisableClientState(GL_COLOR_ARRAY); | 988 | glDisableClientState(GL_COLOR_ARRAY); |
| 1128 | 989 | ||
| 1129 | if (!_useGlobalNormals) { | ||
| 1130 | glDisableClientState(GL_NORMAL_ARRAY); | ||
| 1131 | } | ||
| 1132 | |||
| 1133 | // bind with 0 to switch back to normal operation | 990 | // bind with 0 to switch back to normal operation |
| 1134 | glBindBuffer(GL_ARRAY_BUFFER, 0); | 991 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 1135 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); | 992 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |