mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 15:29:05 +02:00
Working on display plugins
This commit is contained in:
parent
6a5c7b8b42
commit
abab54aed8
9 changed files with 68 additions and 33 deletions
|
@ -3069,7 +3069,11 @@ PickRay Application::computePickRay(float x, float y) const {
|
||||||
if (isHMDMode()) {
|
if (isHMDMode()) {
|
||||||
ApplicationOverlay::computeHmdPickRay(glm::vec2(x, y), result.origin, result.direction);
|
ApplicationOverlay::computeHmdPickRay(glm::vec2(x, y), result.origin, result.direction);
|
||||||
} else {
|
} else {
|
||||||
getViewFrustum()->computePickRay(x, y, result.origin, result.direction);
|
if (activeRenderingThread) {
|
||||||
|
getDisplayViewFrustum()->computePickRay(x, y, result.origin, result.direction);
|
||||||
|
} else {
|
||||||
|
getViewFrustum()->computePickRay(x, y, result.origin, result.direction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -3124,6 +3128,16 @@ ViewFrustum* Application::getDisplayViewFrustum() {
|
||||||
return &_displayViewFrustum;
|
return &_displayViewFrustum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ViewFrustum* Application::getDisplayViewFrustum() const {
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (QThread::currentThread() != activeRenderingThread) {
|
||||||
|
// FIXME, should this be an assert?
|
||||||
|
qWarning() << "Calling Application::getDisplayViewFrustum() from outside the active rendering thread or outside rendering, did you mean Application::getViewFrustum()?";
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return &_displayViewFrustum;
|
||||||
|
}
|
||||||
|
|
||||||
void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs::RenderSide renderSide) {
|
void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs::RenderSide renderSide) {
|
||||||
activeRenderingThread = QThread::currentThread();
|
activeRenderingThread = QThread::currentThread();
|
||||||
PROFILE_RANGE(__FUNCTION__);
|
PROFILE_RANGE(__FUNCTION__);
|
||||||
|
|
|
@ -205,6 +205,7 @@ public:
|
||||||
// which might be different from the viewFrustum, i.e. shadowmap
|
// which might be different from the viewFrustum, i.e. shadowmap
|
||||||
// passes, mirror window passes, etc
|
// passes, mirror window passes, etc
|
||||||
ViewFrustum* getDisplayViewFrustum();
|
ViewFrustum* getDisplayViewFrustum();
|
||||||
|
const ViewFrustum* getDisplayViewFrustum() const;
|
||||||
ViewFrustum* getShadowViewFrustum() { return &_shadowViewFrustum; }
|
ViewFrustum* getShadowViewFrustum() { return &_shadowViewFrustum; }
|
||||||
const OctreePacketProcessor& getOctreePacketProcessor() const { return _octreeProcessor; }
|
const OctreePacketProcessor& getOctreePacketProcessor() const { return _octreeProcessor; }
|
||||||
EntityTreeRenderer* getEntities() { return &_entities; }
|
EntityTreeRenderer* getEntities() { return &_entities; }
|
||||||
|
|
|
@ -45,6 +45,10 @@ private:
|
||||||
static eyeFrustum _rightEye;
|
static eyeFrustum _rightEye;
|
||||||
static eyeFrustum* _activeEye;
|
static eyeFrustum* _activeEye;
|
||||||
|
|
||||||
|
// The first function is the code executed for each eye
|
||||||
|
// while the second is code to be executed between the two eyes.
|
||||||
|
// The use case here is to modify the output viewport coordinates
|
||||||
|
// for the new eye.
|
||||||
template<typename F, typename FF>
|
template<typename F, typename FF>
|
||||||
static void forEachEye(F f, FF ff = []{}) {
|
static void forEachEye(F f, FF ff = []{}) {
|
||||||
f(_leftEye);
|
f(_leftEye);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
//
|
//
|
||||||
#include "GPULogging.h"
|
#include "GPULogging.h"
|
||||||
#include "GLBackendShared.h"
|
#include "GLBackendShared.h"
|
||||||
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
|
||||||
GLBackend::CommandCall GLBackend::_commandCalls[Batch::NUM_COMMANDS] =
|
GLBackend::CommandCall GLBackend::_commandCalls[Batch::NUM_COMMANDS] =
|
||||||
{
|
{
|
||||||
|
@ -521,3 +522,29 @@ void GLBackend::do_glColor4f(Batch& batch, uint32 paramOffset) {
|
||||||
(void) CHECK_GL_ERROR();
|
(void) CHECK_GL_ERROR();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLBackend::loadMatrix(GLenum target, const glm::mat4 & m) {
|
||||||
|
glMatrixMode(target);
|
||||||
|
glLoadMatrixf(glm::value_ptr(m));
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLBackend::fetchMatrix(GLenum target, glm::mat4 & m) {
|
||||||
|
switch (target) {
|
||||||
|
case GL_MODELVIEW_MATRIX:
|
||||||
|
case GL_PROJECTION_MATRIX:
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Lazy cheating
|
||||||
|
case GL_MODELVIEW:
|
||||||
|
target = GL_MODELVIEW_MATRIX;
|
||||||
|
break;
|
||||||
|
case GL_PROJECTION:
|
||||||
|
target = GL_PROJECTION_MATRIX;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Q_ASSERT_X(false, "GLBackend::fetchMatrix", "Bad matrix target");
|
||||||
|
}
|
||||||
|
glGetFloatv(target, glm::value_ptr(m));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,9 @@ public:
|
||||||
static GLShader* syncGPUObject(const Shader& shader);
|
static GLShader* syncGPUObject(const Shader& shader);
|
||||||
static GLuint getShaderID(const ShaderPointer& shader);
|
static GLuint getShaderID(const ShaderPointer& shader);
|
||||||
|
|
||||||
|
static void loadMatrix(GLenum target, const glm::mat4 & m);
|
||||||
|
static void fetchMatrix(GLenum target, glm::mat4 & m);
|
||||||
|
|
||||||
class GLState : public GPUObject {
|
class GLState : public GPUObject {
|
||||||
public:
|
public:
|
||||||
class Command {
|
class Command {
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#ifndef hifi_RenderUtil_h
|
#ifndef hifi_RenderUtil_h
|
||||||
#define hifi_RenderUtil_h
|
#define hifi_RenderUtil_h
|
||||||
|
|
||||||
|
#include <MatrixStack.h>
|
||||||
|
|
||||||
/// Renders a quad from (-1, -1, 0) to (1, 1, 0) with texture coordinates from (sMin, tMin) to (sMax, tMax).
|
/// Renders a quad from (-1, -1, 0) to (1, 1, 0) with texture coordinates from (sMin, tMin) to (sMax, tMax).
|
||||||
void renderFullscreenQuad(float sMin = 0.0f, float sMax = 1.0f, float tMin = 0.0f, float tMax = 1.0f);
|
void renderFullscreenQuad(float sMin = 0.0f, float sMax = 1.0f, float tMin = 0.0f, float tMax = 1.0f);
|
||||||
|
|
||||||
|
|
|
@ -548,18 +548,23 @@ float TextRenderer::draw(float x, float y, const QString & str,
|
||||||
|
|
||||||
float scale = (_pointSize / DEFAULT_POINT_SIZE) * 0.25f;
|
float scale = (_pointSize / DEFAULT_POINT_SIZE) * 0.25f;
|
||||||
glm::vec2 result;
|
glm::vec2 result;
|
||||||
MatrixStack::withGlMatrices([&] {
|
|
||||||
|
MatrixStack::withPushAll([&] {
|
||||||
MatrixStack & mv = MatrixStack::modelview();
|
MatrixStack & mv = MatrixStack::modelview();
|
||||||
// scale the modelview into font units
|
MatrixStack & pr = MatrixStack::projection();
|
||||||
// FIXME migrate the constant scale factor into the geometry of the
|
gpu::GLBackend::fetchMatrix(GL_MODELVIEW_MATRIX, mv.top());
|
||||||
// fonts so we don't have to flip the Y axis here and don't have to
|
gpu::GLBackend::fetchMatrix(GL_PROJECTION_MATRIX, pr.top());
|
||||||
// scale at all.
|
|
||||||
mv.translate(glm::vec2(x, y)).scale(glm::vec3(scale, -scale, scale));
|
// scale the modelview into font units
|
||||||
// The font does all the OpenGL work
|
// FIXME migrate the constant scale factor into the geometry of the
|
||||||
if (_font) {
|
// fonts so we don't have to flip the Y axis here and don't have to
|
||||||
result = _font->drawString(x, y, str, actualColor, _effectType, bounds / scale);
|
// scale at all.
|
||||||
}
|
mv.translate(glm::vec2(x, y)).scale(glm::vec3(scale, -scale, scale));
|
||||||
});
|
// The font does all the OpenGL work
|
||||||
|
if (_font) {
|
||||||
|
result = _font->drawString(x, y, str, actualColor, _effectType, bounds / scale);
|
||||||
|
}
|
||||||
|
});
|
||||||
return result.x;
|
return result.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,6 @@
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
|
||||||
#include <gpu/GPUConfig.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MatrixStack : public std::stack<glm::mat4> {
|
class MatrixStack : public std::stack<glm::mat4> {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -183,22 +179,5 @@ public:
|
||||||
stack2.withPush(f);
|
stack2.withPush(f);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Function>
|
|
||||||
static void withGlMatrices(Function f) {
|
|
||||||
// Push the current stack, and then copy the values out of OpenGL
|
|
||||||
withPushAll([&] {
|
|
||||||
// Fetch the current matrices out of GL stack
|
|
||||||
// FIXME, eliminate the usage of deprecated GL
|
|
||||||
MatrixStack & mv = MatrixStack::modelview();
|
|
||||||
MatrixStack & pr = MatrixStack::projection();
|
|
||||||
glm::mat4 & mvm = mv.top();
|
|
||||||
glGetFloatv(GL_MODELVIEW_MATRIX, &(mvm[0][0]));
|
|
||||||
|
|
||||||
glm::mat4 & prm = pr.top();
|
|
||||||
glGetFloatv(GL_PROJECTION_MATRIX, &(prm[0][0]));
|
|
||||||
f();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue