History

Normal map support almost there.

Andrzej Kapolka committed 13 years ago

Commit 06e050f1 parent 2931e2e13 files · +308 −54Browse files

Showing the changes to interface/src/renderer/TextureCache.cpp (1 of 13 files). Show all

Unified · Split

interface/src/renderer/TextureCache.cpp+18−5
@@ -20,6 +20,7 @@ · 19 unmodified lines
2020 TextureCache::TextureCache() :
2121 _permutationNormalTextureID(0),
2222 _whiteTextureID(0),
23+ _blueTextureID(0),
2324 _primaryFramebufferObject(NULL),
2425 _secondaryFramebufferObject(NULL),
2526 _tertiaryFramebufferObject(NULL)
@@ -74,9 +75,11 @@ GLuint TextureCache::getPermutationNormalTextureID() { · 48 unmodified lines
7475 return _permutationNormalTextureID;
7576 }
7677
77−static void loadWhiteTexture() {
78− const char OPAQUE_WHITE[] = { 0xFF, 0xFF, 0xFF, 0xFF };
79− glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, OPAQUE_WHITE);
78+const char OPAQUE_WHITE[] = { 0xFF, 0xFF, 0xFF, 0xFF };
79+const char OPAQUE_BLUE[] = { 0x80, 0x80, 0xFF, 0xFF };
80+
81+static void loadSingleColorTexture(const char* color) {
82+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, color);
8083 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
8184 }
8285
@@ -84,12 +87,22 @@ GLuint TextureCache::getWhiteTextureID() { · 1 unmodified line
8487 if (_whiteTextureID == 0) {
8588 glGenTextures(1, &_whiteTextureID);
8689 glBindTexture(GL_TEXTURE_2D, _whiteTextureID);
87− loadWhiteTexture();
90+ loadSingleColorTexture(OPAQUE_WHITE);
8891 glBindTexture(GL_TEXTURE_2D, 0);
8992 }
9093 return _whiteTextureID;
9194 }
9295
96+GLuint TextureCache::getBlueTextureID() {
97+ if (_blueTextureID == 0) {
98+ glGenTextures(1, &_blueTextureID);
99+ glBindTexture(GL_TEXTURE_2D, _blueTextureID);
100+ loadSingleColorTexture(OPAQUE_BLUE);
101+ glBindTexture(GL_TEXTURE_2D, 0);
102+ }
103+ return _blueTextureID;
104+}
105+
93106 GLuint TextureCache::getFileTextureID(const QString& filename) {
94107 GLuint id = _fileTextureIDs.value(filename);
95108 if (id == 0) {
@@ -219,7 +232,7 @@ NetworkTexture::NetworkTexture(const QUrl& url) : _reply(NULL), _averageColor(1. · 123 unmodified lines
219232
220233 // default to white
221234 glBindTexture(GL_TEXTURE_2D, getID());
222− loadWhiteTexture();
235+ loadSingleColorTexture(OPAQUE_WHITE);
223236 glBindTexture(GL_TEXTURE_2D, 0);
224237 }
225238

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t