Added toggle for voxel textures; they may be slowing some machines down.

This commit is contained in:
Andrzej Kapolka 2013-05-20 12:13:23 -07:00
parent 2697453df4
commit 3f0fd2f976
4 changed files with 16 additions and 9 deletions

View file

@ -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

View file

@ -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

View file

@ -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);

View file

@ -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;};