Working on fixing overlays with team-teaching merge

This commit is contained in:
Brad Davis 2015-06-10 09:36:14 -07:00
parent 5e279367b7
commit 7374fb84e8
5 changed files with 198 additions and 169 deletions

View file

@ -958,7 +958,7 @@ void Application::paintGL() {
GL_COLOR_BUFFER_BIT, GL_NEAREST); GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
_applicationOverlay.displayOverlayTexture(); _applicationOverlay.displayOverlayTexture(&renderArgs);
} }
if (!OculusManager::isConnected() || OculusManager::allowSwap()) { if (!OculusManager::isConnected() || OculusManager::allowSwap()) {

View file

@ -615,12 +615,9 @@ void OculusManager::display(QGLWidget * glCanvas, RenderArgs* renderArgs, const
renderArgs->_renderSide = RenderArgs::MONO; renderArgs->_renderSide = RenderArgs::MONO;
qApp->displaySide(renderArgs, *_camera, false); qApp->displaySide(renderArgs, *_camera, false);
qApp->getApplicationOverlay().displayOverlayTextureHmd(*_camera);
}); });
_activeEye = ovrEye_Count; _activeEye = ovrEye_Count;
glPopMatrix();
gpu::FramebufferPointer finalFbo; gpu::FramebufferPointer finalFbo;
//Bind the output texture from the glow shader. If glow effect is disabled, we just grab the texture //Bind the output texture from the glow shader. If glow effect is disabled, we just grab the texture
if (Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)) { if (Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)) {
@ -632,9 +629,35 @@ void OculusManager::display(QGLWidget * glCanvas, RenderArgs* renderArgs, const
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
} }
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(finalFbo));
//Render each eye into an fbo
for_each_eye(_ovrHmd, [&](ovrEyeType eye) {
_activeEye = eye;
// Update our camera to what the application camera is doing
_camera->setRotation(toGlm(eyeRenderPose[eye].Orientation));
_camera->setPosition(toGlm(eyeRenderPose[eye].Position));
configureCamera(*_camera);
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(glm::value_ptr(_camera->getProjection()));
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
ovrRecti & vp = _eyeTextures[eye].Header.RenderViewport;
vp.Size.h = _recommendedTexSize.h * _offscreenRenderScale;
vp.Size.w = _recommendedTexSize.w * _offscreenRenderScale;
glViewport(vp.Pos.x, vp.Pos.y, vp.Size.w, vp.Size.h);
qApp->getApplicationOverlay().displayOverlayTextureHmd(renderArgs, *_camera);
});
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glPopMatrix();
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glPopMatrix(); glPopMatrix();
// restore our normal viewport // restore our normal viewport
glViewport(0, 0, deviceSize.width(), deviceSize.height()); glViewport(0, 0, deviceSize.width(), deviceSize.height());

View file

@ -120,7 +120,7 @@ void TV3DManager::display(RenderArgs* renderArgs, Camera& whichCamera) {
glLoadIdentity(); glLoadIdentity();
renderArgs->_renderSide = RenderArgs::MONO; renderArgs->_renderSide = RenderArgs::MONO;
qApp->displaySide(renderArgs, eyeCamera, false); qApp->displaySide(renderArgs, eyeCamera, false);
qApp->getApplicationOverlay().displayOverlayTextureStereo(whichCamera, _aspect, fov); qApp->getApplicationOverlay().displayOverlayTextureStereo(renderArgs, whichCamera, _aspect, fov);
_activeEye = NULL; _activeEye = NULL;
}, [&]{ }, [&]{
// render right side view // render right side view

View file

@ -14,13 +14,16 @@
#include <QOpenGLFramebufferObject> #include <QOpenGLFramebufferObject>
#include <QOpenGLTexture> #include <QOpenGLTexture>
#include <glm/gtc/type_ptr.hpp>
#include <avatar/AvatarManager.h> #include <avatar/AvatarManager.h>
#include <DeferredLightingEffect.h>
#include <GLMHelpers.h> #include <GLMHelpers.h>
#include <PathUtils.h>
#include <gpu/GLBackend.h> #include <gpu/GLBackend.h>
#include <GLMHelpers.h> #include <GLMHelpers.h>
#include <PerfStat.h>
#include <OffscreenUi.h> #include <OffscreenUi.h>
#include <PathUtils.h>
#include <PerfStat.h>
#include "AudioClient.h" #include "AudioClient.h"
#include "audio/AudioIOStatsRenderer.h" #include "audio/AudioIOStatsRenderer.h"
@ -149,7 +152,8 @@ ApplicationOverlay::ApplicationOverlay() :
_previousMagnifierBottomLeft(), _previousMagnifierBottomLeft(),
_previousMagnifierBottomRight(), _previousMagnifierBottomRight(),
_previousMagnifierTopLeft(), _previousMagnifierTopLeft(),
_previousMagnifierTopRight() _previousMagnifierTopRight(),
_framebufferObject(nullptr)
{ {
memset(_reticleActive, 0, sizeof(_reticleActive)); memset(_reticleActive, 0, sizeof(_reticleActive));
memset(_magActive, 0, sizeof(_reticleActive)); memset(_magActive, 0, sizeof(_reticleActive));
@ -196,16 +200,17 @@ void ApplicationOverlay::renderOverlay(RenderArgs* renderArgs) {
//Handle fading and deactivation/activation of UI //Handle fading and deactivation/activation of UI
// Render 2D overlay // Render 2D overlay
glMatrixMode(GL_PROJECTION);
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
_overlays.buildFramebufferObject(); buildFramebufferObject();
_overlays.bind();
_framebufferObject->bind();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glViewport(0, 0, size.x, size.y); glViewport(0, 0, size.x, size.y);
glMatrixMode(GL_PROJECTION);
glPushMatrix(); { glPushMatrix(); {
const float NEAR_CLIP = -10000; const float NEAR_CLIP = -10000;
const float FAR_CLIP = 10000; const float FAR_CLIP = 10000;
@ -227,6 +232,22 @@ void ApplicationOverlay::renderOverlay(RenderArgs* renderArgs) {
renderPointers(); renderPointers();
renderDomainConnectionStatusBorder(); renderDomainConnectionStatusBorder();
if (_newUiTexture) {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, _newUiTexture);
DependencyManager::get<GeometryCache>()->renderUnitQuad();
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
}
glLoadIdentity();
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
} glPopMatrix(); } glPopMatrix();
@ -236,166 +257,159 @@ void ApplicationOverlay::renderOverlay(RenderArgs* renderArgs) {
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE); glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE);
_overlays.release(); _framebufferObject->release();
} }
// A quick and dirty solution for compositing the old overlay // A quick and dirty solution for compositing the old overlay
// texture with the new one // texture with the new one
template <typename F> //template <typename F>
void with_each_texture(GLuint firstPassTexture, GLuint secondPassTexture, F f) { //void with_each_texture(GLuint firstPassTexture, GLuint secondPassTexture, F f) {
glEnable(GL_TEXTURE_2D); // glEnable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0); // glActiveTexture(GL_TEXTURE0);
if (firstPassTexture) { // if (firstPassTexture) {
glBindTexture(GL_TEXTURE_2D, firstPassTexture); // glBindTexture(GL_TEXTURE_2D, firstPassTexture);
f(); // f();
} // }
if (secondPassTexture) { // //if (secondPassTexture) {
glBindTexture(GL_TEXTURE_2D, secondPassTexture); // // glBindTexture(GL_TEXTURE_2D, secondPassTexture);
f(); // // f();
} // //}
glBindTexture(GL_TEXTURE_2D, 0); // glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D); // glDisable(GL_TEXTURE_2D);
} //}
// Draws the FBO texture for the screen // Draws the FBO texture for the screen
void ApplicationOverlay::displayOverlayTexture() { void ApplicationOverlay::displayOverlayTexture(RenderArgs* renderArgs) {
if (_alpha == 0.0f) { if (_alpha == 0.0f) {
return; return;
} }
if (!_crosshairTexture) {
_crosshairTexture = TextureCache::getImageTexture(
PathUtils::resourcesPath() + "images/sixense-reticle.png");
}
/*
FIXME - doesn't work
renderArgs->_context->syncCache();
gpu::Batch batch;
DependencyManager::get<DeferredLightingEffect>()->bindSimpleProgram(batch, true);
batch.setModelTransform(Transform());
batch.setProjectionTransform(mat4());
batch.setViewTransform(Transform());
batch.setUniformTexture(0, _crosshairTexture);
DependencyManager::get<GeometryCache>()->renderUnitQuad(batch, vec4(vec3(1), _alpha));
renderArgs->_context->render(batch);
return;
*/
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D);
glViewport(0, 0, qApp->getDeviceSize().width(), qApp->getDeviceSize().height());
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glPushMatrix(); { glPushMatrix();
glLoadIdentity(); glLoadIdentity();
glDisable(GL_DEPTH_TEST); glMatrixMode(GL_MODELVIEW);
glDisable(GL_LIGHTING); glPushMatrix();
glEnable(GL_BLEND); glLoadIdentity();
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); {
glViewport(0, 0, qApp->getDeviceSize().width(), qApp->getDeviceSize().height()); glBindTexture(GL_TEXTURE_2D, _framebufferObject->texture());
DependencyManager::get<GeometryCache>()->renderUnitQuad(vec4(vec3(1), _alpha));
static const glm::vec2 topLeft(-1, 1);
static const glm::vec2 bottomRight(1, -1);
static const glm::vec2 texCoordTopLeft(0.0f, 1.0f);
static const glm::vec2 texCoordBottomRight(1.0f, 0.0f);
with_each_texture(_overlays.getTexture(), _newUiTexture, [&] {
DependencyManager::get<GeometryCache>()->renderQuad(
topLeft, bottomRight,
texCoordTopLeft, texCoordBottomRight,
glm::vec4(1.0f, 1.0f, 1.0f, _alpha));
});
if (!_crosshairTexture) {
_crosshairTexture = DependencyManager::get<TextureCache>()->
getImageTexture(PathUtils::resourcesPath() + "images/sixense-reticle.png");
}
//draw the mouse pointer //draw the mouse pointer
glm::vec2 canvasSize = qApp->getCanvasSize(); glm::vec2 canvasSize = qApp->getCanvasSize();
glm::vec2 mouseSize = 32.0f / canvasSize;
auto mouseTopLeft = topLeft * mouseSize; // Get the mouse coordinates and convert to NDC [-1, 1]
auto mouseBottomRight = bottomRight * mouseSize;
vec2 mousePosition = vec2(qApp->getMouseX(), qApp->getMouseY()); vec2 mousePosition = vec2(qApp->getMouseX(), qApp->getMouseY());
mousePosition /= canvasSize; mousePosition /= canvasSize;
mousePosition *= 2.0f; mousePosition *= 2.0f;
mousePosition -= 1.0f; mousePosition -= 1.0f;
mousePosition.y *= -1.0f; mousePosition.y *= -1.0f;
mat4 mouseMv = glm::translate(mat4(), vec3(mousePosition, 0));
glEnable(GL_TEXTURE_2D); // Scale the mouse based on the canvasSize (NOT the device size,
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // we don't want a smaller mouse on retina displays)
glm::vec2 mouseSize = 32.0f / canvasSize;
mouseMv = glm::scale(mouseMv, vec3(mouseSize, 1.0f));
// Push the resulting matrix into modelview
glLoadMatrixf(glm::value_ptr(mouseMv));
glBindTexture(GL_TEXTURE_2D, gpu::GLBackend::getTextureID(_crosshairTexture)); glBindTexture(GL_TEXTURE_2D, gpu::GLBackend::getTextureID(_crosshairTexture));
glm::vec4 reticleColor = { RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2], 1.0f }; glm::vec4 reticleColor = { RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2], 1.0f };
DependencyManager::get<GeometryCache>()->renderQuad( DependencyManager::get<GeometryCache>()->renderUnitQuad(reticleColor);
mouseTopLeft + mousePosition, mouseBottomRight + mousePosition, }
texCoordTopLeft, texCoordBottomRight, glMatrixMode(GL_PROJECTION);
reticleColor); glPopMatrix();
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE); glMatrixMode(GL_MODELVIEW);
glDisable(GL_TEXTURE_2D); glPopMatrix();
} glPopMatrix();
} }
// Draws the FBO texture for Oculus rift. // Draws the FBO texture for Oculus rift.
void ApplicationOverlay::displayOverlayTextureHmd(Camera& whichCamera) { void ApplicationOverlay::displayOverlayTextureHmd(RenderArgs* renderArgs, Camera& whichCamera) {
if (_alpha == 0.0f) { if (_alpha == 0.0f) {
return; return;
} }
glEnable(GL_BLEND); _overlays.buildVBO(_textureFov, _textureAspectRatio, 80, 80);
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE); glDisable(GL_DEPTH_TEST);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glEnable(GL_ALPHA_TEST); glEnable(GL_BLEND);
glAlphaFunc(GL_GREATER, 0.01f); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// The camera here contains only the head pose relative to the avatar position
vec3 pos = whichCamera.getPosition();
quat rot = whichCamera.getOrientation();
mat4 overlayXfm = glm::translate(glm::mat4(), pos) * glm::mat4_cast(rot);
glLoadMatrixf(glm::value_ptr(glm::inverse(overlayXfm)));
glBindTexture(GL_TEXTURE_2D, _framebufferObject->texture());
_overlays.render();
//Update and draw the magnifiers //Update and draw the magnifiers
/*
// FIXME Mangifiers need to be re-thought
MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
const glm::quat& orientation = myAvatar->getOrientation();
// Always display the HMD overlay relative to the camera position but
// remove the HMD pose offset. This results in an overlay that sticks with you
// even in third person mode, but isn't drawn at a fixed distance.
glm::vec3 position = whichCamera.getPosition();
position -= qApp->getCamera()->getHmdPosition();
const float scale = myAvatar->getScale() * _oculusUIRadius; const float scale = myAvatar->getScale() * _oculusUIRadius;
overlayXfm = glm::scale(overlayXfm, vec3(scale));
// glm::vec3 eyeOffset = setEyeOffsetPosition; for (int i = 0; i < NUMBER_OF_RETICLES; i++) {
glMatrixMode(GL_MODELVIEW); if (_magActive[i]) {
glPushMatrix(); { _magSizeMult[i] += MAG_SPEED;
glTranslatef(position.x, position.y, position.z); if (_magSizeMult[i] > 1.0f) {
glm::mat4 rotation = glm::toMat4(orientation); _magSizeMult[i] = 1.0f;
glMultMatrixf(&rotation[0][0]);
glScalef(scale, scale, scale);
for (int i = 0; i < NUMBER_OF_RETICLES; i++) {
if (_magActive[i]) {
_magSizeMult[i] += MAG_SPEED;
if (_magSizeMult[i] > 1.0f) {
_magSizeMult[i] = 1.0f;
}
} else {
_magSizeMult[i] -= MAG_SPEED;
if (_magSizeMult[i] < 0.0f) {
_magSizeMult[i] = 0.0f;
}
} }
} else {
if (_magSizeMult[i] > 0.0f) { _magSizeMult[i] -= MAG_SPEED;
//Render magnifier, but dont show border for mouse magnifier if (_magSizeMult[i] < 0.0f) {
glm::vec2 projection = screenToOverlay(glm::vec2(_reticlePosition[MOUSE].x(), _magSizeMult[i] = 0.0f;
_reticlePosition[MOUSE].y()));
with_each_texture(_overlays.getTexture(), 0, [&] {
renderMagnifier(projection, _magSizeMult[i], i != MOUSE);
});
} }
} }
glDepthMask(GL_FALSE);
glDisable(GL_ALPHA_TEST);
static float textureFOV = 0.0f, textureAspectRatio = 1.0f;
if (textureFOV != _textureFov ||
textureAspectRatio != _textureAspectRatio) {
textureFOV = _textureFov;
textureAspectRatio = _textureAspectRatio;
_overlays.buildVBO(_textureFov, _textureAspectRatio, 80, 80); if (_magSizeMult[i] > 0.0f) {
//Render magnifier, but dont show border for mouse magnifier
glm::vec2 projection = screenToOverlay(glm::vec2(_reticlePosition[MOUSE].x(),
_reticlePosition[MOUSE].y()));
with_each_texture(_overlays.getTexture(), 0, [&] {
renderMagnifier(projection, _magSizeMult[i], i != MOUSE);
});
} }
}
*/
with_each_texture(_overlays.getTexture(), _newUiTexture, [&] { if (!Application::getInstance()->isMouseHidden()) {
_overlays.render(); renderPointersOculus();
}); }
if (!Application::getInstance()->isMouseHidden()) {
renderPointersOculus();
}
glDepthMask(GL_TRUE);
glDisable(GL_TEXTURE_2D);
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE);
glEnable(GL_LIGHTING);
} glPopMatrix();
} }
// Draws the FBO texture for 3DTV. // Draws the FBO texture for 3DTV.
void ApplicationOverlay::displayOverlayTextureStereo(Camera& whichCamera, float aspectRatio, float fov) { void ApplicationOverlay::displayOverlayTextureStereo(RenderArgs* renderArgs, Camera& whichCamera, float aspectRatio, float fov) {
if (_alpha == 0.0f) { if (_alpha == 0.0f) {
return; return;
} }
@ -440,15 +454,15 @@ void ApplicationOverlay::displayOverlayTextureStereo(Camera& whichCamera, float
GLfloat y = -halfQuadHeight; GLfloat y = -halfQuadHeight;
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
with_each_texture(_overlays.getTexture(), _newUiTexture, [&] { //with_each_texture(_framebufferObject->texture(), _newUiTexture, [&] {
DependencyManager::get<GeometryCache>()->renderQuad(glm::vec3(x, y + quadHeight, -distance), // DependencyManager::get<GeometryCache>()->renderQuad(glm::vec3(x, y + quadHeight, -distance),
glm::vec3(x + quadWidth, y + quadHeight, -distance), // glm::vec3(x + quadWidth, y + quadHeight, -distance),
glm::vec3(x + quadWidth, y, -distance), // glm::vec3(x + quadWidth, y, -distance),
glm::vec3(x, y, -distance), // glm::vec3(x, y, -distance),
glm::vec2(0.0f, 1.0f), glm::vec2(1.0f, 1.0f), // glm::vec2(0.0f, 1.0f), glm::vec2(1.0f, 1.0f),
glm::vec2(1.0f, 0.0f), glm::vec2(0.0f, 0.0f), // glm::vec2(1.0f, 0.0f), glm::vec2(0.0f, 0.0f),
overlayColor); // overlayColor);
}); //});
if (!_crosshairTexture) { if (!_crosshairTexture) {
_crosshairTexture = TextureCache::getImageTexture(PathUtils::resourcesPath() + _crosshairTexture = TextureCache::getImageTexture(PathUtils::resourcesPath() +
@ -1071,29 +1085,24 @@ void ApplicationOverlay::renderDomainConnectionStatusBorder() {
ApplicationOverlay::TexturedHemisphere::TexturedHemisphere() : ApplicationOverlay::TexturedHemisphere::TexturedHemisphere() :
_vertices(0), _vertices(0),
_indices(0), _indices(0),
_framebufferObject(NULL),
_vbo(0, 0) { _vbo(0, 0) {
} }
ApplicationOverlay::TexturedHemisphere::~TexturedHemisphere() { ApplicationOverlay::TexturedHemisphere::~TexturedHemisphere() {
cleanupVBO(); cleanupVBO();
if (_framebufferObject != NULL) {
delete _framebufferObject;
}
}
void ApplicationOverlay::TexturedHemisphere::bind() {
_framebufferObject->bind();
}
void ApplicationOverlay::TexturedHemisphere::release() {
_framebufferObject->release();
} }
void ApplicationOverlay::TexturedHemisphere::buildVBO(const float fov, void ApplicationOverlay::TexturedHemisphere::buildVBO(const float fov,
const float aspectRatio, const float aspectRatio,
const int slices, const int slices,
const int stacks) { const int stacks) {
static float textureFOV = 0.0f, textureAspectRatio = 1.0f;
if (textureFOV == fov && textureAspectRatio == aspectRatio) {
return;
}
textureFOV = fov;
textureAspectRatio = aspectRatio;
if (fov >= PI) { if (fov >= PI) {
qDebug() << "TexturedHemisphere::buildVBO(): FOV greater or equal than Pi will create issues"; qDebug() << "TexturedHemisphere::buildVBO(): FOV greater or equal than Pi will create issues";
} }
@ -1176,7 +1185,11 @@ void ApplicationOverlay::TexturedHemisphere::cleanupVBO() {
} }
} }
void ApplicationOverlay::TexturedHemisphere::buildFramebufferObject() { GLuint ApplicationOverlay::getOverlayTexture() {
return _framebufferObject->texture();
}
void ApplicationOverlay::buildFramebufferObject() {
auto canvasSize = qApp->getCanvasSize(); auto canvasSize = qApp->getCanvasSize();
QSize fboSize = QSize(canvasSize.x, canvasSize.y); QSize fboSize = QSize(canvasSize.x, canvasSize.y);
if (_framebufferObject != NULL && fboSize == _framebufferObject->size()) { if (_framebufferObject != NULL && fboSize == _framebufferObject->size()) {
@ -1189,7 +1202,7 @@ void ApplicationOverlay::TexturedHemisphere::buildFramebufferObject() {
} }
_framebufferObject = new QOpenGLFramebufferObject(fboSize, QOpenGLFramebufferObject::Depth); _framebufferObject = new QOpenGLFramebufferObject(fboSize, QOpenGLFramebufferObject::Depth);
glBindTexture(GL_TEXTURE_2D, getTexture()); glBindTexture(GL_TEXTURE_2D, getOverlayTexture());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
@ -1201,7 +1214,7 @@ void ApplicationOverlay::TexturedHemisphere::buildFramebufferObject() {
//Renders a hemisphere with texture coordinates. //Renders a hemisphere with texture coordinates.
void ApplicationOverlay::TexturedHemisphere::render() { void ApplicationOverlay::TexturedHemisphere::render() {
if (_framebufferObject == NULL || _vbo.first == 0 || _vbo.second == 0) { if (_vbo.first == 0 || _vbo.second == 0) {
qDebug() << "TexturedHemisphere::render(): Incorrect initialisation"; qDebug() << "TexturedHemisphere::render(): Incorrect initialisation";
return; return;
} }
@ -1227,10 +1240,6 @@ void ApplicationOverlay::TexturedHemisphere::render() {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
} }
GLuint ApplicationOverlay::TexturedHemisphere::getTexture() {
return _framebufferObject->texture();
}
glm::vec2 ApplicationOverlay::directionToSpherical(const glm::vec3& direction) { glm::vec2 ApplicationOverlay::directionToSpherical(const glm::vec3& direction) {
glm::vec2 result; glm::vec2 result;
// Compute yaw // Compute yaw

View file

@ -33,9 +33,9 @@ public:
~ApplicationOverlay(); ~ApplicationOverlay();
void renderOverlay(RenderArgs* renderArgs); void renderOverlay(RenderArgs* renderArgs);
void displayOverlayTexture(); void displayOverlayTexture(RenderArgs* renderArgs);
void displayOverlayTextureStereo(Camera& whichCamera, float aspectRatio, float fov); void displayOverlayTextureStereo(RenderArgs* renderArgs, Camera& whichCamera, float aspectRatio, float fov);
void displayOverlayTextureHmd(Camera& whichCamera); void displayOverlayTextureHmd(RenderArgs* renderArgs, Camera& whichCamera);
QPoint getPalmClickLocation(const PalmData *palm) const; QPoint getPalmClickLocation(const PalmData *palm) const;
bool calculateRayUICollisionPoint(const glm::vec3& position, const glm::vec3& direction, glm::vec3& result) const; bool calculateRayUICollisionPoint(const glm::vec3& position, const glm::vec3& direction, glm::vec3& result) const;
@ -59,6 +59,7 @@ public:
glm::vec2 screenToOverlay(const glm::vec2 & screenPos) const; glm::vec2 screenToOverlay(const glm::vec2 & screenPos) const;
glm::vec2 overlayToScreen(const glm::vec2 & overlayPos) const; glm::vec2 overlayToScreen(const glm::vec2 & overlayPos) const;
void computeHmdPickRay(glm::vec2 cursorPos, glm::vec3& origin, glm::vec3& direction) const; void computeHmdPickRay(glm::vec2 cursorPos, glm::vec3& origin, glm::vec3& direction) const;
GLuint getOverlayTexture();
static glm::vec2 directionToSpherical(const glm::vec3 & direction); static glm::vec2 directionToSpherical(const glm::vec3 & direction);
static glm::vec3 sphericalToDirection(const glm::vec2 & sphericalPos); static glm::vec3 sphericalToDirection(const glm::vec2 & sphericalPos);
@ -77,12 +78,6 @@ private:
public: public:
TexturedHemisphere(); TexturedHemisphere();
~TexturedHemisphere(); ~TexturedHemisphere();
void bind();
void release();
GLuint getTexture();
void buildFramebufferObject();
void buildVBO(const float fov, const float aspectRatio, const int slices, const int stacks); void buildVBO(const float fov, const float aspectRatio, const int slices, const int stacks);
void render(); void render();
@ -91,14 +86,14 @@ private:
GLuint _vertices; GLuint _vertices;
GLuint _indices; GLuint _indices;
QOpenGLFramebufferObject* _framebufferObject;
VerticesIndices _vbo; VerticesIndices _vbo;
}; };
float _hmdUIAngularSize = DEFAULT_HMD_UI_ANGULAR_SIZE; float _hmdUIAngularSize = DEFAULT_HMD_UI_ANGULAR_SIZE;
QOpenGLFramebufferObject* _framebufferObject;
void renderReticle(glm::quat orientation, float alpha); void renderReticle(glm::quat orientation, float alpha);
void renderPointers();; void renderPointers();
void renderMagnifier(glm::vec2 magPos, float sizeMult, bool showBorder); void renderMagnifier(glm::vec2 magPos, float sizeMult, bool showBorder);
void renderControllerPointers(); void renderControllerPointers();
@ -109,6 +104,8 @@ private:
void renderStatsAndLogs(); void renderStatsAndLogs();
void renderDomainConnectionStatusBorder(); void renderDomainConnectionStatusBorder();
void buildFramebufferObject();
TexturedHemisphere _overlays; TexturedHemisphere _overlays;
float _textureFov; float _textureFov;