Showing the changes to interface/src/renderer/TextureCache.cpp (1 of 4 files). Show all
Unified · Split
| @@ -64,12 +64,11 @@ GLuint TextureCache::getPermutationNormalTextureID() { · 63 unmodified lines | ||
| 64 | 64 | |
| 65 | 65 | QOpenGLFramebufferObject* TextureCache::getPrimaryFramebufferObject() { |
| 66 | 66 | if (_primaryFramebufferObject == NULL) { |
| 67 | − QSize size = Application::getInstance()->getGLWidget()->size(); | |
| 68 | − _primaryFramebufferObject = new QOpenGLFramebufferObject(size); | |
| 69 | − Application::getInstance()->getGLWidget()->installEventFilter(this); | |
| 70 | − | |
| 67 | + _primaryFramebufferObject = createFramebufferObject(); | |
| 68 | + | |
| 71 | 69 | glGenTextures(1, &_primaryDepthTextureID); |
| 72 | 70 | glBindTexture(GL_TEXTURE_2D, _primaryDepthTextureID); |
| 71 | + QSize size = Application::getInstance()->getGLWidget()->size(); | |
| 73 | 72 | glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, size.width(), size.height(), |
| 74 | 73 | 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0); |
| 75 | 74 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| @@ -91,16 +90,14 @@ GLuint TextureCache::getPrimaryDepthTextureID() { · 15 unmodified lines | ||
| 91 | 90 | |
| 92 | 91 | QOpenGLFramebufferObject* TextureCache::getSecondaryFramebufferObject() { |
| 93 | 92 | if (_secondaryFramebufferObject == NULL) { |
| 94 | − _secondaryFramebufferObject = new QOpenGLFramebufferObject(Application::getInstance()->getGLWidget()->size()); | |
| 95 | − Application::getInstance()->getGLWidget()->installEventFilter(this); | |
| 93 | + _secondaryFramebufferObject = createFramebufferObject(); | |
| 96 | 94 | } |
| 97 | 95 | return _secondaryFramebufferObject; |
| 98 | 96 | } |
| 99 | 97 | |
| 100 | 98 | QOpenGLFramebufferObject* TextureCache::getTertiaryFramebufferObject() { |
| 101 | 99 | if (_tertiaryFramebufferObject == NULL) { |
| 102 | − _tertiaryFramebufferObject = new QOpenGLFramebufferObject(Application::getInstance()->getGLWidget()->size()); | |
| 103 | − Application::getInstance()->getGLWidget()->installEventFilter(this); | |
| 100 | + _tertiaryFramebufferObject = createFramebufferObject(); | |
| 104 | 101 | } |
| 105 | 102 | return _tertiaryFramebufferObject; |
| 106 | 103 | } |
| @@ -124,3 +121,15 @@ bool TextureCache::eventFilter(QObject* watched, QEvent* event) { · 17 unmodified lines | ||
| 124 | 121 | } |
| 125 | 122 | return false; |
| 126 | 123 | } |
| 124 | + | |
| 125 | +QOpenGLFramebufferObject* TextureCache::createFramebufferObject() { | |
| 126 | + QOpenGLFramebufferObject* fbo = new QOpenGLFramebufferObject(Application::getInstance()->getGLWidget()->size()); | |
| 127 | + Application::getInstance()->getGLWidget()->installEventFilter(this); | |
| 128 | + | |
| 129 | + glBindTexture(GL_TEXTURE_2D, fbo->texture()); | |
| 130 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | |
| 131 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | |
| 132 | + glBindTexture(GL_TEXTURE_2D, 0); | |
| 133 | + | |
| 134 | + return fbo; | |
| 135 | +} | |