mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 20:36:38 +02:00
make TextureCache work with DependancyManager
This commit is contained in:
parent
c6b033fa0e
commit
7d75d2d1bf
13 changed files with 70 additions and 78 deletions
|
@ -620,10 +620,10 @@ void Application::paintGL() {
|
||||||
// Set the desired FBO texture size. If it hasn't changed, this does nothing.
|
// Set the desired FBO texture size. If it hasn't changed, this does nothing.
|
||||||
// Otherwise, it must rebuild the FBOs
|
// Otherwise, it must rebuild the FBOs
|
||||||
if (OculusManager::isConnected()) {
|
if (OculusManager::isConnected()) {
|
||||||
TextureCache::getInstance()->setFrameBufferSize(OculusManager::getRenderTargetSize());
|
DependencyManager::get<TextureCache>()->setFrameBufferSize(OculusManager::getRenderTargetSize());
|
||||||
} else {
|
} else {
|
||||||
QSize fbSize = _glWidget->getDeviceSize() * getRenderResolutionScale();
|
QSize fbSize = _glWidget->getDeviceSize() * getRenderResolutionScale();
|
||||||
TextureCache::getInstance()->setFrameBufferSize(fbSize);
|
DependencyManager::get<TextureCache>()->setFrameBufferSize(fbSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnable(GL_LINE_SMOOTH);
|
glEnable(GL_LINE_SMOOTH);
|
||||||
|
@ -713,7 +713,7 @@ void Application::paintGL() {
|
||||||
_glowEffect.prepare();
|
_glowEffect.prepare();
|
||||||
|
|
||||||
// Viewport is assigned to the size of the framebuffer
|
// Viewport is assigned to the size of the framebuffer
|
||||||
QSize size = TextureCache::getInstance()->getPrimaryFramebufferObject()->size();
|
QSize size = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->size();
|
||||||
glViewport(0, 0, size.width(), size.height());
|
glViewport(0, 0, size.width(), size.height());
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
@ -2043,7 +2043,7 @@ void Application::init() {
|
||||||
connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);
|
connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);
|
||||||
|
|
||||||
// make sure our texture cache knows about window size changes
|
// make sure our texture cache knows about window size changes
|
||||||
TextureCache::getInstance()->associateWithWidget(getGLWidget());
|
DependencyManager::get<TextureCache>()->associateWithWidget(getGLWidget());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::closeMirrorView() {
|
void Application::closeMirrorView() {
|
||||||
|
@ -2774,7 +2774,7 @@ glm::vec3 Application::getSunDirection() {
|
||||||
|
|
||||||
void Application::updateShadowMap() {
|
void Application::updateShadowMap() {
|
||||||
PerformanceTimer perfTimer("shadowMap");
|
PerformanceTimer perfTimer("shadowMap");
|
||||||
QOpenGLFramebufferObject* fbo = TextureCache::getInstance()->getShadowFramebufferObject();
|
QOpenGLFramebufferObject* fbo = DependencyManager::get<TextureCache>()->getShadowFramebufferObject();
|
||||||
fbo->bind();
|
fbo->bind();
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
@ -2939,7 +2939,7 @@ void Application::setupWorldLight() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage Application::renderAvatarBillboard() {
|
QImage Application::renderAvatarBillboard() {
|
||||||
TextureCache::getInstance()->getPrimaryFramebufferObject()->bind();
|
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind();
|
||||||
|
|
||||||
// the "glow" here causes an alpha of one
|
// the "glow" here causes an alpha of one
|
||||||
Glower glower;
|
Glower glower;
|
||||||
|
@ -2950,7 +2950,7 @@ QImage Application::renderAvatarBillboard() {
|
||||||
QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32);
|
QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32);
|
||||||
glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits());
|
glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits());
|
||||||
|
|
||||||
TextureCache::getInstance()->getPrimaryFramebufferObject()->release();
|
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->release();
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
@ -3301,12 +3301,12 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) {
|
||||||
|
|
||||||
// set the bounds of rear mirror view
|
// set the bounds of rear mirror view
|
||||||
if (billboard) {
|
if (billboard) {
|
||||||
QSize size = TextureCache::getInstance()->getFrameBufferSize();
|
QSize size = DependencyManager::get<TextureCache>()->getFrameBufferSize();
|
||||||
glViewport(region.x(), size.height() - region.y() - region.height(), region.width(), region.height());
|
glViewport(region.x(), size.height() - region.y() - region.height(), region.width(), region.height());
|
||||||
glScissor(region.x(), size.height() - region.y() - region.height(), region.width(), region.height());
|
glScissor(region.x(), size.height() - region.y() - region.height(), region.width(), region.height());
|
||||||
} else {
|
} else {
|
||||||
// if not rendering the billboard, the region is in device independent coordinates; must convert to device
|
// if not rendering the billboard, the region is in device independent coordinates; must convert to device
|
||||||
QSize size = TextureCache::getInstance()->getFrameBufferSize();
|
QSize size = DependencyManager::get<TextureCache>()->getFrameBufferSize();
|
||||||
float ratio = QApplication::desktop()->windowHandle()->devicePixelRatio() * getRenderResolutionScale();
|
float ratio = QApplication::desktop()->windowHandle()->devicePixelRatio() * getRenderResolutionScale();
|
||||||
int x = region.x() * ratio, y = region.y() * ratio, width = region.width() * ratio, height = region.height() * ratio;
|
int x = region.x() * ratio, y = region.y() * ratio, width = region.width() * ratio, height = region.height() * ratio;
|
||||||
glViewport(x, size.height() - y - height, width, height);
|
glViewport(x, size.height() - y - height, width, height);
|
||||||
|
|
|
@ -205,7 +205,7 @@ void MetavoxelSystem::render() {
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
|
||||||
TextureCache::getInstance()->setPrimaryDrawBuffers(true, true);
|
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, true);
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
|
@ -251,7 +251,7 @@ void MetavoxelSystem::render() {
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCache::getInstance()->setPrimaryDrawBuffers(true, false);
|
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, false);
|
||||||
|
|
||||||
_baseHeightfieldProgram.release();
|
_baseHeightfieldProgram.release();
|
||||||
|
|
||||||
|
@ -348,7 +348,7 @@ void MetavoxelSystem::render() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_voxelBaseBatches.isEmpty()) {
|
if (!_voxelBaseBatches.isEmpty()) {
|
||||||
TextureCache::getInstance()->setPrimaryDrawBuffers(true, true);
|
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, true);
|
||||||
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
@ -383,7 +383,7 @@ void MetavoxelSystem::render() {
|
||||||
glDisable(GL_ALPHA_TEST);
|
glDisable(GL_ALPHA_TEST);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
TextureCache::getInstance()->setPrimaryDrawBuffers(true, false);
|
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, false);
|
||||||
|
|
||||||
if (!_voxelSplatBatches.isEmpty()) {
|
if (!_voxelSplatBatches.isEmpty()) {
|
||||||
glDepthFunc(GL_LEQUAL);
|
glDepthFunc(GL_LEQUAL);
|
||||||
|
@ -463,7 +463,7 @@ void MetavoxelSystem::render() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_hermiteBatches.isEmpty() && Menu::getInstance()->isOptionChecked(MenuOption::DisplayHermiteData)) {
|
if (!_hermiteBatches.isEmpty() && Menu::getInstance()->isOptionChecked(MenuOption::DisplayHermiteData)) {
|
||||||
TextureCache::getInstance()->setPrimaryDrawBuffers(true, true);
|
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, true);
|
||||||
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
|
||||||
|
@ -486,7 +486,7 @@ void MetavoxelSystem::render() {
|
||||||
|
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
|
|
||||||
TextureCache::getInstance()->setPrimaryDrawBuffers(true, false);
|
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, false);
|
||||||
}
|
}
|
||||||
_hermiteBatches.clear();
|
_hermiteBatches.clear();
|
||||||
|
|
||||||
|
@ -797,7 +797,7 @@ void MetavoxelSystem::applyMaterialEdit(const MetavoxelEditMessage& message, boo
|
||||||
Q_ARG(bool, reliable));
|
Q_ARG(bool, reliable));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QSharedPointer<NetworkTexture> texture = TextureCache::getInstance()->getTexture(
|
QSharedPointer<NetworkTexture> texture = DependencyManager::get<TextureCache>()->getTexture(
|
||||||
material->getDiffuse(), SPLAT_TEXTURE);
|
material->getDiffuse(), SPLAT_TEXTURE);
|
||||||
if (texture->isLoaded()) {
|
if (texture->isLoaded()) {
|
||||||
MetavoxelEditMessage newMessage = message;
|
MetavoxelEditMessage newMessage = message;
|
||||||
|
@ -1180,7 +1180,7 @@ void VoxelBuffer::render(bool cursor) {
|
||||||
for (int i = 0; i < _materials.size(); i++) {
|
for (int i = 0; i < _materials.size(); i++) {
|
||||||
const SharedObjectPointer material = _materials.at(i);
|
const SharedObjectPointer material = _materials.at(i);
|
||||||
if (material) {
|
if (material) {
|
||||||
_networkTextures[i] = TextureCache::getInstance()->getTexture(
|
_networkTextures[i] = DependencyManager::get<TextureCache>()->getTexture(
|
||||||
static_cast<MaterialObject*>(material.data())->getDiffuse(), SPLAT_TEXTURE);
|
static_cast<MaterialObject*>(material.data())->getDiffuse(), SPLAT_TEXTURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2234,7 +2234,7 @@ void HeightfieldNodeRenderer::render(const HeightfieldNodePointer& node, const g
|
||||||
for (int i = 0; i < materials.size(); i++) {
|
for (int i = 0; i < materials.size(); i++) {
|
||||||
const SharedObjectPointer& material = materials.at(i);
|
const SharedObjectPointer& material = materials.at(i);
|
||||||
if (material) {
|
if (material) {
|
||||||
_networkTextures[i] = TextureCache::getInstance()->getTexture(
|
_networkTextures[i] = DependencyManager::get<TextureCache>()->getTexture(
|
||||||
static_cast<MaterialObject*>(material.data())->getDiffuse(), SPLAT_TEXTURE);
|
static_cast<MaterialObject*>(material.data())->getDiffuse(), SPLAT_TEXTURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -473,7 +473,7 @@ void ModelUploader::processCheck() {
|
||||||
QMessageBox::Ok);
|
QMessageBox::Ok);
|
||||||
GeometryCache::getInstance()->refresh(_url);
|
GeometryCache::getInstance()->refresh(_url);
|
||||||
foreach (const QByteArray& filename, _textureFilenames) {
|
foreach (const QByteArray& filename, _textureFilenames) {
|
||||||
TextureCache::getInstance()->refresh(_textureBase + filename);
|
DependencyManager::get<TextureCache>()->refresh(_textureBase + filename);
|
||||||
}
|
}
|
||||||
deleteLater();
|
deleteLater();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -449,7 +449,7 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)) {
|
||||||
Application::getInstance()->getGlowEffect()->prepare();
|
Application::getInstance()->getGlowEffect()->prepare();
|
||||||
} else {
|
} else {
|
||||||
TextureCache::getInstance()->getPrimaryFramebufferObject()->bind();
|
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind();
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -555,8 +555,8 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p
|
||||||
QOpenGLFramebufferObject* fbo = Application::getInstance()->getGlowEffect()->render(true);
|
QOpenGLFramebufferObject* fbo = Application::getInstance()->getGlowEffect()->render(true);
|
||||||
glBindTexture(GL_TEXTURE_2D, fbo->texture());
|
glBindTexture(GL_TEXTURE_2D, fbo->texture());
|
||||||
} else {
|
} else {
|
||||||
TextureCache::getInstance()->getPrimaryFramebufferObject()->release();
|
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->release();
|
||||||
glBindTexture(GL_TEXTURE_2D, TextureCache::getInstance()->getPrimaryFramebufferObject()->texture());
|
glBindTexture(GL_TEXTURE_2D, DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->texture());
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore our normal viewport
|
// restore our normal viewport
|
||||||
|
|
|
@ -98,7 +98,7 @@ void AmbientOcclusionEffect::render() {
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, TextureCache::getInstance()->getPrimaryDepthTextureID());
|
glBindTexture(GL_TEXTURE_2D, DependencyManager::get<TextureCache>()->getPrimaryDepthTextureID());
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, _rotationTextureID);
|
glBindTexture(GL_TEXTURE_2D, _rotationTextureID);
|
||||||
|
@ -116,7 +116,7 @@ void AmbientOcclusionEffect::render() {
|
||||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||||
const int VIEWPORT_X_INDEX = 0;
|
const int VIEWPORT_X_INDEX = 0;
|
||||||
const int VIEWPORT_WIDTH_INDEX = 2;
|
const int VIEWPORT_WIDTH_INDEX = 2;
|
||||||
QOpenGLFramebufferObject* primaryFBO = TextureCache::getInstance()->getPrimaryFramebufferObject();
|
QOpenGLFramebufferObject* primaryFBO = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject();
|
||||||
float sMin = viewport[VIEWPORT_X_INDEX] / (float)primaryFBO->width();
|
float sMin = viewport[VIEWPORT_X_INDEX] / (float)primaryFBO->width();
|
||||||
float sWidth = viewport[VIEWPORT_WIDTH_INDEX] / (float)primaryFBO->width();
|
float sWidth = viewport[VIEWPORT_WIDTH_INDEX] / (float)primaryFBO->width();
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ void AmbientOcclusionEffect::render() {
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
// now render secondary to primary with 4x4 blur
|
// now render secondary to primary with 4x4 blur
|
||||||
TextureCache::getInstance()->getPrimaryFramebufferObject()->bind();
|
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind();
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFuncSeparate(GL_ZERO, GL_SRC_COLOR, GL_ZERO, GL_ONE);
|
glBlendFuncSeparate(GL_ZERO, GL_SRC_COLOR, GL_ZERO, GL_ONE);
|
||||||
|
|
|
@ -37,7 +37,7 @@ void DeferredLightingEffect::init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredLightingEffect::bindSimpleProgram() {
|
void DeferredLightingEffect::bindSimpleProgram() {
|
||||||
TextureCache::getInstance()->setPrimaryDrawBuffers(true, true, true);
|
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, true, true);
|
||||||
_simpleProgram.bind();
|
_simpleProgram.bind();
|
||||||
_simpleProgram.setUniformValue(_glowIntensityLocation, Application::getInstance()->getGlowEffect()->getIntensity());
|
_simpleProgram.setUniformValue(_glowIntensityLocation, Application::getInstance()->getGlowEffect()->getIntensity());
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
@ -46,7 +46,7 @@ void DeferredLightingEffect::bindSimpleProgram() {
|
||||||
void DeferredLightingEffect::releaseSimpleProgram() {
|
void DeferredLightingEffect::releaseSimpleProgram() {
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
_simpleProgram.release();
|
_simpleProgram.release();
|
||||||
TextureCache::getInstance()->setPrimaryDrawBuffers(true, false, false);
|
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredLightingEffect::renderSolidSphere(float radius, int slices, int stacks) {
|
void DeferredLightingEffect::renderSolidSphere(float radius, int slices, int stacks) {
|
||||||
|
@ -117,15 +117,15 @@ void DeferredLightingEffect::addSpotLight(const glm::vec3& position, float radiu
|
||||||
|
|
||||||
void DeferredLightingEffect::prepare() {
|
void DeferredLightingEffect::prepare() {
|
||||||
// clear the normal and specular buffers
|
// clear the normal and specular buffers
|
||||||
TextureCache::getInstance()->setPrimaryDrawBuffers(false, true, false);
|
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(false, true, false);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
TextureCache::getInstance()->setPrimaryDrawBuffers(false, false, true);
|
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(false, false, true);
|
||||||
// clearing to zero alpha for specular causes problems on my Nvidia card; clear to lowest non-zero value instead
|
// clearing to zero alpha for specular causes problems on my Nvidia card; clear to lowest non-zero value instead
|
||||||
const float MAX_SPECULAR_EXPONENT = 128.0f;
|
const float MAX_SPECULAR_EXPONENT = 128.0f;
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f / MAX_SPECULAR_EXPONENT);
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f / MAX_SPECULAR_EXPONENT);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
TextureCache::getInstance()->setPrimaryDrawBuffers(true, false, false);
|
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredLightingEffect::render() {
|
void DeferredLightingEffect::render() {
|
||||||
|
@ -138,7 +138,7 @@ void DeferredLightingEffect::render() {
|
||||||
glDisable(GL_COLOR_MATERIAL);
|
glDisable(GL_COLOR_MATERIAL);
|
||||||
glDepthMask(false);
|
glDepthMask(false);
|
||||||
|
|
||||||
QOpenGLFramebufferObject* primaryFBO = TextureCache::getInstance()->getPrimaryFramebufferObject();
|
QOpenGLFramebufferObject* primaryFBO = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject();
|
||||||
primaryFBO->release();
|
primaryFBO->release();
|
||||||
|
|
||||||
QOpenGLFramebufferObject* freeFBO = Application::getInstance()->getGlowEffect()->getFreeFramebufferObject();
|
QOpenGLFramebufferObject* freeFBO = Application::getInstance()->getGlowEffect()->getFreeFramebufferObject();
|
||||||
|
@ -148,13 +148,13 @@ void DeferredLightingEffect::render() {
|
||||||
glBindTexture(GL_TEXTURE_2D, primaryFBO->texture());
|
glBindTexture(GL_TEXTURE_2D, primaryFBO->texture());
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, TextureCache::getInstance()->getPrimaryNormalTextureID());
|
glBindTexture(GL_TEXTURE_2D, DependencyManager::get<TextureCache>()->getPrimaryNormalTextureID());
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE2);
|
glActiveTexture(GL_TEXTURE2);
|
||||||
glBindTexture(GL_TEXTURE_2D, TextureCache::getInstance()->getPrimarySpecularTextureID());
|
glBindTexture(GL_TEXTURE_2D, DependencyManager::get<TextureCache>()->getPrimarySpecularTextureID());
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE3);
|
glActiveTexture(GL_TEXTURE3);
|
||||||
glBindTexture(GL_TEXTURE_2D, TextureCache::getInstance()->getPrimaryDepthTextureID());
|
glBindTexture(GL_TEXTURE_2D, DependencyManager::get<TextureCache>()->getPrimaryDepthTextureID());
|
||||||
|
|
||||||
// get the viewport side (left, right, both)
|
// get the viewport side (left, right, both)
|
||||||
int viewport[4];
|
int viewport[4];
|
||||||
|
@ -173,7 +173,7 @@ void DeferredLightingEffect::render() {
|
||||||
bool shadowsEnabled = Menu::getInstance()->getShadowsEnabled();
|
bool shadowsEnabled = Menu::getInstance()->getShadowsEnabled();
|
||||||
if (shadowsEnabled) {
|
if (shadowsEnabled) {
|
||||||
glActiveTexture(GL_TEXTURE4);
|
glActiveTexture(GL_TEXTURE4);
|
||||||
glBindTexture(GL_TEXTURE_2D, TextureCache::getInstance()->getShadowDepthTextureID());
|
glBindTexture(GL_TEXTURE_2D, DependencyManager::get<TextureCache>()->getShadowDepthTextureID());
|
||||||
|
|
||||||
program = &_directionalLightShadowMap;
|
program = &_directionalLightShadowMap;
|
||||||
locations = &_directionalLightShadowMapLocations;
|
locations = &_directionalLightShadowMapLocations;
|
||||||
|
@ -188,7 +188,7 @@ void DeferredLightingEffect::render() {
|
||||||
program->bind();
|
program->bind();
|
||||||
}
|
}
|
||||||
program->setUniformValue(locations->shadowScale,
|
program->setUniformValue(locations->shadowScale,
|
||||||
1.0f / TextureCache::getInstance()->getShadowFramebufferObject()->width());
|
1.0f / DependencyManager::get<TextureCache>()->getShadowFramebufferObject()->width());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
program->bind();
|
program->bind();
|
||||||
|
|
|
@ -712,19 +712,19 @@ void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& u
|
||||||
QSharedPointer<NetworkTexture> matchingTexture = QSharedPointer<NetworkTexture>();
|
QSharedPointer<NetworkTexture> matchingTexture = QSharedPointer<NetworkTexture>();
|
||||||
if (part.diffuseTextureName == name) {
|
if (part.diffuseTextureName == name) {
|
||||||
part.diffuseTexture =
|
part.diffuseTexture =
|
||||||
TextureCache::getInstance()->getTexture(url, DEFAULT_TEXTURE,
|
DependencyManager::get<TextureCache>()->getTexture(url, DEFAULT_TEXTURE,
|
||||||
_geometry.meshes[i].isEye, QByteArray());
|
_geometry.meshes[i].isEye, QByteArray());
|
||||||
part.diffuseTexture->setLoadPriorities(_loadPriorities);
|
part.diffuseTexture->setLoadPriorities(_loadPriorities);
|
||||||
} else if (part.normalTextureName == name) {
|
} else if (part.normalTextureName == name) {
|
||||||
part.normalTexture = TextureCache::getInstance()->getTexture(url, DEFAULT_TEXTURE,
|
part.normalTexture = DependencyManager::get<TextureCache>()->getTexture(url, DEFAULT_TEXTURE,
|
||||||
false, QByteArray());
|
false, QByteArray());
|
||||||
part.normalTexture->setLoadPriorities(_loadPriorities);
|
part.normalTexture->setLoadPriorities(_loadPriorities);
|
||||||
} else if (part.specularTextureName == name) {
|
} else if (part.specularTextureName == name) {
|
||||||
part.specularTexture = TextureCache::getInstance()->getTexture(url, DEFAULT_TEXTURE,
|
part.specularTexture = DependencyManager::get<TextureCache>()->getTexture(url, DEFAULT_TEXTURE,
|
||||||
false, QByteArray());
|
false, QByteArray());
|
||||||
part.specularTexture->setLoadPriorities(_loadPriorities);
|
part.specularTexture->setLoadPriorities(_loadPriorities);
|
||||||
} else if (part.emissiveTextureName == name) {
|
} else if (part.emissiveTextureName == name) {
|
||||||
part.emissiveTexture = TextureCache::getInstance()->getTexture(url, DEFAULT_TEXTURE,
|
part.emissiveTexture = DependencyManager::get<TextureCache>()->getTexture(url, DEFAULT_TEXTURE,
|
||||||
false, QByteArray());
|
false, QByteArray());
|
||||||
part.emissiveTexture->setLoadPriorities(_loadPriorities);
|
part.emissiveTexture->setLoadPriorities(_loadPriorities);
|
||||||
}
|
}
|
||||||
|
@ -925,28 +925,28 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) {
|
||||||
foreach (const FBXMeshPart& part, mesh.parts) {
|
foreach (const FBXMeshPart& part, mesh.parts) {
|
||||||
NetworkMeshPart networkPart;
|
NetworkMeshPart networkPart;
|
||||||
if (!part.diffuseTexture.filename.isEmpty()) {
|
if (!part.diffuseTexture.filename.isEmpty()) {
|
||||||
networkPart.diffuseTexture = TextureCache::getInstance()->getTexture(
|
networkPart.diffuseTexture = DependencyManager::get<TextureCache>()->getTexture(
|
||||||
_textureBase.resolved(QUrl(part.diffuseTexture.filename)), DEFAULT_TEXTURE,
|
_textureBase.resolved(QUrl(part.diffuseTexture.filename)), DEFAULT_TEXTURE,
|
||||||
mesh.isEye, part.diffuseTexture.content);
|
mesh.isEye, part.diffuseTexture.content);
|
||||||
networkPart.diffuseTextureName = part.diffuseTexture.name;
|
networkPart.diffuseTextureName = part.diffuseTexture.name;
|
||||||
networkPart.diffuseTexture->setLoadPriorities(_loadPriorities);
|
networkPart.diffuseTexture->setLoadPriorities(_loadPriorities);
|
||||||
}
|
}
|
||||||
if (!part.normalTexture.filename.isEmpty()) {
|
if (!part.normalTexture.filename.isEmpty()) {
|
||||||
networkPart.normalTexture = TextureCache::getInstance()->getTexture(
|
networkPart.normalTexture = DependencyManager::get<TextureCache>()->getTexture(
|
||||||
_textureBase.resolved(QUrl(part.normalTexture.filename)), NORMAL_TEXTURE,
|
_textureBase.resolved(QUrl(part.normalTexture.filename)), NORMAL_TEXTURE,
|
||||||
false, part.normalTexture.content);
|
false, part.normalTexture.content);
|
||||||
networkPart.normalTextureName = part.normalTexture.name;
|
networkPart.normalTextureName = part.normalTexture.name;
|
||||||
networkPart.normalTexture->setLoadPriorities(_loadPriorities);
|
networkPart.normalTexture->setLoadPriorities(_loadPriorities);
|
||||||
}
|
}
|
||||||
if (!part.specularTexture.filename.isEmpty()) {
|
if (!part.specularTexture.filename.isEmpty()) {
|
||||||
networkPart.specularTexture = TextureCache::getInstance()->getTexture(
|
networkPart.specularTexture = DependencyManager::get<TextureCache>()->getTexture(
|
||||||
_textureBase.resolved(QUrl(part.specularTexture.filename)), SPECULAR_TEXTURE,
|
_textureBase.resolved(QUrl(part.specularTexture.filename)), SPECULAR_TEXTURE,
|
||||||
false, part.specularTexture.content);
|
false, part.specularTexture.content);
|
||||||
networkPart.specularTextureName = part.specularTexture.name;
|
networkPart.specularTextureName = part.specularTexture.name;
|
||||||
networkPart.specularTexture->setLoadPriorities(_loadPriorities);
|
networkPart.specularTexture->setLoadPriorities(_loadPriorities);
|
||||||
}
|
}
|
||||||
if (!part.emissiveTexture.filename.isEmpty()) {
|
if (!part.emissiveTexture.filename.isEmpty()) {
|
||||||
networkPart.emissiveTexture = TextureCache::getInstance()->getTexture(
|
networkPart.emissiveTexture = DependencyManager::get<TextureCache>()->getTexture(
|
||||||
_textureBase.resolved(QUrl(part.emissiveTexture.filename)), EMISSIVE_TEXTURE,
|
_textureBase.resolved(QUrl(part.emissiveTexture.filename)), EMISSIVE_TEXTURE,
|
||||||
false, part.emissiveTexture.content);
|
false, part.emissiveTexture.content);
|
||||||
networkPart.emissiveTextureName = part.emissiveTexture.name;
|
networkPart.emissiveTextureName = part.emissiveTexture.name;
|
||||||
|
|
|
@ -41,8 +41,8 @@ GlowEffect::~GlowEffect() {
|
||||||
|
|
||||||
QOpenGLFramebufferObject* GlowEffect::getFreeFramebufferObject() const {
|
QOpenGLFramebufferObject* GlowEffect::getFreeFramebufferObject() const {
|
||||||
return (_isOddFrame ?
|
return (_isOddFrame ?
|
||||||
TextureCache::getInstance()->getSecondaryFramebufferObject():
|
DependencyManager::get<TextureCache>()->getSecondaryFramebufferObject():
|
||||||
TextureCache::getInstance()->getTertiaryFramebufferObject());
|
DependencyManager::get<TextureCache>()->getTertiaryFramebufferObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
static ProgramObject* createProgram(const QString& name) {
|
static ProgramObject* createProgram(const QString& name) {
|
||||||
|
@ -88,7 +88,7 @@ void GlowEffect::init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlowEffect::prepare() {
|
void GlowEffect::prepare() {
|
||||||
TextureCache::getInstance()->getPrimaryFramebufferObject()->bind();
|
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind();
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
_isEmpty = true;
|
_isEmpty = true;
|
||||||
|
@ -122,7 +122,7 @@ static void maybeRelease(QOpenGLFramebufferObject* fbo) {
|
||||||
QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
|
QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
|
||||||
PerformanceTimer perfTimer("glowEffect");
|
PerformanceTimer perfTimer("glowEffect");
|
||||||
|
|
||||||
QOpenGLFramebufferObject* primaryFBO = TextureCache::getInstance()->getPrimaryFramebufferObject();
|
QOpenGLFramebufferObject* primaryFBO = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject();
|
||||||
primaryFBO->release();
|
primaryFBO->release();
|
||||||
glBindTexture(GL_TEXTURE_2D, primaryFBO->texture());
|
glBindTexture(GL_TEXTURE_2D, primaryFBO->texture());
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
|
|
||||||
QOpenGLFramebufferObject* destFBO = toTexture ?
|
QOpenGLFramebufferObject* destFBO = toTexture ?
|
||||||
TextureCache::getInstance()->getSecondaryFramebufferObject() : NULL;
|
DependencyManager::get<TextureCache>()->getSecondaryFramebufferObject() : NULL;
|
||||||
if (!Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect) || _isEmpty) {
|
if (!Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect) || _isEmpty) {
|
||||||
// copy the primary to the screen
|
// copy the primary to the screen
|
||||||
if (destFBO && QOpenGLFramebufferObject::hasOpenGLFramebufferBlit()) {
|
if (destFBO && QOpenGLFramebufferObject::hasOpenGLFramebufferBlit()) {
|
||||||
|
@ -160,9 +160,9 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
|
||||||
} else {
|
} else {
|
||||||
// diffuse into the secondary/tertiary (alternating between frames)
|
// diffuse into the secondary/tertiary (alternating between frames)
|
||||||
QOpenGLFramebufferObject* oldDiffusedFBO =
|
QOpenGLFramebufferObject* oldDiffusedFBO =
|
||||||
TextureCache::getInstance()->getSecondaryFramebufferObject();
|
DependencyManager::get<TextureCache>()->getSecondaryFramebufferObject();
|
||||||
QOpenGLFramebufferObject* newDiffusedFBO =
|
QOpenGLFramebufferObject* newDiffusedFBO =
|
||||||
TextureCache::getInstance()->getTertiaryFramebufferObject();
|
DependencyManager::get<TextureCache>()->getTertiaryFramebufferObject();
|
||||||
if (_isOddFrame) {
|
if (_isOddFrame) {
|
||||||
qSwap(oldDiffusedFBO, newDiffusedFBO);
|
qSwap(oldDiffusedFBO, newDiffusedFBO);
|
||||||
}
|
}
|
||||||
|
|
|
@ -749,7 +749,7 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*TextureCache::getInstance()->setPrimaryDrawBuffers(
|
/*DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(
|
||||||
mode == DEFAULT_RENDER_MODE || mode == DIFFUSE_RENDER_MODE,
|
mode == DEFAULT_RENDER_MODE || mode == DIFFUSE_RENDER_MODE,
|
||||||
mode == DEFAULT_RENDER_MODE || mode == NORMAL_RENDER_MODE,
|
mode == DEFAULT_RENDER_MODE || mode == NORMAL_RENDER_MODE,
|
||||||
mode == DEFAULT_RENDER_MODE);
|
mode == DEFAULT_RENDER_MODE);
|
||||||
|
@ -789,7 +789,7 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) {
|
||||||
opaqueMeshPartsRendered += renderMeshes(batch, mode, false, DEFAULT_ALPHA_THRESHOLD, true, true, true, false, args);
|
opaqueMeshPartsRendered += renderMeshes(batch, mode, false, DEFAULT_ALPHA_THRESHOLD, true, true, true, false, args);
|
||||||
|
|
||||||
// render translucent meshes afterwards
|
// render translucent meshes afterwards
|
||||||
//TextureCache::getInstance()->setPrimaryDrawBuffers(false, true, true);
|
//DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(false, true, true);
|
||||||
{
|
{
|
||||||
GLenum buffers[2];
|
GLenum buffers[2];
|
||||||
int bufferCount = 0;
|
int bufferCount = 0;
|
||||||
|
@ -814,7 +814,7 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) {
|
||||||
GLBATCH(glDepthMask)(false);
|
GLBATCH(glDepthMask)(false);
|
||||||
GLBATCH(glDepthFunc)(GL_LEQUAL);
|
GLBATCH(glDepthFunc)(GL_LEQUAL);
|
||||||
|
|
||||||
//TextureCache::getInstance()->setPrimaryDrawBuffers(true);
|
//DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true);
|
||||||
{
|
{
|
||||||
GLenum buffers[1];
|
GLenum buffers[1];
|
||||||
int bufferCount = 0;
|
int bufferCount = 0;
|
||||||
|
@ -1705,7 +1705,7 @@ void Model::endScene(RenderMode mode, RenderArgs* args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*TextureCache::getInstance()->setPrimaryDrawBuffers(
|
/*DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(
|
||||||
mode == DEFAULT_RENDER_MODE || mode == DIFFUSE_RENDER_MODE,
|
mode == DEFAULT_RENDER_MODE || mode == DIFFUSE_RENDER_MODE,
|
||||||
mode == DEFAULT_RENDER_MODE || mode == NORMAL_RENDER_MODE,
|
mode == DEFAULT_RENDER_MODE || mode == NORMAL_RENDER_MODE,
|
||||||
mode == DEFAULT_RENDER_MODE);
|
mode == DEFAULT_RENDER_MODE);
|
||||||
|
@ -1745,7 +1745,7 @@ void Model::endScene(RenderMode mode, RenderArgs* args) {
|
||||||
opaqueMeshPartsRendered += renderMeshesForModelsInScene(batch, mode, false, DEFAULT_ALPHA_THRESHOLD, true, true, true, false, args);
|
opaqueMeshPartsRendered += renderMeshesForModelsInScene(batch, mode, false, DEFAULT_ALPHA_THRESHOLD, true, true, true, false, args);
|
||||||
|
|
||||||
// render translucent meshes afterwards
|
// render translucent meshes afterwards
|
||||||
//TextureCache::getInstance()->setPrimaryDrawBuffers(false, true, true);
|
//DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(false, true, true);
|
||||||
{
|
{
|
||||||
GLenum buffers[2];
|
GLenum buffers[2];
|
||||||
int bufferCount = 0;
|
int bufferCount = 0;
|
||||||
|
@ -1770,7 +1770,7 @@ void Model::endScene(RenderMode mode, RenderArgs* args) {
|
||||||
GLBATCH(glDepthMask)(false);
|
GLBATCH(glDepthMask)(false);
|
||||||
GLBATCH(glDepthFunc)(GL_LEQUAL);
|
GLBATCH(glDepthFunc)(GL_LEQUAL);
|
||||||
|
|
||||||
//TextureCache::getInstance()->setPrimaryDrawBuffers(true);
|
//DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true);
|
||||||
{
|
{
|
||||||
GLenum buffers[1];
|
GLenum buffers[1];
|
||||||
int bufferCount = 0;
|
int bufferCount = 0;
|
||||||
|
@ -2446,7 +2446,7 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
|
||||||
if (showDiffuse && diffuseMap) {
|
if (showDiffuse && diffuseMap) {
|
||||||
GLBATCH(glBindTexture)(GL_TEXTURE_2D, diffuseMap->getID());
|
GLBATCH(glBindTexture)(GL_TEXTURE_2D, diffuseMap->getID());
|
||||||
} else {
|
} else {
|
||||||
GLBATCH(glBindTexture)(GL_TEXTURE_2D, TextureCache::getInstance()->getWhiteTextureID());
|
GLBATCH(glBindTexture)(GL_TEXTURE_2D, DependencyManager::get<TextureCache>()->getWhiteTextureID());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (locations->texcoordMatrices >= 0) {
|
if (locations->texcoordMatrices >= 0) {
|
||||||
|
@ -2464,7 +2464,7 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
|
||||||
GLBATCH(glActiveTexture)(GL_TEXTURE1);
|
GLBATCH(glActiveTexture)(GL_TEXTURE1);
|
||||||
Texture* normalMap = networkPart.normalTexture.data();
|
Texture* normalMap = networkPart.normalTexture.data();
|
||||||
GLBATCH(glBindTexture)(GL_TEXTURE_2D, !normalMap ?
|
GLBATCH(glBindTexture)(GL_TEXTURE_2D, !normalMap ?
|
||||||
TextureCache::getInstance()->getBlueTextureID() : normalMap->getID());
|
DependencyManager::get<TextureCache>()->getBlueTextureID() : normalMap->getID());
|
||||||
GLBATCH(glActiveTexture)(GL_TEXTURE0);
|
GLBATCH(glActiveTexture)(GL_TEXTURE0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2472,7 +2472,7 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
|
||||||
GLBATCH(glActiveTexture)(GL_TEXTURE0 + locations->specularTextureUnit);
|
GLBATCH(glActiveTexture)(GL_TEXTURE0 + locations->specularTextureUnit);
|
||||||
Texture* specularMap = networkPart.specularTexture.data();
|
Texture* specularMap = networkPart.specularTexture.data();
|
||||||
GLBATCH(glBindTexture)(GL_TEXTURE_2D, !specularMap ?
|
GLBATCH(glBindTexture)(GL_TEXTURE_2D, !specularMap ?
|
||||||
TextureCache::getInstance()->getWhiteTextureID() : specularMap->getID());
|
DependencyManager::get<TextureCache>()->getWhiteTextureID() : specularMap->getID());
|
||||||
GLBATCH(glActiveTexture)(GL_TEXTURE0);
|
GLBATCH(glActiveTexture)(GL_TEXTURE0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2493,7 +2493,7 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
|
||||||
GLBATCH(glActiveTexture)(GL_TEXTURE0 + locations->emissiveTextureUnit);
|
GLBATCH(glActiveTexture)(GL_TEXTURE0 + locations->emissiveTextureUnit);
|
||||||
Texture* emissiveMap = networkPart.emissiveTexture.data();
|
Texture* emissiveMap = networkPart.emissiveTexture.data();
|
||||||
GLBATCH(glBindTexture)(GL_TEXTURE_2D, !emissiveMap ?
|
GLBATCH(glBindTexture)(GL_TEXTURE_2D, !emissiveMap ?
|
||||||
TextureCache::getInstance()->getWhiteTextureID() : emissiveMap->getID());
|
DependencyManager::get<TextureCache>()->getWhiteTextureID() : emissiveMap->getID());
|
||||||
GLBATCH(glActiveTexture)(GL_TEXTURE0);
|
GLBATCH(glActiveTexture)(GL_TEXTURE0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,6 @@
|
||||||
|
|
||||||
#include "TextureCache.h"
|
#include "TextureCache.h"
|
||||||
|
|
||||||
TextureCache* TextureCache::getInstance() {
|
|
||||||
static TextureCache instance;
|
|
||||||
return &instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TextureCache::TextureCache() :
|
TextureCache::TextureCache() :
|
||||||
_permutationNormalTextureID(0),
|
_permutationNormalTextureID(0),
|
||||||
_whiteTextureID(0),
|
_whiteTextureID(0),
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QGLWidget>
|
#include <QGLWidget>
|
||||||
|
|
||||||
|
#include <DependencyManager.h>
|
||||||
#include <ResourceCache.h>
|
#include <ResourceCache.h>
|
||||||
|
|
||||||
#include "InterfaceConfig.h"
|
#include "InterfaceConfig.h"
|
||||||
|
@ -29,16 +30,11 @@ typedef QSharedPointer<NetworkTexture> NetworkTexturePointer;
|
||||||
enum TextureType { DEFAULT_TEXTURE, NORMAL_TEXTURE, SPECULAR_TEXTURE, EMISSIVE_TEXTURE, SPLAT_TEXTURE };
|
enum TextureType { DEFAULT_TEXTURE, NORMAL_TEXTURE, SPECULAR_TEXTURE, EMISSIVE_TEXTURE, SPLAT_TEXTURE };
|
||||||
|
|
||||||
/// Stores cached textures, including render-to-texture targets.
|
/// Stores cached textures, including render-to-texture targets.
|
||||||
class TextureCache : public ResourceCache {
|
class TextureCache : public ResourceCache, public DependencyManager::Dependency {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static TextureCache* getInstance();
|
|
||||||
|
|
||||||
TextureCache();
|
|
||||||
virtual ~TextureCache();
|
|
||||||
|
|
||||||
void associateWithWidget(QGLWidget* widget);
|
void associateWithWidget(QGLWidget* widget);
|
||||||
|
|
||||||
/// Sets the desired texture resolution for the framebuffer objects.
|
/// Sets the desired texture resolution for the framebuffer objects.
|
||||||
|
@ -98,7 +94,9 @@ protected:
|
||||||
const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra);
|
const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
TextureCache();
|
||||||
|
virtual ~TextureCache();
|
||||||
|
friend class DependencyManager;
|
||||||
friend class DilatableNetworkTexture;
|
friend class DilatableNetworkTexture;
|
||||||
|
|
||||||
QOpenGLFramebufferObject* createFramebufferObject();
|
QOpenGLFramebufferObject* createFramebufferObject();
|
||||||
|
|
|
@ -916,7 +916,7 @@ void MaterialControl::updateTexture() {
|
||||||
_texture.clear();
|
_texture.clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_texture = TextureCache::getInstance()->getTexture(material->getDiffuse(), SPLAT_TEXTURE);
|
_texture = DependencyManager::get<TextureCache>()->getTexture(material->getDiffuse(), SPLAT_TEXTURE);
|
||||||
if (_texture) {
|
if (_texture) {
|
||||||
if (_texture->isLoaded()) {
|
if (_texture->isLoaded()) {
|
||||||
textureLoaded();
|
textureLoaded();
|
||||||
|
|
|
@ -1170,7 +1170,7 @@ void VoxelSystem::render() {
|
||||||
void VoxelSystem::applyScaleAndBindProgram(bool texture) {
|
void VoxelSystem::applyScaleAndBindProgram(bool texture) {
|
||||||
if (texture) {
|
if (texture) {
|
||||||
bindPerlinModulateProgram();
|
bindPerlinModulateProgram();
|
||||||
glBindTexture(GL_TEXTURE_2D, TextureCache::getInstance()->getPermutationNormalTextureID());
|
glBindTexture(GL_TEXTURE_2D, DependencyManager::get<TextureCache>()->getPermutationNormalTextureID());
|
||||||
} else {
|
} else {
|
||||||
_program.bind();
|
_program.bind();
|
||||||
}
|
}
|
||||||
|
@ -1178,7 +1178,7 @@ void VoxelSystem::applyScaleAndBindProgram(bool texture) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glScalef(_treeScale, _treeScale, _treeScale);
|
glScalef(_treeScale, _treeScale, _treeScale);
|
||||||
|
|
||||||
TextureCache::getInstance()->setPrimaryDrawBuffers(true, true);
|
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelSystem::removeScaleAndReleaseProgram(bool texture) {
|
void VoxelSystem::removeScaleAndReleaseProgram(bool texture) {
|
||||||
|
@ -1192,7 +1192,7 @@ void VoxelSystem::removeScaleAndReleaseProgram(bool texture) {
|
||||||
_program.release();
|
_program.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCache::getInstance()->setPrimaryDrawBuffers(true, false);
|
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int VoxelSystem::_nodeCount = 0;
|
int VoxelSystem::_nodeCount = 0;
|
||||||
|
|
Loading…
Reference in a new issue