Showing the changes to interface/src/VoxelSystem.cpp (1 of 4 files). Show all
Unified · Split
| @@ -1386,20 +1386,39 @@ void VoxelSystem::render(bool texture) { · 1385 unmodified lines | ||
| 1386 | 1386 | } |
| 1387 | 1387 | |
| 1388 | 1388 | void VoxelSystem::applyScaleAndBindProgram(bool texture) { |
| 1389 | − glPushMatrix(); | |
| 1390 | − glScalef(_treeScale, _treeScale, _treeScale); | |
| 1391 | 1389 | |
| 1392 | − if (texture) { | |
| 1390 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Shadows)) { | |
| 1391 | + glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getShadowDepthTextureID()); | |
| 1392 | + glEnable(GL_TEXTURE_GEN_S); | |
| 1393 | + glEnable(GL_TEXTURE_GEN_T); | |
| 1394 | + glEnable(GL_TEXTURE_GEN_R); | |
| 1395 | + glEnable(GL_TEXTURE_2D); | |
| 1396 | + | |
| 1397 | + glTexGenfv(GL_S, GL_EYE_PLANE, (const GLfloat*)&Application::getInstance()->getShadowMatrix()[0]); | |
| 1398 | + glTexGenfv(GL_T, GL_EYE_PLANE, (const GLfloat*)&Application::getInstance()->getShadowMatrix()[1]); | |
| 1399 | + glTexGenfv(GL_R, GL_EYE_PLANE, (const GLfloat*)&Application::getInstance()->getShadowMatrix()[2]); | |
| 1400 | + | |
| 1401 | + } else if (texture) { | |
| 1393 | 1402 | _perlinModulateProgram.bind(); |
| 1394 | 1403 | glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPermutationNormalTextureID()); |
| 1395 | 1404 | } |
| 1405 | + | |
| 1406 | + glPushMatrix(); | |
| 1407 | + glScalef(_treeScale, _treeScale, _treeScale); | |
| 1396 | 1408 | } |
| 1397 | 1409 | |
| 1398 | 1410 | void VoxelSystem::removeScaleAndReleaseProgram(bool texture) { |
| 1399 | 1411 | // scale back down to 1 so heads aren't massive |
| 1400 | 1412 | glPopMatrix(); |
| 1401 | 1413 | |
| 1402 | − if (texture) { | |
| 1414 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Shadows)) { | |
| 1415 | + glBindTexture(GL_TEXTURE_2D, 0); | |
| 1416 | + glDisable(GL_TEXTURE_GEN_S); | |
| 1417 | + glDisable(GL_TEXTURE_GEN_T); | |
| 1418 | + glDisable(GL_TEXTURE_GEN_R); | |
| 1419 | + glDisable(GL_TEXTURE_2D); | |
| 1420 | + | |
| 1421 | + } else if (texture) { | |
| 1403 | 1422 | _perlinModulateProgram.release(); |
| 1404 | 1423 | glBindTexture(GL_TEXTURE_2D, 0); |
| 1405 | 1424 | } |