History

Working on support for a textured face mode that doesn't rely on the video stream.

Andrzej Kapolka committed 13 years ago

Commit 720ae561 parent e5de6719 files · +390 −184Browse files

Showing the changes to interface/src/VoxelSystem.cpp (1 of 9 files). Show all

Unified · Split

interface/src/VoxelSystem.cpp+3−26
@@ -17,8 +17,6 @@ · 16 unmodified lines
1717 #include <fstream> // to load voxels from file
1818 #include <pthread.h>
1919
20−#include <glm/gtc/random.hpp>
21−
2220 #include <OctalCode.h>
2321 #include <PacketHeaders.h>
2422 #include <PerfStat.h>
@@ -493,7 +491,6 @@ glm::vec3 VoxelSystem::computeVoxelVertex(const glm::vec3& startVertex, float vo · 468 unmodified lines
493491 }
494492
495493 ProgramObject* VoxelSystem::_perlinModulateProgram = 0;
496−GLuint VoxelSystem::_permutationNormalTextureID = 0;
497494
498495 void VoxelSystem::init() {
499496
@@ -585,29 +582,9 @@ void VoxelSystem::init() { · 85 unmodified lines
585582 _perlinModulateProgram->addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/perlin_modulate.frag");
586583 _perlinModulateProgram->link();
587584
585+ _perlinModulateProgram->bind();
588586 _perlinModulateProgram->setUniformValue("permutationNormalTexture", 0);
589−
590− // create the permutation/normal texture
591− glGenTextures(1, &_permutationNormalTextureID);
592− glBindTexture(GL_TEXTURE_2D, _permutationNormalTextureID);
593−
594− // the first line consists of random permutation offsets
595− unsigned char data[256 * 2 * 3];
596− for (int i = 0; i < 256 * 3; i++) {
597− data[i] = rand() % 256;
598− }
599− // the next, random unit normals
600− for (int i = 256 * 3; i < 256 * 3 * 2; i += 3) {
601− glm::vec3 randvec = glm::sphericalRand(1.0f);
602− data[i] = ((randvec.x + 1.0f) / 2.0f) * 255.0f;
603− data[i + 1] = ((randvec.y + 1.0f) / 2.0f) * 255.0f;
604− data[i + 2] = ((randvec.z + 1.0f) / 2.0f) * 255.0f;
605− }
606− glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
607− glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
608− glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
609−
610− glBindTexture(GL_TEXTURE_2D, 0);
587+ _perlinModulateProgram->release();
611588 }
612589
613590 void VoxelSystem::updateFullVBOs() {
@@ -734,7 +711,7 @@ void VoxelSystem::applyScaleAndBindProgram(bool texture) { · 120 unmodified lines
734711
735712 if (texture) {
736713 _perlinModulateProgram->bind();
737− glBindTexture(GL_TEXTURE_2D, _permutationNormalTextureID);
714+ glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPermutationNormalTextureID());
738715 }
739716 }
740717