changing render function of openspaceengine and renderengine to take glm::mat4 matrices for Projection / ViewMatrix.

This commit is contained in:
Joakim Kilby
2015-02-19 15:19:20 +01:00
parent d96b7146e3
commit dce4835bab
5 changed files with 29 additions and 20 deletions

View File

@@ -75,7 +75,7 @@ public:
bool initializeGL();
void preSynchronization();
void postSynchronizationPreDraw();
void render();
void render(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix);
void postDraw();
void keyboardCallback(int key, int action);
void charCallback(unsigned int codepoint);

View File

@@ -60,7 +60,7 @@ public:
bool initializeGL();
void postSynchronizationPreDraw();
void preSynchronization();
void render();
void render(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix);
void postDraw();
void takeScreenshot();

View File

@@ -567,8 +567,8 @@ void OpenSpaceEngine::postSynchronizationPreDraw() {
}
}
void OpenSpaceEngine::render() {
_renderEngine->render();
void OpenSpaceEngine::render(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix) {
_renderEngine->render(projectionMatrix, viewMatrix);
if (sgct::Engine::instance()->isMaster()) {
// If currently writing a command, render it to screen
@@ -576,7 +576,7 @@ void OpenSpaceEngine::render() {
if (sgct::Engine::instance()->isMaster() && !w->isUsingFisheyeRendering() && _console->isVisible()) {
_console->render();
}
if (_gui->isEnabled())
_gui->endFrame();
}

View File

@@ -162,7 +162,10 @@ void mainPostSyncPreDrawFunc()
void mainRenderFunc()
{
OsEng.render();
glm::mat4 userMatrix = glm::translate(glm::mat4(1.f), -_sgctEngine->getUserPtr()->getPos());
glm::mat4 viewMatrix = _sgctEngine->getActiveModelViewMatrix() * userMatrix;
glm::mat4 projectionMatrix = _sgctEngine->getActiveProjectionMatrix();
OsEng.render(projectionMatrix, viewMatrix);
}
void mainPostDrawFunc()

View File

@@ -347,7 +347,7 @@ namespace openspace {
}
void RenderEngine::render()
void RenderEngine::render(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix)
{
// We need the window pointer
sgct::SGCTWindow* w = sgct::Engine::instance()->getActiveWindowPtr();
@@ -371,25 +371,31 @@ namespace openspace {
const glm::vec3 eyePosition
= sgct_core::ClusterManager::instance()->getUserPtr("")->getPos();
#else
const glm::vec3 eyePosition
= sgct_core::ClusterManager::instance()->getUserPtr()->getPos();
//const glm::vec3 eyePosition
// = sgct_core::ClusterManager::instance()->getUserPtr()->getPos();
#endif
//@CHECK does the dome disparity disappear if this line disappears? ---abock
const glm::mat4 view
= glm::translate(glm::mat4(1.0),
eyePosition); // make sure the eye is in the center
_mainCamera->setViewProjectionMatrix(
sgct::Engine::instance()->getActiveModelViewProjectionMatrix() * view);
//const glm::mat4 view
// = glm::translate(glm::mat4(1.0),
// eyePosition); // make sure the eye is in the center
//_mainCamera->setViewProjectionMatrix(
// sgct::Engine::instance()->getActiveModelViewProjectionMatrix() * view);
_mainCamera->setModelMatrix(
sgct::Engine::instance()->getModelMatrix());
//_mainCamera->setModelMatrix(
// sgct::Engine::instance()->getModelMatrix());
_mainCamera->setViewMatrix(
sgct::Engine::instance()->getActiveViewMatrix()* view);
//_mainCamera->setViewMatrix(
// sgct::Engine::instance()->getActiveViewMatrix()* view);
_mainCamera->setProjectionMatrix(
sgct::Engine::instance()->getActiveProjectionMatrix());
//_mainCamera->setProjectionMatrix(
// sgct::Engine::instance()->getActiveProjectionMatrix());
_mainCamera->setViewMatrix(viewMatrix);
_mainCamera->setProjectionMatrix(projectionMatrix);
//is this really necessary?
_mainCamera->setViewProjectionMatrix(projectionMatrix * viewMatrix);
// render the scene starting from the root node
if (!_visualizeABuffer) {