From 3f0fd2f9766bff7efc67059a23b5f4e81b8461a7 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Mon, 20 May 2013 12:13:23 -0700 Subject: [PATCH] Added toggle for voxel textures; they may be slowing some machines down. --- interface/src/Application.cpp | 4 +++- interface/src/Application.h | 1 + interface/src/VoxelSystem.cpp | 18 +++++++++++------- interface/src/VoxelSystem.h | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index f5f0970394..119fd0f509 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1204,6 +1204,8 @@ void Application::initMenu() { (_renderVoxels = renderMenu->addAction("Voxels"))->setCheckable(true); _renderVoxels->setChecked(true); _renderVoxels->setShortcut(Qt::Key_V); + (_renderVoxelTextures = renderMenu->addAction("Voxel Textures"))->setCheckable(true); + _renderVoxelTextures->setChecked(true); (_renderStarsOn = renderMenu->addAction("Stars"))->setCheckable(true); _renderStarsOn->setChecked(true); _renderStarsOn->setShortcut(Qt::Key_Asterisk); @@ -1680,7 +1682,7 @@ void Application::displaySide(Camera& whichCamera) { // Draw voxels if (_renderVoxels->isChecked()) { - _voxels.render(); + _voxels.render(_renderVoxelTextures->isChecked()); } // indicate what we'll be adding/removing in mouse mode, if anything diff --git a/interface/src/Application.h b/interface/src/Application.h index 87ea615ad8..713b50e4ef 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -134,6 +134,7 @@ private: QAction* _lookingInMirror; // Are we currently rendering one's own head as if in mirror? QAction* _gyroLook; // Whether to allow the gyro data from head to move your view QAction* _renderVoxels; // Whether to render voxels + QAction* _renderVoxelTextures; // Whether to render noise textures on voxels QAction* _renderStarsOn; // Whether to display the stars QAction* _renderAtmosphereOn; // Whether to display the atmosphere QAction* _renderAvatarsOn; // Whether to render avatars diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index d578bb3504..914d4b630a 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -617,7 +617,7 @@ void VoxelSystem::updateVBOs() { _callsToTreesToArrays = 0; // clear it } -void VoxelSystem::render() { +void VoxelSystem::render(bool texture) { PerformanceWarning warn(_renderWarningsOn, "render()"); glPushMatrix(); updateVBOs(); @@ -635,9 +635,11 @@ void VoxelSystem::render() { glBindBuffer(GL_ARRAY_BUFFER, _vboColorsID); glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0); - _perlinModulateProgram->bind(); - glBindTexture(GL_TEXTURE_2D, _permutationNormalTextureID); - + if (texture) { + _perlinModulateProgram->bind(); + glBindTexture(GL_TEXTURE_2D, _permutationNormalTextureID); + } + // for performance, disable blending and enable backface culling glDisable(GL_BLEND); glEnable(GL_CULL_FACE); @@ -650,9 +652,11 @@ void VoxelSystem::render() { glEnable(GL_BLEND); glDisable(GL_CULL_FACE); - _perlinModulateProgram->release(); - glBindTexture(GL_TEXTURE_2D, 0); - + if (texture) { + _perlinModulateProgram->release(); + glBindTexture(GL_TEXTURE_2D, 0); + } + // deactivate vertex and color arrays after drawing glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); diff --git a/interface/src/VoxelSystem.h b/interface/src/VoxelSystem.h index 2d6d9717f6..d9dd844657 100644 --- a/interface/src/VoxelSystem.h +++ b/interface/src/VoxelSystem.h @@ -36,7 +36,7 @@ public: void init(); void simulate(float deltaTime) { }; - void render(); + void render(bool texture); unsigned long getVoxelsUpdated() const {return _voxelsUpdated;}; unsigned long getVoxelsRendered() const {return _voxelsInReadArrays;};