Showing the changes to interface/src/VoxelSystem.cpp (1 of 6 files). Show all
Unified · Split
| @@ -625,10 +625,7 @@ void VoxelSystem::render(bool texture) { · 624 unmodified lines | ||
| 625 | 625 | glBindBuffer(GL_ARRAY_BUFFER, _vboColorsID); |
| 626 | 626 | glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0); |
| 627 | 627 | |
| 628 | − if (texture) { | |
| 629 | − _perlinModulateProgram->bind(); | |
| 630 | − glBindTexture(GL_TEXTURE_2D, _permutationNormalTextureID); | |
| 631 | − } | |
| 628 | + bindProgram(texture); | |
| 632 | 629 | |
| 633 | 630 | // for performance, disable blending and enable backface culling |
| 634 | 631 | glDisable(GL_BLEND); |
| @@ -643,10 +640,7 @@ void VoxelSystem::render(bool texture) { · 8 unmodified lines | ||
| 643 | 640 | glEnable(GL_BLEND); |
| 644 | 641 | glDisable(GL_CULL_FACE); |
| 645 | 642 | |
| 646 | − if (texture) { | |
| 647 | − _perlinModulateProgram->release(); | |
| 648 | − glBindTexture(GL_TEXTURE_2D, 0); | |
| 649 | − } | |
| 643 | + releaseProgram(texture); | |
| 650 | 644 | |
| 651 | 645 | // deactivate vertex and color arrays after drawing |
| 652 | 646 | glDisableClientState(GL_VERTEX_ARRAY); |
| @@ -663,6 +657,20 @@ void VoxelSystem::render(bool texture) { · 10 unmodified lines | ||
| 663 | 657 | pthread_mutex_unlock(&_bufferWriteLock); |
| 664 | 658 | } |
| 665 | 659 | |
| 660 | +void VoxelSystem::bindProgram(bool texture) { | |
| 661 | + if (texture) { | |
| 662 | + _perlinModulateProgram->bind(); | |
| 663 | + glBindTexture(GL_TEXTURE_2D, _permutationNormalTextureID); | |
| 664 | + } | |
| 665 | +} | |
| 666 | + | |
| 667 | +void VoxelSystem::releaseProgram(bool texture) { | |
| 668 | + if (texture) { | |
| 669 | + _perlinModulateProgram->release(); | |
| 670 | + glBindTexture(GL_TEXTURE_2D, 0); | |
| 671 | + } | |
| 672 | +} | |
| 673 | + | |
| 666 | 674 | int VoxelSystem::_nodeCount = 0; |
| 667 | 675 | |
| 668 | 676 | void VoxelSystem::killLocalVoxels() { |