mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 02:44:30 +02:00
Merge pull request #3966 from ZappoMan/untangling
Untangling - step toward librarization
This commit is contained in:
commit
78a61cd48b
25 changed files with 214 additions and 165 deletions
|
@ -194,7 +194,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
_isVSyncOn(true),
|
_isVSyncOn(true),
|
||||||
_aboutToQuit(false)
|
_aboutToQuit(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
// read the ApplicationInfo.ini file for Name/Version/Domain information
|
// read the ApplicationInfo.ini file for Name/Version/Domain information
|
||||||
QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
|
QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
|
||||||
|
|
||||||
|
@ -621,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.setFrameBufferSize(OculusManager::getRenderTargetSize());
|
DependencyManager::get<TextureCache>()->setFrameBufferSize(OculusManager::getRenderTargetSize());
|
||||||
} else {
|
} else {
|
||||||
QSize fbSize = _glWidget->getDeviceSize() * getRenderResolutionScale();
|
QSize fbSize = _glWidget->getDeviceSize() * getRenderResolutionScale();
|
||||||
_textureCache.setFrameBufferSize(fbSize);
|
DependencyManager::get<TextureCache>()->setFrameBufferSize(fbSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnable(GL_LINE_SMOOTH);
|
glEnable(GL_LINE_SMOOTH);
|
||||||
|
@ -714,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 = Application::getInstance()->getTextureCache()->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);
|
||||||
|
@ -2042,6 +2041,9 @@ void Application::init() {
|
||||||
|
|
||||||
// save settings when avatar changes
|
// save settings when avatar changes
|
||||||
connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);
|
connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);
|
||||||
|
|
||||||
|
// make sure our texture cache knows about window size changes
|
||||||
|
DependencyManager::get<TextureCache>()->associateWithWidget(getGLWidget());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::closeMirrorView() {
|
void Application::closeMirrorView() {
|
||||||
|
@ -2772,7 +2774,7 @@ glm::vec3 Application::getSunDirection() {
|
||||||
|
|
||||||
void Application::updateShadowMap() {
|
void Application::updateShadowMap() {
|
||||||
PerformanceTimer perfTimer("shadowMap");
|
PerformanceTimer perfTimer("shadowMap");
|
||||||
QOpenGLFramebufferObject* fbo = _textureCache.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);
|
||||||
|
@ -2937,7 +2939,7 @@ void Application::setupWorldLight() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage Application::renderAvatarBillboard() {
|
QImage Application::renderAvatarBillboard() {
|
||||||
_textureCache.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;
|
||||||
|
@ -2948,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.getPrimaryFramebufferObject()->release();
|
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->release();
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
@ -3078,7 +3080,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
|
||||||
// draw a red sphere
|
// draw a red sphere
|
||||||
float originSphereRadius = 0.05f;
|
float originSphereRadius = 0.05f;
|
||||||
glColor3f(1,0,0);
|
glColor3f(1,0,0);
|
||||||
_geometryCache.renderSphere(originSphereRadius, 15, 15);
|
DependencyManager::get<GeometryCache>()->renderSphere(originSphereRadius, 15, 15);
|
||||||
|
|
||||||
// Draw voxels
|
// Draw voxels
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
|
||||||
|
@ -3299,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 = getTextureCache()->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 = getTextureCache()->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);
|
||||||
|
|
|
@ -34,9 +34,9 @@
|
||||||
#include <EntityEditPacketSender.h>
|
#include <EntityEditPacketSender.h>
|
||||||
#include <NetworkPacket.h>
|
#include <NetworkPacket.h>
|
||||||
#include <NodeList.h>
|
#include <NodeList.h>
|
||||||
|
#include <OctreeQuery.h>
|
||||||
#include <PacketHeaders.h>
|
#include <PacketHeaders.h>
|
||||||
#include <ScriptEngine.h>
|
#include <ScriptEngine.h>
|
||||||
#include <OctreeQuery.h>
|
|
||||||
#include <ViewFrustum.h>
|
#include <ViewFrustum.h>
|
||||||
#include <VoxelEditPacketSender.h>
|
#include <VoxelEditPacketSender.h>
|
||||||
|
|
||||||
|
@ -249,9 +249,7 @@ public:
|
||||||
|
|
||||||
ToolWindow* getToolWindow() { return _toolWindow ; }
|
ToolWindow* getToolWindow() { return _toolWindow ; }
|
||||||
|
|
||||||
GeometryCache* getGeometryCache() { return &_geometryCache; }
|
|
||||||
AnimationCache* getAnimationCache() { return &_animationCache; }
|
AnimationCache* getAnimationCache() { return &_animationCache; }
|
||||||
TextureCache* getTextureCache() { return &_textureCache; }
|
|
||||||
DeferredLightingEffect* getDeferredLightingEffect() { return &_deferredLightingEffect; }
|
DeferredLightingEffect* getDeferredLightingEffect() { return &_deferredLightingEffect; }
|
||||||
GlowEffect* getGlowEffect() { return &_glowEffect; }
|
GlowEffect* getGlowEffect() { return &_glowEffect; }
|
||||||
ControllerScriptingInterface* getControllerScriptingInterface() { return &_controllerScriptingInterface; }
|
ControllerScriptingInterface* getControllerScriptingInterface() { return &_controllerScriptingInterface; }
|
||||||
|
@ -569,9 +567,7 @@ private:
|
||||||
QSet<int> _keysPressed;
|
QSet<int> _keysPressed;
|
||||||
|
|
||||||
|
|
||||||
GeometryCache _geometryCache;
|
|
||||||
AnimationCache _animationCache;
|
AnimationCache _animationCache;
|
||||||
TextureCache _textureCache;
|
|
||||||
|
|
||||||
DeferredLightingEffect _deferredLightingEffect;
|
DeferredLightingEffect _deferredLightingEffect;
|
||||||
GlowEffect _glowEffect;
|
GlowEffect _glowEffect;
|
||||||
|
|
|
@ -261,7 +261,7 @@ void Environment::renderAtmosphere(Camera& camera, const EnvironmentData& data)
|
||||||
|
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(1.0f, 100, 50); //Draw a unit sphere
|
DependencyManager::get<GeometryCache>()->renderSphere(1.0f, 100, 50); //Draw a unit sphere
|
||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
|
|
||||||
program->release();
|
program->release();
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
Application::getInstance()->getTextureCache()->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();
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::getInstance()->getTextureCache()->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()) {
|
||||||
Application::getInstance()->getTextureCache()->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);
|
||||||
|
|
||||||
Application::getInstance()->getTextureCache()->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)) {
|
||||||
Application::getInstance()->getTextureCache()->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);
|
||||||
|
|
||||||
Application::getInstance()->getTextureCache()->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 = Application::getInstance()->getTextureCache()->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;
|
||||||
|
@ -1177,10 +1177,11 @@ void VoxelBuffer::render(bool cursor) {
|
||||||
|
|
||||||
if (!_materials.isEmpty()) {
|
if (!_materials.isEmpty()) {
|
||||||
_networkTextures.resize(_materials.size());
|
_networkTextures.resize(_materials.size());
|
||||||
|
TextureCache* textureCache = DependencyManager::get<TextureCache>();
|
||||||
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] = Application::getInstance()->getTextureCache()->getTexture(
|
_networkTextures[i] = textureCache->getTexture(
|
||||||
static_cast<MaterialObject*>(material.data())->getDiffuse(), SPLAT_TEXTURE);
|
static_cast<MaterialObject*>(material.data())->getDiffuse(), SPLAT_TEXTURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2231,10 +2232,11 @@ void HeightfieldNodeRenderer::render(const HeightfieldNodePointer& node, const g
|
||||||
|
|
||||||
const QVector<SharedObjectPointer>& materials = node->getMaterial()->getMaterials();
|
const QVector<SharedObjectPointer>& materials = node->getMaterial()->getMaterials();
|
||||||
_networkTextures.resize(materials.size());
|
_networkTextures.resize(materials.size());
|
||||||
|
TextureCache* textureCache = DependencyManager::get<TextureCache>();
|
||||||
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] = Application::getInstance()->getTextureCache()->getTexture(
|
_networkTextures[i] = textureCache->getTexture(
|
||||||
static_cast<MaterialObject*>(material.data())->getDiffuse(), SPLAT_TEXTURE);
|
static_cast<MaterialObject*>(material.data())->getDiffuse(), SPLAT_TEXTURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -466,17 +466,19 @@ void ModelUploader::processCheck() {
|
||||||
_timer.stop();
|
_timer.stop();
|
||||||
|
|
||||||
switch (reply->error()) {
|
switch (reply->error()) {
|
||||||
case QNetworkReply::NoError:
|
case QNetworkReply::NoError: {
|
||||||
QMessageBox::information(NULL,
|
QMessageBox::information(NULL,
|
||||||
QString("ModelUploader::processCheck()"),
|
QString("ModelUploader::processCheck()"),
|
||||||
QString("Your model is now available in the browser."),
|
QString("Your model is now available in the browser."),
|
||||||
QMessageBox::Ok);
|
QMessageBox::Ok);
|
||||||
Application::getInstance()->getGeometryCache()->refresh(_url);
|
DependencyManager::get<GeometryCache>()->refresh(_url);
|
||||||
|
TextureCache* textureCache = DependencyManager::get<TextureCache>();
|
||||||
foreach (const QByteArray& filename, _textureFilenames) {
|
foreach (const QByteArray& filename, _textureFilenames) {
|
||||||
Application::getInstance()->getTextureCache()->refresh(_textureBase + filename);
|
textureCache->refresh(_textureBase + filename);
|
||||||
}
|
}
|
||||||
deleteLater();
|
deleteLater();
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case QNetworkReply::ContentNotFoundError:
|
case QNetworkReply::ContentNotFoundError:
|
||||||
if (--_numberOfChecks) {
|
if (--_numberOfChecks) {
|
||||||
_timer.start(TIMEOUT);
|
_timer.start(TIMEOUT);
|
||||||
|
|
|
@ -71,22 +71,23 @@ void renderWorldBox() {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(MARKER_DISTANCE, 0, 0);
|
glTranslatef(MARKER_DISTANCE, 0, 0);
|
||||||
glColor3fv(red);
|
glColor3fv(red);
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(MARKER_RADIUS, 10, 10);
|
GeometryCache* geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
|
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(0, MARKER_DISTANCE, 0);
|
glTranslatef(0, MARKER_DISTANCE, 0);
|
||||||
glColor3fv(green);
|
glColor3fv(green);
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(MARKER_RADIUS, 10, 10);
|
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(0, 0, MARKER_DISTANCE);
|
glTranslatef(0, 0, MARKER_DISTANCE);
|
||||||
glColor3fv(blue);
|
glColor3fv(blue);
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(MARKER_RADIUS, 10, 10);
|
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glColor3fv(gray);
|
glColor3fv(gray);
|
||||||
glTranslatef(MARKER_DISTANCE, 0, MARKER_DISTANCE);
|
glTranslatef(MARKER_DISTANCE, 0, MARKER_DISTANCE);
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(MARKER_RADIUS, 10, 10);
|
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -394,7 +394,7 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bool
|
||||||
} else {
|
} else {
|
||||||
glTranslatef(_position.x, getDisplayNamePosition().y + LOOK_AT_INDICATOR_OFFSET, _position.z);
|
glTranslatef(_position.x, getDisplayNamePosition().y + LOOK_AT_INDICATOR_OFFSET, _position.z);
|
||||||
}
|
}
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(LOOK_AT_INDICATOR_RADIUS, 15, 15);
|
DependencyManager::get<GeometryCache>()->renderSphere(LOOK_AT_INDICATOR_RADIUS, 15, 15);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -422,7 +422,7 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bool
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(_position.x, _position.y, _position.z);
|
glTranslatef(_position.x, _position.y, _position.z);
|
||||||
glScalef(height, height, height);
|
glScalef(height, height, height);
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(sphereRadius, 15, 15);
|
DependencyManager::get<GeometryCache>()->renderSphere(sphereRadius, 15, 15);
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ void Hand::render(bool isMine, Model::RenderMode renderMode) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(position.x, position.y, position.z);
|
glTranslatef(position.x, position.y, position.z);
|
||||||
glColor3f(0.0f, 1.0f, 0.0f);
|
glColor3f(0.0f, 1.0f, 0.0f);
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(PALM_COLLISION_RADIUS * _owningAvatar->getScale(), 10, 10);
|
DependencyManager::get<GeometryCache>()->renderSphere(PALM_COLLISION_RADIUS * _owningAvatar->getScale(), 10, 10);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ void Hand::renderHandTargets(bool isMine) {
|
||||||
Avatar::renderJointConnectingCone(root, offsetFromPalm, PALM_DISK_RADIUS, 0.0f);
|
Avatar::renderJointConnectingCone(root, offsetFromPalm, PALM_DISK_RADIUS, 0.0f);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(root.x, root.y, root.z);
|
glTranslatef(root.x, root.y, root.z);
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(PALM_BALL_RADIUS, 20.0f, 20.0f);
|
DependencyManager::get<GeometryCache>()->renderSphere(PALM_BALL_RADIUS, 20.0f, 20.0f);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -394,7 +394,7 @@ void MyAvatar::renderDebugBodyPoints() {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glColor4f(0, 1, 0, .5f);
|
glColor4f(0, 1, 0, .5f);
|
||||||
glTranslatef(position.x, position.y, position.z);
|
glTranslatef(position.x, position.y, position.z);
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(0.2f, 10.0f, 10.0f);
|
DependencyManager::get<GeometryCache>()->renderSphere(0.2f, 10.0f, 10.0f);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
// Head Sphere
|
// Head Sphere
|
||||||
|
@ -402,7 +402,7 @@ void MyAvatar::renderDebugBodyPoints() {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glColor4f(0, 1, 0, .5f);
|
glColor4f(0, 1, 0, .5f);
|
||||||
glTranslatef(position.x, position.y, position.z);
|
glTranslatef(position.x, position.y, position.z);
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(0.15f, 10.0f, 10.0f);
|
DependencyManager::get<GeometryCache>()->renderSphere(0.15f, 10.0f, 10.0f);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -554,6 +554,7 @@ void SkeletonModel::renderRagdoll() {
|
||||||
float radius1 = 0.008f;
|
float radius1 = 0.008f;
|
||||||
float radius2 = 0.01f;
|
float radius2 = 0.01f;
|
||||||
glm::vec3 simulationTranslation = _ragdoll->getTranslationInSimulationFrame();
|
glm::vec3 simulationTranslation = _ragdoll->getTranslationInSimulationFrame();
|
||||||
|
GeometryCache* geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
for (int i = 0; i < numPoints; ++i) {
|
for (int i = 0; i < numPoints; ++i) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
// NOTE: ragdollPoints are in simulation-frame but we want them to be model-relative
|
// NOTE: ragdollPoints are in simulation-frame but we want them to be model-relative
|
||||||
|
@ -561,9 +562,9 @@ void SkeletonModel::renderRagdoll() {
|
||||||
glTranslatef(position.x, position.y, position.z);
|
glTranslatef(position.x, position.y, position.z);
|
||||||
// draw each point as a yellow hexagon with black border
|
// draw each point as a yellow hexagon with black border
|
||||||
glColor4f(0.0f, 0.0f, 0.0f, alpha);
|
glColor4f(0.0f, 0.0f, 0.0f, alpha);
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(radius2, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
geometryCache->renderSphere(radius2, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||||
glColor4f(1.0f, 1.0f, 0.0f, alpha);
|
glColor4f(1.0f, 1.0f, 0.0f, alpha);
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(radius1, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
geometryCache->renderSphere(radius1, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
@ -913,7 +914,8 @@ void SkeletonModel::renderBoundingCollisionShapes(float alpha) {
|
||||||
endPoint = endPoint - _translation;
|
endPoint = endPoint - _translation;
|
||||||
glTranslatef(endPoint.x, endPoint.y, endPoint.z);
|
glTranslatef(endPoint.x, endPoint.y, endPoint.z);
|
||||||
glColor4f(0.6f, 0.6f, 0.8f, alpha);
|
glColor4f(0.6f, 0.6f, 0.8f, alpha);
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
GeometryCache* geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
|
geometryCache->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||||
|
|
||||||
// draw a yellow sphere at the capsule startpoint
|
// draw a yellow sphere at the capsule startpoint
|
||||||
glm::vec3 startPoint;
|
glm::vec3 startPoint;
|
||||||
|
@ -922,7 +924,7 @@ void SkeletonModel::renderBoundingCollisionShapes(float alpha) {
|
||||||
glm::vec3 axis = endPoint - startPoint;
|
glm::vec3 axis = endPoint - startPoint;
|
||||||
glTranslatef(-axis.x, -axis.y, -axis.z);
|
glTranslatef(-axis.x, -axis.y, -axis.z);
|
||||||
glColor4f(0.8f, 0.8f, 0.6f, alpha);
|
glColor4f(0.8f, 0.8f, 0.6f, alpha);
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
geometryCache->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||||
|
|
||||||
// draw a green cylinder between the two points
|
// draw a green cylinder between the two points
|
||||||
glm::vec3 origin(0.0f);
|
glm::vec3 origin(0.0f);
|
||||||
|
@ -948,6 +950,8 @@ void SkeletonModel::renderJointCollisionShapes(float alpha) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GeometryCache* geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
// shapes are stored in simulation-frame but we want position to be model-relative
|
// shapes are stored in simulation-frame but we want position to be model-relative
|
||||||
if (shape->getType() == SPHERE_SHAPE) {
|
if (shape->getType() == SPHERE_SHAPE) {
|
||||||
|
@ -955,7 +959,7 @@ void SkeletonModel::renderJointCollisionShapes(float alpha) {
|
||||||
glTranslatef(position.x, position.y, position.z);
|
glTranslatef(position.x, position.y, position.z);
|
||||||
// draw a grey sphere at shape position
|
// draw a grey sphere at shape position
|
||||||
glColor4f(0.75f, 0.75f, 0.75f, alpha);
|
glColor4f(0.75f, 0.75f, 0.75f, alpha);
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(shape->getBoundingRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
geometryCache->renderSphere(shape->getBoundingRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||||
} else if (shape->getType() == CAPSULE_SHAPE) {
|
} else if (shape->getType() == CAPSULE_SHAPE) {
|
||||||
CapsuleShape* capsule = static_cast<CapsuleShape*>(shape);
|
CapsuleShape* capsule = static_cast<CapsuleShape*>(shape);
|
||||||
|
|
||||||
|
@ -965,7 +969,7 @@ void SkeletonModel::renderJointCollisionShapes(float alpha) {
|
||||||
endPoint = endPoint - simulationTranslation;
|
endPoint = endPoint - simulationTranslation;
|
||||||
glTranslatef(endPoint.x, endPoint.y, endPoint.z);
|
glTranslatef(endPoint.x, endPoint.y, endPoint.z);
|
||||||
glColor4f(0.6f, 0.6f, 0.8f, alpha);
|
glColor4f(0.6f, 0.6f, 0.8f, alpha);
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
geometryCache->renderSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||||
|
|
||||||
// draw a yellow sphere at the capsule startpoint
|
// draw a yellow sphere at the capsule startpoint
|
||||||
glm::vec3 startPoint;
|
glm::vec3 startPoint;
|
||||||
|
@ -974,7 +978,7 @@ void SkeletonModel::renderJointCollisionShapes(float alpha) {
|
||||||
glm::vec3 axis = endPoint - startPoint;
|
glm::vec3 axis = endPoint - startPoint;
|
||||||
glTranslatef(-axis.x, -axis.y, -axis.z);
|
glTranslatef(-axis.x, -axis.y, -axis.z);
|
||||||
glColor4f(0.8f, 0.8f, 0.6f, alpha);
|
glColor4f(0.8f, 0.8f, 0.6f, alpha);
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
geometryCache->renderSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||||
|
|
||||||
// draw a green cylinder between the two points
|
// draw a green cylinder between the two points
|
||||||
glm::vec3 origin(0.0f);
|
glm::vec3 origin(0.0f);
|
||||||
|
|
|
@ -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 {
|
||||||
Application::getInstance()->getTextureCache()->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 {
|
||||||
Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject()->release();
|
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->release();
|
||||||
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->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, Application::getInstance()->getTextureCache()->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 = Application::getInstance()->getTextureCache()->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
|
||||||
Application::getInstance()->getTextureCache()->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() {
|
||||||
Application::getInstance()->getTextureCache()->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,12 +46,12 @@ void DeferredLightingEffect::bindSimpleProgram() {
|
||||||
void DeferredLightingEffect::releaseSimpleProgram() {
|
void DeferredLightingEffect::releaseSimpleProgram() {
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
_simpleProgram.release();
|
_simpleProgram.release();
|
||||||
Application::getInstance()->getTextureCache()->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) {
|
||||||
bindSimpleProgram();
|
bindSimpleProgram();
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(radius, slices, stacks);
|
DependencyManager::get<GeometryCache>()->renderSphere(radius, slices, stacks);
|
||||||
releaseSimpleProgram();
|
releaseSimpleProgram();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ void DeferredLightingEffect::renderWireCube(float size) {
|
||||||
|
|
||||||
void DeferredLightingEffect::renderSolidCone(float base, float height, int slices, int stacks) {
|
void DeferredLightingEffect::renderSolidCone(float base, float height, int slices, int stacks) {
|
||||||
bindSimpleProgram();
|
bindSimpleProgram();
|
||||||
Application::getInstance()->getGeometryCache()->renderCone(base, height, slices, stacks);
|
DependencyManager::get<GeometryCache>()->renderCone(base, height, slices, stacks);
|
||||||
releaseSimpleProgram();
|
releaseSimpleProgram();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,15 +117,16 @@ 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
|
||||||
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(false, true, false);
|
TextureCache* textureCache = DependencyManager::get<TextureCache>();
|
||||||
|
textureCache->setPrimaryDrawBuffers(false, true, false);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(false, false, true);
|
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);
|
||||||
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false, false);
|
textureCache->setPrimaryDrawBuffers(true, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredLightingEffect::render() {
|
void DeferredLightingEffect::render() {
|
||||||
|
@ -137,8 +138,10 @@ void DeferredLightingEffect::render() {
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_COLOR_MATERIAL);
|
glDisable(GL_COLOR_MATERIAL);
|
||||||
glDepthMask(false);
|
glDepthMask(false);
|
||||||
|
|
||||||
|
TextureCache* textureCache = DependencyManager::get<TextureCache>();
|
||||||
|
|
||||||
QOpenGLFramebufferObject* primaryFBO = Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject();
|
QOpenGLFramebufferObject* primaryFBO = textureCache->getPrimaryFramebufferObject();
|
||||||
primaryFBO->release();
|
primaryFBO->release();
|
||||||
|
|
||||||
QOpenGLFramebufferObject* freeFBO = Application::getInstance()->getGlowEffect()->getFreeFramebufferObject();
|
QOpenGLFramebufferObject* freeFBO = Application::getInstance()->getGlowEffect()->getFreeFramebufferObject();
|
||||||
|
@ -148,13 +151,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, Application::getInstance()->getTextureCache()->getPrimaryNormalTextureID());
|
glBindTexture(GL_TEXTURE_2D, textureCache->getPrimaryNormalTextureID());
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE2);
|
glActiveTexture(GL_TEXTURE2);
|
||||||
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimarySpecularTextureID());
|
glBindTexture(GL_TEXTURE_2D, textureCache->getPrimarySpecularTextureID());
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE3);
|
glActiveTexture(GL_TEXTURE3);
|
||||||
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryDepthTextureID());
|
glBindTexture(GL_TEXTURE_2D, textureCache->getPrimaryDepthTextureID());
|
||||||
|
|
||||||
// get the viewport side (left, right, both)
|
// get the viewport side (left, right, both)
|
||||||
int viewport[4];
|
int viewport[4];
|
||||||
|
@ -173,7 +176,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, Application::getInstance()->getTextureCache()->getShadowDepthTextureID());
|
glBindTexture(GL_TEXTURE_2D, textureCache->getShadowDepthTextureID());
|
||||||
|
|
||||||
program = &_directionalLightShadowMap;
|
program = &_directionalLightShadowMap;
|
||||||
locations = &_directionalLightShadowMapLocations;
|
locations = &_directionalLightShadowMapLocations;
|
||||||
|
@ -188,7 +191,7 @@ void DeferredLightingEffect::render() {
|
||||||
program->bind();
|
program->bind();
|
||||||
}
|
}
|
||||||
program->setUniformValue(locations->shadowScale,
|
program->setUniformValue(locations->shadowScale,
|
||||||
1.0f / Application::getInstance()->getTextureCache()->getShadowFramebufferObject()->width());
|
1.0f / textureCache->getShadowFramebufferObject()->width());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
program->bind();
|
program->bind();
|
||||||
|
@ -234,6 +237,8 @@ void DeferredLightingEffect::render() {
|
||||||
|
|
||||||
const glm::vec3& eyePoint = Application::getInstance()->getDisplayViewFrustum()->getPosition();
|
const glm::vec3& eyePoint = Application::getInstance()->getDisplayViewFrustum()->getPosition();
|
||||||
float nearRadius = glm::distance(eyePoint, Application::getInstance()->getDisplayViewFrustum()->getNearTopLeft());
|
float nearRadius = glm::distance(eyePoint, Application::getInstance()->getDisplayViewFrustum()->getNearTopLeft());
|
||||||
|
|
||||||
|
GeometryCache* geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
|
|
||||||
if (!_pointLights.isEmpty()) {
|
if (!_pointLights.isEmpty()) {
|
||||||
_pointLight.bind();
|
_pointLight.bind();
|
||||||
|
@ -241,7 +246,7 @@ void DeferredLightingEffect::render() {
|
||||||
_pointLight.setUniformValue(_pointLightLocations.depthScale, depthScale);
|
_pointLight.setUniformValue(_pointLightLocations.depthScale, depthScale);
|
||||||
_pointLight.setUniformValue(_pointLightLocations.depthTexCoordOffset, depthTexCoordOffsetS, depthTexCoordOffsetT);
|
_pointLight.setUniformValue(_pointLightLocations.depthTexCoordOffset, depthTexCoordOffsetS, depthTexCoordOffsetT);
|
||||||
_pointLight.setUniformValue(_pointLightLocations.depthTexCoordScale, depthTexCoordScaleS, depthTexCoordScaleT);
|
_pointLight.setUniformValue(_pointLightLocations.depthTexCoordScale, depthTexCoordScaleS, depthTexCoordScaleT);
|
||||||
|
|
||||||
foreach (const PointLight& light, _pointLights) {
|
foreach (const PointLight& light, _pointLights) {
|
||||||
_pointLight.setUniformValue(_pointLightLocations.radius, light.radius);
|
_pointLight.setUniformValue(_pointLightLocations.radius, light.radius);
|
||||||
glLightfv(GL_LIGHT1, GL_AMBIENT, (const GLfloat*)&light.ambient);
|
glLightfv(GL_LIGHT1, GL_AMBIENT, (const GLfloat*)&light.ambient);
|
||||||
|
@ -270,7 +275,7 @@ void DeferredLightingEffect::render() {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
glTranslatef(light.position.x, light.position.y, light.position.z);
|
glTranslatef(light.position.x, light.position.y, light.position.z);
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(expandedRadius, 32, 32);
|
geometryCache->renderSphere(expandedRadius, 32, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
@ -323,7 +328,7 @@ void DeferredLightingEffect::render() {
|
||||||
glm::vec3 axis = glm::axis(spotRotation);
|
glm::vec3 axis = glm::axis(spotRotation);
|
||||||
glRotatef(glm::degrees(glm::angle(spotRotation)), axis.x, axis.y, axis.z);
|
glRotatef(glm::degrees(glm::angle(spotRotation)), axis.x, axis.y, axis.z);
|
||||||
glTranslatef(0.0f, 0.0f, -light.radius * (1.0f + SCALE_EXPANSION * 0.5f));
|
glTranslatef(0.0f, 0.0f, -light.radius * (1.0f + SCALE_EXPANSION * 0.5f));
|
||||||
Application::getInstance()->getGeometryCache()->renderCone(expandedRadius * glm::tan(light.cutoff),
|
geometryCache->renderCone(expandedRadius * glm::tan(light.cutoff),
|
||||||
expandedRadius, 32, 1);
|
expandedRadius, 32, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,19 +9,21 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
// include this before QOpenGLBuffer, which includes an earlier version of OpenGL
|
||||||
|
#include <gpu/GPUConfig.h>
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QRunnable>
|
#include <QRunnable>
|
||||||
#include <QThreadPool>
|
#include <QThreadPool>
|
||||||
|
|
||||||
#include "Application.h"
|
#include <SharedUtil.h>
|
||||||
#include "GeometryCache.h"
|
|
||||||
#include "Model.h"
|
|
||||||
#include "world.h"
|
|
||||||
|
|
||||||
GeometryCache::GeometryCache() :
|
#include "GeometryCache.h"
|
||||||
_pendingBlenders(0) {
|
#include "TextureCache.h"
|
||||||
|
|
||||||
|
GeometryCache::GeometryCache() {
|
||||||
}
|
}
|
||||||
|
|
||||||
GeometryCache::~GeometryCache() {
|
GeometryCache::~GeometryCache() {
|
||||||
|
@ -505,33 +507,6 @@ QSharedPointer<NetworkGeometry> GeometryCache::getGeometry(const QUrl& url, cons
|
||||||
return getResource(url, fallback, delayLoad).staticCast<NetworkGeometry>();
|
return getResource(url, fallback, delayLoad).staticCast<NetworkGeometry>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeometryCache::noteRequiresBlend(Model* model) {
|
|
||||||
if (_pendingBlenders < QThread::idealThreadCount()) {
|
|
||||||
if (model->maybeStartBlender()) {
|
|
||||||
_pendingBlenders++;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!_modelsRequiringBlends.contains(model)) {
|
|
||||||
_modelsRequiringBlends.append(model);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GeometryCache::setBlendedVertices(const QPointer<Model>& model, int blendNumber,
|
|
||||||
const QWeakPointer<NetworkGeometry>& geometry, const QVector<glm::vec3>& vertices, const QVector<glm::vec3>& normals) {
|
|
||||||
if (!model.isNull()) {
|
|
||||||
model->setBlendedVertices(blendNumber, geometry, vertices, normals);
|
|
||||||
}
|
|
||||||
_pendingBlenders--;
|
|
||||||
while (!_modelsRequiringBlends.isEmpty()) {
|
|
||||||
Model* nextModel = _modelsRequiringBlends.takeFirst();
|
|
||||||
if (nextModel && nextModel->maybeStartBlender()) {
|
|
||||||
_pendingBlenders++;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QSharedPointer<Resource> GeometryCache::createResource(const QUrl& url,
|
QSharedPointer<Resource> GeometryCache::createResource(const QUrl& url,
|
||||||
const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra) {
|
const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra) {
|
||||||
QSharedPointer<NetworkGeometry> geometry(new NetworkGeometry(url, fallback.staticCast<NetworkGeometry>(), delayLoad),
|
QSharedPointer<NetworkGeometry> geometry(new NetworkGeometry(url, fallback.staticCast<NetworkGeometry>(), delayLoad),
|
||||||
|
@ -724,6 +699,7 @@ void NetworkGeometry::clearLoadPriority(const QPointer<QObject>& owner) {
|
||||||
|
|
||||||
void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& url) {
|
void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& url) {
|
||||||
if (_meshes.size() > 0) {
|
if (_meshes.size() > 0) {
|
||||||
|
TextureCache* textureCache = DependencyManager::get<TextureCache>();
|
||||||
for (int i = 0; i < _meshes.size(); i++) {
|
for (int i = 0; i < _meshes.size(); i++) {
|
||||||
NetworkMesh& mesh = _meshes[i];
|
NetworkMesh& mesh = _meshes[i];
|
||||||
for (int j = 0; j < mesh.parts.size(); j++) {
|
for (int j = 0; j < mesh.parts.size(); j++) {
|
||||||
|
@ -732,19 +708,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 =
|
||||||
Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE,
|
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 = Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE,
|
part.normalTexture = 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 = Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE,
|
part.specularTexture = 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 = Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE,
|
part.emissiveTexture = textureCache->getTexture(url, DEFAULT_TEXTURE,
|
||||||
false, QByteArray());
|
false, QByteArray());
|
||||||
part.emissiveTexture->setLoadPriorities(_loadPriorities);
|
part.emissiveTexture->setLoadPriorities(_loadPriorities);
|
||||||
}
|
}
|
||||||
|
@ -937,6 +913,8 @@ void NetworkGeometry::reinsert() {
|
||||||
|
|
||||||
void NetworkGeometry::setGeometry(const FBXGeometry& geometry) {
|
void NetworkGeometry::setGeometry(const FBXGeometry& geometry) {
|
||||||
_geometry = geometry;
|
_geometry = geometry;
|
||||||
|
|
||||||
|
TextureCache* textureCache = DependencyManager::get<TextureCache>();
|
||||||
|
|
||||||
foreach (const FBXMesh& mesh, _geometry.meshes) {
|
foreach (const FBXMesh& mesh, _geometry.meshes) {
|
||||||
NetworkMesh networkMesh;
|
NetworkMesh networkMesh;
|
||||||
|
@ -945,28 +923,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 = Application::getInstance()->getTextureCache()->getTexture(
|
networkPart.diffuseTexture = 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 = Application::getInstance()->getTextureCache()->getTexture(
|
networkPart.normalTexture = 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 = Application::getInstance()->getTextureCache()->getTexture(
|
networkPart.specularTexture = 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 = Application::getInstance()->getTextureCache()->getTexture(
|
networkPart.emissiveTexture = 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;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QOpenGLBuffer>
|
#include <QOpenGLBuffer>
|
||||||
|
|
||||||
|
#include <DependencyManager.h>
|
||||||
#include <ResourceCache.h>
|
#include <ResourceCache.h>
|
||||||
|
|
||||||
#include <FBXReader.h>
|
#include <FBXReader.h>
|
||||||
|
@ -26,20 +27,15 @@
|
||||||
|
|
||||||
#include "gpu/Stream.h"
|
#include "gpu/Stream.h"
|
||||||
|
|
||||||
class Model;
|
|
||||||
class NetworkGeometry;
|
class NetworkGeometry;
|
||||||
class NetworkMesh;
|
class NetworkMesh;
|
||||||
class NetworkTexture;
|
class NetworkTexture;
|
||||||
|
|
||||||
/// Stores cached geometry.
|
/// Stores cached geometry.
|
||||||
class GeometryCache : public ResourceCache {
|
class GeometryCache : public ResourceCache, public DependencyManager::Dependency {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GeometryCache();
|
|
||||||
virtual ~GeometryCache();
|
|
||||||
|
|
||||||
void renderHemisphere(int slices, int stacks);
|
void renderHemisphere(int slices, int stacks);
|
||||||
void renderSphere(float radius, int slices, int stacks);
|
void renderSphere(float radius, int slices, int stacks);
|
||||||
void renderSquare(int xDivisions, int yDivisions);
|
void renderSquare(int xDivisions, int yDivisions);
|
||||||
|
@ -52,20 +48,15 @@ public:
|
||||||
/// \param delayLoad if true, don't load the geometry immediately; wait until load is first requested
|
/// \param delayLoad if true, don't load the geometry immediately; wait until load is first requested
|
||||||
QSharedPointer<NetworkGeometry> getGeometry(const QUrl& url, const QUrl& fallback = QUrl(), bool delayLoad = false);
|
QSharedPointer<NetworkGeometry> getGeometry(const QUrl& url, const QUrl& fallback = QUrl(), bool delayLoad = false);
|
||||||
|
|
||||||
/// Adds the specified model to the list requiring vertex blends.
|
|
||||||
void noteRequiresBlend(Model* model);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
|
|
||||||
void setBlendedVertices(const QPointer<Model>& model, int blendNumber, const QWeakPointer<NetworkGeometry>& geometry,
|
|
||||||
const QVector<glm::vec3>& vertices, const QVector<glm::vec3>& normals);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual QSharedPointer<Resource> createResource(const QUrl& url,
|
virtual QSharedPointer<Resource> createResource(const QUrl& url,
|
||||||
const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra);
|
const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
GeometryCache();
|
||||||
|
virtual ~GeometryCache();
|
||||||
|
friend class DependencyManager;
|
||||||
|
|
||||||
typedef QPair<int, int> IntPair;
|
typedef QPair<int, int> IntPair;
|
||||||
typedef QPair<GLuint, GLuint> VerticesIndices;
|
typedef QPair<GLuint, GLuint> VerticesIndices;
|
||||||
|
@ -78,9 +69,6 @@ private:
|
||||||
QHash<IntPair, QOpenGLBuffer> _gridBuffers;
|
QHash<IntPair, QOpenGLBuffer> _gridBuffers;
|
||||||
|
|
||||||
QHash<QUrl, QWeakPointer<NetworkGeometry> > _networkGeometry;
|
QHash<QUrl, QWeakPointer<NetworkGeometry> > _networkGeometry;
|
||||||
|
|
||||||
QList<QPointer<Model> > _modelsRequiringBlends;
|
|
||||||
int _pendingBlenders;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Geometry loaded from the network.
|
/// Geometry loaded from the network.
|
||||||
|
|
|
@ -41,8 +41,8 @@ GlowEffect::~GlowEffect() {
|
||||||
|
|
||||||
QOpenGLFramebufferObject* GlowEffect::getFreeFramebufferObject() const {
|
QOpenGLFramebufferObject* GlowEffect::getFreeFramebufferObject() const {
|
||||||
return (_isOddFrame ?
|
return (_isOddFrame ?
|
||||||
Application::getInstance()->getTextureCache()->getSecondaryFramebufferObject():
|
DependencyManager::get<TextureCache>()->getSecondaryFramebufferObject():
|
||||||
Application::getInstance()->getTextureCache()->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() {
|
||||||
Application::getInstance()->getTextureCache()->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,8 @@ static void maybeRelease(QOpenGLFramebufferObject* fbo) {
|
||||||
QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
|
QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
|
||||||
PerformanceTimer perfTimer("glowEffect");
|
PerformanceTimer perfTimer("glowEffect");
|
||||||
|
|
||||||
QOpenGLFramebufferObject* primaryFBO = Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject();
|
TextureCache* textureCache = DependencyManager::get<TextureCache>();
|
||||||
|
QOpenGLFramebufferObject* primaryFBO = textureCache->getPrimaryFramebufferObject();
|
||||||
primaryFBO->release();
|
primaryFBO->release();
|
||||||
glBindTexture(GL_TEXTURE_2D, primaryFBO->texture());
|
glBindTexture(GL_TEXTURE_2D, primaryFBO->texture());
|
||||||
|
|
||||||
|
@ -138,7 +139,7 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
|
|
||||||
QOpenGLFramebufferObject* destFBO = toTexture ?
|
QOpenGLFramebufferObject* destFBO = toTexture ?
|
||||||
Application::getInstance()->getTextureCache()->getSecondaryFramebufferObject() : NULL;
|
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 +161,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 =
|
||||||
Application::getInstance()->getTextureCache()->getSecondaryFramebufferObject();
|
textureCache->getSecondaryFramebufferObject();
|
||||||
QOpenGLFramebufferObject* newDiffusedFBO =
|
QOpenGLFramebufferObject* newDiffusedFBO =
|
||||||
Application::getInstance()->getTextureCache()->getTertiaryFramebufferObject();
|
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) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*Application::getInstance()->getTextureCache()->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
|
||||||
//Application::getInstance()->getTextureCache()->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);
|
||||||
|
|
||||||
//Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true);
|
//DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true);
|
||||||
{
|
{
|
||||||
GLenum buffers[1];
|
GLenum buffers[1];
|
||||||
int bufferCount = 0;
|
int bufferCount = 0;
|
||||||
|
@ -997,7 +997,7 @@ void Model::setURL(const QUrl& url, const QUrl& fallback, bool retainCurrent, bo
|
||||||
_url = url;
|
_url = url;
|
||||||
|
|
||||||
// if so instructed, keep the current geometry until the new one is loaded
|
// if so instructed, keep the current geometry until the new one is loaded
|
||||||
_nextBaseGeometry = _nextGeometry = Application::getInstance()->getGeometryCache()->getGeometry(url, fallback, delayLoad);
|
_nextBaseGeometry = _nextGeometry = DependencyManager::get<GeometryCache>()->getGeometry(url, fallback, delayLoad);
|
||||||
_nextLODHysteresis = NetworkGeometry::NO_HYSTERESIS;
|
_nextLODHysteresis = NetworkGeometry::NO_HYSTERESIS;
|
||||||
if (!retainCurrent || !isActive() || _nextGeometry->isLoaded()) {
|
if (!retainCurrent || !isActive() || _nextGeometry->isLoaded()) {
|
||||||
applyNextGeometry();
|
applyNextGeometry();
|
||||||
|
@ -1149,7 +1149,7 @@ void Blender::run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// post the result to the geometry cache, which will dispatch to the model if still alive
|
// post the result to the geometry cache, which will dispatch to the model if still alive
|
||||||
QMetaObject::invokeMethod(Application::getInstance()->getGeometryCache(), "setBlendedVertices",
|
QMetaObject::invokeMethod(DependencyManager::get<ModelBlender>(), "setBlendedVertices",
|
||||||
Q_ARG(const QPointer<Model>&, _model), Q_ARG(int, _blendNumber),
|
Q_ARG(const QPointer<Model>&, _model), Q_ARG(int, _blendNumber),
|
||||||
Q_ARG(const QWeakPointer<NetworkGeometry>&, _geometry), Q_ARG(const QVector<glm::vec3>&, vertices),
|
Q_ARG(const QWeakPointer<NetworkGeometry>&, _geometry), Q_ARG(const QVector<glm::vec3>&, vertices),
|
||||||
Q_ARG(const QVector<glm::vec3>&, normals));
|
Q_ARG(const QVector<glm::vec3>&, normals));
|
||||||
|
@ -1312,7 +1312,7 @@ void Model::simulateInternal(float deltaTime) {
|
||||||
// post the blender if we're not currently waiting for one to finish
|
// post the blender if we're not currently waiting for one to finish
|
||||||
if (geometry.hasBlendedMeshes() && _blendshapeCoefficients != _blendedBlendshapeCoefficients) {
|
if (geometry.hasBlendedMeshes() && _blendshapeCoefficients != _blendedBlendshapeCoefficients) {
|
||||||
_blendedBlendshapeCoefficients = _blendshapeCoefficients;
|
_blendedBlendshapeCoefficients = _blendshapeCoefficients;
|
||||||
Application::getInstance()->getGeometryCache()->noteRequiresBlend(this);
|
DependencyManager::get<ModelBlender>()->noteRequiresBlend(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1705,7 +1705,7 @@ void Model::endScene(RenderMode mode, RenderArgs* args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*Application::getInstance()->getTextureCache()->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
|
||||||
//Application::getInstance()->getTextureCache()->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);
|
||||||
|
|
||||||
//Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true);
|
//DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true);
|
||||||
{
|
{
|
||||||
GLenum buffers[1];
|
GLenum buffers[1];
|
||||||
int bufferCount = 0;
|
int bufferCount = 0;
|
||||||
|
@ -2324,7 +2324,8 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
|
||||||
bool dontCullOutOfViewMeshParts = Menu::getInstance()->isOptionChecked(MenuOption::DontCullOutOfViewMeshParts);
|
bool dontCullOutOfViewMeshParts = Menu::getInstance()->isOptionChecked(MenuOption::DontCullOutOfViewMeshParts);
|
||||||
bool cullTooSmallMeshParts = !Menu::getInstance()->isOptionChecked(MenuOption::DontCullTooSmallMeshParts);
|
bool cullTooSmallMeshParts = !Menu::getInstance()->isOptionChecked(MenuOption::DontCullTooSmallMeshParts);
|
||||||
bool dontReduceMaterialSwitches = Menu::getInstance()->isOptionChecked(MenuOption::DontReduceMaterialSwitches);
|
bool dontReduceMaterialSwitches = Menu::getInstance()->isOptionChecked(MenuOption::DontReduceMaterialSwitches);
|
||||||
|
|
||||||
|
TextureCache* textureCache = DependencyManager::get<TextureCache>();
|
||||||
QString lastMaterialID;
|
QString lastMaterialID;
|
||||||
int meshPartsRendered = 0;
|
int meshPartsRendered = 0;
|
||||||
updateVisibleJointStates();
|
updateVisibleJointStates();
|
||||||
|
@ -2446,7 +2447,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, Application::getInstance()->getTextureCache()->getWhiteTextureID());
|
GLBATCH(glBindTexture)(GL_TEXTURE_2D, textureCache->getWhiteTextureID());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (locations->texcoordMatrices >= 0) {
|
if (locations->texcoordMatrices >= 0) {
|
||||||
|
@ -2464,7 +2465,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 ?
|
||||||
Application::getInstance()->getTextureCache()->getBlueTextureID() : normalMap->getID());
|
textureCache->getBlueTextureID() : normalMap->getID());
|
||||||
GLBATCH(glActiveTexture)(GL_TEXTURE0);
|
GLBATCH(glActiveTexture)(GL_TEXTURE0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2472,7 +2473,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 ?
|
||||||
Application::getInstance()->getTextureCache()->getWhiteTextureID() : specularMap->getID());
|
textureCache->getWhiteTextureID() : specularMap->getID());
|
||||||
GLBATCH(glActiveTexture)(GL_TEXTURE0);
|
GLBATCH(glActiveTexture)(GL_TEXTURE0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2493,7 +2494,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 ?
|
||||||
Application::getInstance()->getTextureCache()->getWhiteTextureID() : emissiveMap->getID());
|
textureCache->getWhiteTextureID() : emissiveMap->getID());
|
||||||
GLBATCH(glActiveTexture)(GL_TEXTURE0);
|
GLBATCH(glActiveTexture)(GL_TEXTURE0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2544,3 +2545,38 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
|
||||||
|
|
||||||
return meshPartsRendered;
|
return meshPartsRendered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ModelBlender::ModelBlender() :
|
||||||
|
_pendingBlenders(0) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ModelBlender::~ModelBlender() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModelBlender::noteRequiresBlend(Model* model) {
|
||||||
|
if (_pendingBlenders < QThread::idealThreadCount()) {
|
||||||
|
if (model->maybeStartBlender()) {
|
||||||
|
_pendingBlenders++;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!_modelsRequiringBlends.contains(model)) {
|
||||||
|
_modelsRequiringBlends.append(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModelBlender::setBlendedVertices(const QPointer<Model>& model, int blendNumber,
|
||||||
|
const QWeakPointer<NetworkGeometry>& geometry, const QVector<glm::vec3>& vertices, const QVector<glm::vec3>& normals) {
|
||||||
|
if (!model.isNull()) {
|
||||||
|
model->setBlendedVertices(blendNumber, geometry, vertices, normals);
|
||||||
|
}
|
||||||
|
_pendingBlenders--;
|
||||||
|
while (!_modelsRequiringBlends.isEmpty()) {
|
||||||
|
Model* nextModel = _modelsRequiringBlends.takeFirst();
|
||||||
|
if (nextModel && nextModel->maybeStartBlender()) {
|
||||||
|
_pendingBlenders++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "Transform.h"
|
#include "Transform.h"
|
||||||
#include <AABox.h>
|
#include <AABox.h>
|
||||||
#include <AnimationCache.h>
|
#include <AnimationCache.h>
|
||||||
|
#include <DependencyManager.h>
|
||||||
#include <GeometryUtil.h>
|
#include <GeometryUtil.h>
|
||||||
#include <PhysicsEntity.h>
|
#include <PhysicsEntity.h>
|
||||||
|
|
||||||
|
@ -453,12 +454,33 @@ private:
|
||||||
static int renderMeshesForModelsInScene(gpu::Batch& batch, RenderMode mode, bool translucent, float alphaThreshold,
|
static int renderMeshesForModelsInScene(gpu::Batch& batch, RenderMode mode, bool translucent, float alphaThreshold,
|
||||||
bool hasLightmap, bool hasTangents, bool hasSpecular, bool isSkinned, RenderArgs* args);
|
bool hasLightmap, bool hasTangents, bool hasSpecular, bool isSkinned, RenderArgs* args);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QPointer<Model>)
|
Q_DECLARE_METATYPE(QPointer<Model>)
|
||||||
Q_DECLARE_METATYPE(QWeakPointer<NetworkGeometry>)
|
Q_DECLARE_METATYPE(QWeakPointer<NetworkGeometry>)
|
||||||
Q_DECLARE_METATYPE(QVector<glm::vec3>)
|
Q_DECLARE_METATYPE(QVector<glm::vec3>)
|
||||||
|
|
||||||
|
/// Handle management of pending models that need blending
|
||||||
|
class ModelBlender : public QObject, public DependencyManager::Dependency {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// Adds the specified model to the list requiring vertex blends.
|
||||||
|
void noteRequiresBlend(Model* model);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setBlendedVertices(const QPointer<Model>& model, int blendNumber, const QWeakPointer<NetworkGeometry>& geometry,
|
||||||
|
const QVector<glm::vec3>& vertices, const QVector<glm::vec3>& normals);
|
||||||
|
|
||||||
|
private:
|
||||||
|
ModelBlender();
|
||||||
|
virtual ~ModelBlender();
|
||||||
|
friend class DependencyManager;
|
||||||
|
|
||||||
|
QList<QPointer<Model> > _modelsRequiringBlends;
|
||||||
|
int _pendingBlenders;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // hifi_Model_h
|
#endif // hifi_Model_h
|
||||||
|
|
|
@ -12,16 +12,17 @@
|
||||||
// include this before QGLWidget, which includes an earlier version of OpenGL
|
// include this before QGLWidget, which includes an earlier version of OpenGL
|
||||||
#include "InterfaceConfig.h"
|
#include "InterfaceConfig.h"
|
||||||
|
|
||||||
|
#include <QEvent>
|
||||||
#include <QGLWidget>
|
#include <QGLWidget>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QOpenGLFramebufferObject>
|
#include <QOpenGLFramebufferObject>
|
||||||
|
#include <QResizeEvent>
|
||||||
#include <QRunnable>
|
#include <QRunnable>
|
||||||
#include <QThreadPool>
|
#include <QThreadPool>
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/random.hpp>
|
#include <glm/gtc/random.hpp>
|
||||||
|
|
||||||
#include "Application.h"
|
|
||||||
#include "TextureCache.h"
|
#include "TextureCache.h"
|
||||||
|
|
||||||
TextureCache::TextureCache() :
|
TextureCache::TextureCache() :
|
||||||
|
@ -35,7 +36,8 @@ TextureCache::TextureCache() :
|
||||||
_secondaryFramebufferObject(NULL),
|
_secondaryFramebufferObject(NULL),
|
||||||
_tertiaryFramebufferObject(NULL),
|
_tertiaryFramebufferObject(NULL),
|
||||||
_shadowFramebufferObject(NULL),
|
_shadowFramebufferObject(NULL),
|
||||||
_frameBufferSize(100, 100)
|
_frameBufferSize(100, 100),
|
||||||
|
_associatedWidget(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,9 +352,16 @@ QSharedPointer<Resource> TextureCache::createResource(const QUrl& url,
|
||||||
&Resource::allReferencesCleared);
|
&Resource::allReferencesCleared);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextureCache::associateWithWidget(QGLWidget* widget) {
|
||||||
|
if (_associatedWidget) {
|
||||||
|
_associatedWidget->removeEventFilter(this);
|
||||||
|
}
|
||||||
|
_associatedWidget = widget;
|
||||||
|
_associatedWidget->installEventFilter(this);
|
||||||
|
}
|
||||||
|
|
||||||
QOpenGLFramebufferObject* TextureCache::createFramebufferObject() {
|
QOpenGLFramebufferObject* TextureCache::createFramebufferObject() {
|
||||||
QOpenGLFramebufferObject* fbo = new QOpenGLFramebufferObject(_frameBufferSize);
|
QOpenGLFramebufferObject* fbo = new QOpenGLFramebufferObject(_frameBufferSize);
|
||||||
Application::getInstance()->getGLWidget()->installEventFilter(this);
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, fbo->texture());
|
glBindTexture(GL_TEXTURE_2D, fbo->texture());
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
|
|
@ -14,7 +14,9 @@
|
||||||
|
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <QGLWidget>
|
||||||
|
|
||||||
|
#include <DependencyManager.h>
|
||||||
#include <ResourceCache.h>
|
#include <ResourceCache.h>
|
||||||
|
|
||||||
#include "InterfaceConfig.h"
|
#include "InterfaceConfig.h"
|
||||||
|
@ -28,13 +30,12 @@ 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:
|
||||||
|
|
||||||
TextureCache();
|
void associateWithWidget(QGLWidget* widget);
|
||||||
virtual ~TextureCache();
|
|
||||||
|
|
||||||
/// Sets the desired texture resolution for the framebuffer objects.
|
/// Sets the desired texture resolution for the framebuffer objects.
|
||||||
void setFrameBufferSize(QSize frameBufferSize);
|
void setFrameBufferSize(QSize frameBufferSize);
|
||||||
|
@ -93,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();
|
||||||
|
@ -115,6 +118,7 @@ private:
|
||||||
GLuint _shadowDepthTextureID;
|
GLuint _shadowDepthTextureID;
|
||||||
|
|
||||||
QSize _frameBufferSize;
|
QSize _frameBufferSize;
|
||||||
|
QGLWidget* _associatedWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A simple object wrapper for an OpenGL texture.
|
/// A simple object wrapper for an OpenGL texture.
|
||||||
|
|
|
@ -353,7 +353,7 @@ void MetavoxelEditor::render() {
|
||||||
|
|
||||||
_gridProgram.bind();
|
_gridProgram.bind();
|
||||||
|
|
||||||
Application::getInstance()->getGeometryCache()->renderGrid(GRID_DIVISIONS, GRID_DIVISIONS);
|
DependencyManager::get<GeometryCache>()->renderGrid(GRID_DIVISIONS, GRID_DIVISIONS);
|
||||||
|
|
||||||
_gridProgram.release();
|
_gridProgram.release();
|
||||||
|
|
||||||
|
@ -916,7 +916,7 @@ void MaterialControl::updateTexture() {
|
||||||
_texture.clear();
|
_texture.clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_texture = Application::getInstance()->getTextureCache()->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();
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#include "Base3DOverlay.h"
|
#include "Base3DOverlay.h"
|
||||||
#include "../../renderer/TextureCache.h"
|
#include "renderer/TextureCache.h"
|
||||||
|
|
||||||
class BillboardOverlay : public Base3DOverlay {
|
class BillboardOverlay : public Base3DOverlay {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
@ -87,7 +87,7 @@ void Grid3DOverlay::render(RenderArgs* args) {
|
||||||
float scale = MINOR_GRID_DIVISIONS * spacing;
|
float scale = MINOR_GRID_DIVISIONS * spacing;
|
||||||
glScalef(scale, scale, scale);
|
glScalef(scale, scale, scale);
|
||||||
|
|
||||||
Application::getInstance()->getGeometryCache()->renderGrid(MINOR_GRID_DIVISIONS, MINOR_GRID_DIVISIONS);
|
DependencyManager::get<GeometryCache>()->renderGrid(MINOR_GRID_DIVISIONS, MINOR_GRID_DIVISIONS);
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ void Grid3DOverlay::render(RenderArgs* args) {
|
||||||
float scale = MAJOR_GRID_DIVISIONS * spacing;
|
float scale = MAJOR_GRID_DIVISIONS * spacing;
|
||||||
glScalef(scale, scale, scale);
|
glScalef(scale, scale, scale);
|
||||||
|
|
||||||
Application::getInstance()->getGeometryCache()->renderGrid(MAJOR_GRID_DIVISIONS, MAJOR_GRID_DIVISIONS);
|
DependencyManager::get<GeometryCache>()->renderGrid(MAJOR_GRID_DIVISIONS, MAJOR_GRID_DIVISIONS);
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ void Sphere3DOverlay::render(RenderArgs* args) {
|
||||||
glScalef(dimensions.x, dimensions.y, dimensions.z);
|
glScalef(dimensions.x, dimensions.y, dimensions.z);
|
||||||
//Application::getInstance()->getDeferredLightingEffect()->renderSolidCube(1.0f);
|
//Application::getInstance()->getDeferredLightingEffect()->renderSolidCube(1.0f);
|
||||||
if (_isSolid) {
|
if (_isSolid) {
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(1.0f, SLICES, SLICES);
|
DependencyManager::get<GeometryCache>()->renderSphere(1.0f, SLICES, SLICES);
|
||||||
} else {
|
} else {
|
||||||
glutWireSphere(1.0f, SLICES, SLICES);
|
glutWireSphere(1.0f, SLICES, SLICES);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream> // to load voxels from file
|
#include <iostream> // to load voxels from file
|
||||||
|
@ -1171,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, Application::getInstance()->getTextureCache()->getPermutationNormalTextureID());
|
glBindTexture(GL_TEXTURE_2D, DependencyManager::get<TextureCache>()->getPermutationNormalTextureID());
|
||||||
} else {
|
} else {
|
||||||
_program.bind();
|
_program.bind();
|
||||||
}
|
}
|
||||||
|
@ -1179,7 +1178,7 @@ void VoxelSystem::applyScaleAndBindProgram(bool texture) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glScalef(_treeScale, _treeScale, _treeScale);
|
glScalef(_treeScale, _treeScale, _treeScale);
|
||||||
|
|
||||||
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, true);
|
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelSystem::removeScaleAndReleaseProgram(bool texture) {
|
void VoxelSystem::removeScaleAndReleaseProgram(bool texture) {
|
||||||
|
@ -1193,7 +1192,7 @@ void VoxelSystem::removeScaleAndReleaseProgram(bool texture) {
|
||||||
_program.release();
|
_program.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false);
|
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int VoxelSystem::_nodeCount = 0;
|
int VoxelSystem::_nodeCount = 0;
|
||||||
|
|
Loading…
Reference in a new issue