use TextureCache::getInstance() instead of Application::getInstance()->getTextureCache()

This commit is contained in:
ZappoMan 2014-12-12 15:29:42 -08:00
parent 2df4c017f1
commit e9ea6b20ce
10 changed files with 49 additions and 49 deletions

View file

@ -716,7 +716,7 @@ void Application::paintGL() {
_glowEffect.prepare();
// Viewport is assigned to the size of the framebuffer
QSize size = Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject()->size();
QSize size = TextureCache::getInstance()->getPrimaryFramebufferObject()->size();
glViewport(0, 0, size.width(), size.height());
glMatrixMode(GL_MODELVIEW);

View file

@ -205,7 +205,7 @@ void MetavoxelSystem::render() {
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, true);
TextureCache::getInstance()->setPrimaryDrawBuffers(true, true);
glDisable(GL_BLEND);
glEnable(GL_CULL_FACE);
@ -251,7 +251,7 @@ void MetavoxelSystem::render() {
glPopMatrix();
}
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false);
TextureCache::getInstance()->setPrimaryDrawBuffers(true, false);
_baseHeightfieldProgram.release();
@ -348,7 +348,7 @@ void MetavoxelSystem::render() {
}
if (!_voxelBaseBatches.isEmpty()) {
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, true);
TextureCache::getInstance()->setPrimaryDrawBuffers(true, true);
glEnableClientState(GL_VERTEX_ARRAY);
glDisable(GL_BLEND);
@ -383,7 +383,7 @@ void MetavoxelSystem::render() {
glDisable(GL_ALPHA_TEST);
glEnable(GL_BLEND);
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false);
TextureCache::getInstance()->setPrimaryDrawBuffers(true, false);
if (!_voxelSplatBatches.isEmpty()) {
glDepthFunc(GL_LEQUAL);
@ -463,7 +463,7 @@ void MetavoxelSystem::render() {
}
if (!_hermiteBatches.isEmpty() && Menu::getInstance()->isOptionChecked(MenuOption::DisplayHermiteData)) {
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, true);
TextureCache::getInstance()->setPrimaryDrawBuffers(true, true);
glEnableClientState(GL_VERTEX_ARRAY);
@ -486,7 +486,7 @@ void MetavoxelSystem::render() {
glDisableClientState(GL_VERTEX_ARRAY);
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false);
TextureCache::getInstance()->setPrimaryDrawBuffers(true, false);
}
_hermiteBatches.clear();
@ -797,7 +797,7 @@ void MetavoxelSystem::applyMaterialEdit(const MetavoxelEditMessage& message, boo
Q_ARG(bool, reliable));
return;
}
QSharedPointer<NetworkTexture> texture = Application::getInstance()->getTextureCache()->getTexture(
QSharedPointer<NetworkTexture> texture = TextureCache::getInstance()->getTexture(
material->getDiffuse(), SPLAT_TEXTURE);
if (texture->isLoaded()) {
MetavoxelEditMessage newMessage = message;
@ -1180,7 +1180,7 @@ void VoxelBuffer::render(bool cursor) {
for (int i = 0; i < _materials.size(); i++) {
const SharedObjectPointer material = _materials.at(i);
if (material) {
_networkTextures[i] = Application::getInstance()->getTextureCache()->getTexture(
_networkTextures[i] = TextureCache::getInstance()->getTexture(
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++) {
const SharedObjectPointer& material = materials.at(i);
if (material) {
_networkTextures[i] = Application::getInstance()->getTextureCache()->getTexture(
_networkTextures[i] = TextureCache::getInstance()->getTexture(
static_cast<MaterialObject*>(material.data())->getDiffuse(), SPLAT_TEXTURE);
}
}

View file

@ -473,7 +473,7 @@ void ModelUploader::processCheck() {
QMessageBox::Ok);
Application::getInstance()->getGeometryCache()->refresh(_url);
foreach (const QByteArray& filename, _textureFilenames) {
Application::getInstance()->getTextureCache()->refresh(_textureBase + filename);
TextureCache::getInstance()->refresh(_textureBase + filename);
}
deleteLater();
break;

View file

@ -449,7 +449,7 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p
if (Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)) {
Application::getInstance()->getGlowEffect()->prepare();
} else {
Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject()->bind();
TextureCache::getInstance()->getPrimaryFramebufferObject()->bind();
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);
glBindTexture(GL_TEXTURE_2D, fbo->texture());
} else {
Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject()->release();
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject()->texture());
TextureCache::getInstance()->getPrimaryFramebufferObject()->release();
glBindTexture(GL_TEXTURE_2D, TextureCache::getInstance()->getPrimaryFramebufferObject()->texture());
}
// restore our normal viewport

View file

@ -98,7 +98,7 @@ void AmbientOcclusionEffect::render() {
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryDepthTextureID());
glBindTexture(GL_TEXTURE_2D, TextureCache::getInstance()->getPrimaryDepthTextureID());
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, _rotationTextureID);
@ -116,7 +116,7 @@ void AmbientOcclusionEffect::render() {
glGetIntegerv(GL_VIEWPORT, viewport);
const int VIEWPORT_X_INDEX = 0;
const int VIEWPORT_WIDTH_INDEX = 2;
QOpenGLFramebufferObject* primaryFBO = Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject();
QOpenGLFramebufferObject* primaryFBO = TextureCache::getInstance()->getPrimaryFramebufferObject();
float sMin = viewport[VIEWPORT_X_INDEX] / (float)primaryFBO->width();
float sWidth = viewport[VIEWPORT_WIDTH_INDEX] / (float)primaryFBO->width();
@ -141,7 +141,7 @@ void AmbientOcclusionEffect::render() {
glActiveTexture(GL_TEXTURE0);
// now render secondary to primary with 4x4 blur
Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject()->bind();
TextureCache::getInstance()->getPrimaryFramebufferObject()->bind();
glEnable(GL_BLEND);
glBlendFuncSeparate(GL_ZERO, GL_SRC_COLOR, GL_ZERO, GL_ONE);

View file

@ -37,7 +37,7 @@ void DeferredLightingEffect::init() {
}
void DeferredLightingEffect::bindSimpleProgram() {
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, true, true);
TextureCache::getInstance()->setPrimaryDrawBuffers(true, true, true);
_simpleProgram.bind();
_simpleProgram.setUniformValue(_glowIntensityLocation, Application::getInstance()->getGlowEffect()->getIntensity());
glDisable(GL_BLEND);
@ -46,7 +46,7 @@ void DeferredLightingEffect::bindSimpleProgram() {
void DeferredLightingEffect::releaseSimpleProgram() {
glEnable(GL_BLEND);
_simpleProgram.release();
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false, false);
TextureCache::getInstance()->setPrimaryDrawBuffers(true, false, false);
}
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() {
// clear the normal and specular buffers
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(false, true, false);
TextureCache::getInstance()->setPrimaryDrawBuffers(false, true, false);
glClear(GL_COLOR_BUFFER_BIT);
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(false, false, true);
TextureCache::getInstance()->setPrimaryDrawBuffers(false, false, true);
// 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;
glClearColor(0.0f, 0.0f, 0.0f, 1.0f / MAX_SPECULAR_EXPONENT);
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false, false);
TextureCache::getInstance()->setPrimaryDrawBuffers(true, false, false);
}
void DeferredLightingEffect::render() {
@ -138,7 +138,7 @@ void DeferredLightingEffect::render() {
glDisable(GL_COLOR_MATERIAL);
glDepthMask(false);
QOpenGLFramebufferObject* primaryFBO = Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject();
QOpenGLFramebufferObject* primaryFBO = TextureCache::getInstance()->getPrimaryFramebufferObject();
primaryFBO->release();
QOpenGLFramebufferObject* freeFBO = Application::getInstance()->getGlowEffect()->getFreeFramebufferObject();
@ -148,13 +148,13 @@ void DeferredLightingEffect::render() {
glBindTexture(GL_TEXTURE_2D, primaryFBO->texture());
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryNormalTextureID());
glBindTexture(GL_TEXTURE_2D, TextureCache::getInstance()->getPrimaryNormalTextureID());
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimarySpecularTextureID());
glBindTexture(GL_TEXTURE_2D, TextureCache::getInstance()->getPrimarySpecularTextureID());
glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryDepthTextureID());
glBindTexture(GL_TEXTURE_2D, TextureCache::getInstance()->getPrimaryDepthTextureID());
// get the viewport side (left, right, both)
int viewport[4];
@ -173,7 +173,7 @@ void DeferredLightingEffect::render() {
bool shadowsEnabled = Menu::getInstance()->getShadowsEnabled();
if (shadowsEnabled) {
glActiveTexture(GL_TEXTURE4);
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getShadowDepthTextureID());
glBindTexture(GL_TEXTURE_2D, TextureCache::getInstance()->getShadowDepthTextureID());
program = &_directionalLightShadowMap;
locations = &_directionalLightShadowMapLocations;
@ -188,7 +188,7 @@ void DeferredLightingEffect::render() {
program->bind();
}
program->setUniformValue(locations->shadowScale,
1.0f / Application::getInstance()->getTextureCache()->getShadowFramebufferObject()->width());
1.0f / TextureCache::getInstance()->getShadowFramebufferObject()->width());
} else {
program->bind();

View file

@ -41,8 +41,8 @@ GlowEffect::~GlowEffect() {
QOpenGLFramebufferObject* GlowEffect::getFreeFramebufferObject() const {
return (_isOddFrame ?
Application::getInstance()->getTextureCache()->getSecondaryFramebufferObject():
Application::getInstance()->getTextureCache()->getTertiaryFramebufferObject());
TextureCache::getInstance()->getSecondaryFramebufferObject():
TextureCache::getInstance()->getTertiaryFramebufferObject());
}
static ProgramObject* createProgram(const QString& name) {
@ -88,7 +88,7 @@ void GlowEffect::init() {
}
void GlowEffect::prepare() {
Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject()->bind();
TextureCache::getInstance()->getPrimaryFramebufferObject()->bind();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
_isEmpty = true;
@ -122,7 +122,7 @@ static void maybeRelease(QOpenGLFramebufferObject* fbo) {
QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
PerformanceTimer perfTimer("glowEffect");
QOpenGLFramebufferObject* primaryFBO = Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject();
QOpenGLFramebufferObject* primaryFBO = TextureCache::getInstance()->getPrimaryFramebufferObject();
primaryFBO->release();
glBindTexture(GL_TEXTURE_2D, primaryFBO->texture());
@ -138,7 +138,7 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
glDepthMask(GL_FALSE);
QOpenGLFramebufferObject* destFBO = toTexture ?
Application::getInstance()->getTextureCache()->getSecondaryFramebufferObject() : NULL;
TextureCache::getInstance()->getSecondaryFramebufferObject() : NULL;
if (!Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect) || _isEmpty) {
// copy the primary to the screen
if (destFBO && QOpenGLFramebufferObject::hasOpenGLFramebufferBlit()) {
@ -160,9 +160,9 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
} else {
// diffuse into the secondary/tertiary (alternating between frames)
QOpenGLFramebufferObject* oldDiffusedFBO =
Application::getInstance()->getTextureCache()->getSecondaryFramebufferObject();
TextureCache::getInstance()->getSecondaryFramebufferObject();
QOpenGLFramebufferObject* newDiffusedFBO =
Application::getInstance()->getTextureCache()->getTertiaryFramebufferObject();
TextureCache::getInstance()->getTertiaryFramebufferObject();
if (_isOddFrame) {
qSwap(oldDiffusedFBO, newDiffusedFBO);
}

View file

@ -749,7 +749,7 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) {
}
/*Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(
/*TextureCache::getInstance()->setPrimaryDrawBuffers(
mode == DEFAULT_RENDER_MODE || mode == DIFFUSE_RENDER_MODE,
mode == DEFAULT_RENDER_MODE || mode == NORMAL_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);
// render translucent meshes afterwards
//Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(false, true, true);
//TextureCache::getInstance()->setPrimaryDrawBuffers(false, true, true);
{
GLenum buffers[2];
int bufferCount = 0;
@ -814,7 +814,7 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) {
GLBATCH(glDepthMask)(false);
GLBATCH(glDepthFunc)(GL_LEQUAL);
//Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true);
//TextureCache::getInstance()->setPrimaryDrawBuffers(true);
{
GLenum buffers[1];
int bufferCount = 0;
@ -1705,7 +1705,7 @@ void Model::endScene(RenderMode mode, RenderArgs* args) {
}
/*Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(
/*TextureCache::getInstance()->setPrimaryDrawBuffers(
mode == DEFAULT_RENDER_MODE || mode == DIFFUSE_RENDER_MODE,
mode == DEFAULT_RENDER_MODE || mode == NORMAL_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);
// render translucent meshes afterwards
//Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(false, true, true);
//TextureCache::getInstance()->setPrimaryDrawBuffers(false, true, true);
{
GLenum buffers[2];
int bufferCount = 0;
@ -1770,7 +1770,7 @@ void Model::endScene(RenderMode mode, RenderArgs* args) {
GLBATCH(glDepthMask)(false);
GLBATCH(glDepthFunc)(GL_LEQUAL);
//Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true);
//TextureCache::getInstance()->setPrimaryDrawBuffers(true);
{
GLenum buffers[1];
int bufferCount = 0;
@ -2446,7 +2446,7 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
if (showDiffuse && diffuseMap) {
GLBATCH(glBindTexture)(GL_TEXTURE_2D, diffuseMap->getID());
} else {
GLBATCH(glBindTexture)(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getWhiteTextureID());
GLBATCH(glBindTexture)(GL_TEXTURE_2D, TextureCache::getInstance()->getWhiteTextureID());
}
if (locations->texcoordMatrices >= 0) {
@ -2464,7 +2464,7 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
GLBATCH(glActiveTexture)(GL_TEXTURE1);
Texture* normalMap = networkPart.normalTexture.data();
GLBATCH(glBindTexture)(GL_TEXTURE_2D, !normalMap ?
Application::getInstance()->getTextureCache()->getBlueTextureID() : normalMap->getID());
TextureCache::getInstance()->getBlueTextureID() : normalMap->getID());
GLBATCH(glActiveTexture)(GL_TEXTURE0);
}
@ -2472,7 +2472,7 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
GLBATCH(glActiveTexture)(GL_TEXTURE0 + locations->specularTextureUnit);
Texture* specularMap = networkPart.specularTexture.data();
GLBATCH(glBindTexture)(GL_TEXTURE_2D, !specularMap ?
Application::getInstance()->getTextureCache()->getWhiteTextureID() : specularMap->getID());
TextureCache::getInstance()->getWhiteTextureID() : specularMap->getID());
GLBATCH(glActiveTexture)(GL_TEXTURE0);
}
@ -2493,7 +2493,7 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
GLBATCH(glActiveTexture)(GL_TEXTURE0 + locations->emissiveTextureUnit);
Texture* emissiveMap = networkPart.emissiveTexture.data();
GLBATCH(glBindTexture)(GL_TEXTURE_2D, !emissiveMap ?
Application::getInstance()->getTextureCache()->getWhiteTextureID() : emissiveMap->getID());
TextureCache::getInstance()->getWhiteTextureID() : emissiveMap->getID());
GLBATCH(glActiveTexture)(GL_TEXTURE0);
}

View file

@ -916,7 +916,7 @@ void MaterialControl::updateTexture() {
_texture.clear();
return;
}
_texture = Application::getInstance()->getTextureCache()->getTexture(material->getDiffuse(), SPLAT_TEXTURE);
_texture = TextureCache::getInstance()->getTexture(material->getDiffuse(), SPLAT_TEXTURE);
if (_texture) {
if (_texture->isLoaded()) {
textureLoaded();

View file

@ -1171,7 +1171,7 @@ void VoxelSystem::render() {
void VoxelSystem::applyScaleAndBindProgram(bool texture) {
if (texture) {
bindPerlinModulateProgram();
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPermutationNormalTextureID());
glBindTexture(GL_TEXTURE_2D, TextureCache::getInstance()->getPermutationNormalTextureID());
} else {
_program.bind();
}
@ -1179,7 +1179,7 @@ void VoxelSystem::applyScaleAndBindProgram(bool texture) {
glPushMatrix();
glScalef(_treeScale, _treeScale, _treeScale);
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, true);
TextureCache::getInstance()->setPrimaryDrawBuffers(true, true);
}
void VoxelSystem::removeScaleAndReleaseProgram(bool texture) {
@ -1193,7 +1193,7 @@ void VoxelSystem::removeScaleAndReleaseProgram(bool texture) {
_program.release();
}
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false);
TextureCache::getInstance()->setPrimaryDrawBuffers(true, false);
}
int VoxelSystem::_nodeCount = 0;