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
20TextureCache::TextureCache() :20TextureCache::TextureCache() :
21 _permutationNormalTextureID(0),21 _permutationNormalTextureID(0),
22 _whiteTextureID(0),22 _whiteTextureID(0),
23 _blueTextureID(0),
23 _primaryFramebufferObject(NULL),24 _primaryFramebufferObject(NULL),
24 _secondaryFramebufferObject(NULL),25 _secondaryFramebufferObject(NULL),
25 _tertiaryFramebufferObject(NULL)26 _tertiaryFramebufferObject(NULL)
@@ -74,9 +75,11 @@ GLuint TextureCache::getPermutationNormalTextureID() { · 48 unmodified lines
74 return _permutationNormalTextureID;75 return _permutationNormalTextureID;
75}76}
76 77
77static void loadWhiteTexture() {78const char OPAQUE_WHITE[] = { 0xFF, 0xFF, 0xFF, 0xFF };
78 const char OPAQUE_WHITE[] = { 0xFF, 0xFF, 0xFF, 0xFF };79const char OPAQUE_BLUE[] = { 0x80, 0x80, 0xFF, 0xFF };
79 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, OPAQUE_WHITE);80
81static void loadSingleColorTexture(const char* color) {
82 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, color);
80 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);83 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
81}84}
82 85
@@ -84,12 +87,22 @@ GLuint TextureCache::getWhiteTextureID() { · 1 unmodified line
84 if (_whiteTextureID == 0) {87 if (_whiteTextureID == 0) {
85 glGenTextures(1, &_whiteTextureID);88 glGenTextures(1, &_whiteTextureID);
86 glBindTexture(GL_TEXTURE_2D, _whiteTextureID);89 glBindTexture(GL_TEXTURE_2D, _whiteTextureID);
87 loadWhiteTexture();90 loadSingleColorTexture(OPAQUE_WHITE);
88 glBindTexture(GL_TEXTURE_2D, 0);91 glBindTexture(GL_TEXTURE_2D, 0);
89 }92 }
90 return _whiteTextureID;93 return _whiteTextureID;
91}94}
92 95
96GLuint 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
93GLuint TextureCache::getFileTextureID(const QString& filename) {106GLuint TextureCache::getFileTextureID(const QString& filename) {
94 GLuint id = _fileTextureIDs.value(filename);107 GLuint id = _fileTextureIDs.value(filename);
95 if (id == 0) {108 if (id == 0) {
@@ -219,7 +232,7 @@ NetworkTexture::NetworkTexture(const QUrl& url) : _reply(NULL), _averageColor(1. · 123 unmodified lines
219 232
220 // default to white233 // default to white
221 glBindTexture(GL_TEXTURE_2D, getID());234 glBindTexture(GL_TEXTURE_2D, getID());
222 loadWhiteTexture();235 loadSingleColorTexture(OPAQUE_WHITE);
223 glBindTexture(GL_TEXTURE_2D, 0);236 glBindTexture(GL_TEXTURE_2D, 0);
224}237}
225 238

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