First version to update OpenSpace to the new SGCT version

This commit is contained in:
Alexander Bock
2015-10-05 00:07:38 +02:00
parent 6801c4e9a9
commit 35e95b94e7
7 changed files with 84 additions and 66 deletions
+4 -3
View File
@@ -128,7 +128,8 @@ int main(int argc, char** argv) {
_sgctEngine->setExternalControlCallback(mainExternalControlCallback);
_sgctEngine->setCharCallbackFunction(mainCharCallback);
_sgctEngine->setFisheyeClearColor(0.f, 0.f, 0.f);
// _sgctEngine->setFisheyeClearColor(0.f, 0.f, 0.f);
// set encode and decode functions
// NOTE: starts synchronizing before init functions
@@ -214,13 +215,13 @@ void mainRenderFunc() {
mat4 userMatrix = translate(mat4(1.f), _sgctEngine->getDefaultUserPtr()->getPos());
mat4 sceneMatrix = _sgctEngine->getModelMatrix();
mat4 viewMatrix = _sgctEngine->getActiveViewMatrix() * userMatrix;
mat4 viewMatrix = _sgctEngine->getCurrentViewMatrix() * userMatrix;
//dont shift nav-direction on master, makes it very tricky to navigate @JK
if (!OsEng.ref().isMaster())
viewMatrix = viewMatrix * sceneMatrix;
mat4 projectionMatrix = _sgctEngine->getActiveProjectionMatrix();
mat4 projectionMatrix = _sgctEngine->getCurrentProjectionMatrix();
OsEng.render(projectionMatrix, viewMatrix);
}
+3 -2
View File
@@ -331,8 +331,9 @@ void ABuffer::invalidateABuffer() {
}
void ABuffer::updateDimensions() {
_width = sgct::Engine::instance()->getActiveWindowPtr()->getXFramebufferResolution();
_height = sgct::Engine::instance()->getActiveWindowPtr()->getYFramebufferResolution();
_width = sgct::Engine::instance()->getCurrentWindowPtr()->getXFramebufferResolution();
_height = sgct::Engine::instance()->getCurrentWindowPtr()->getYFramebufferResolution();
_totalPixels = _width * _height;
}
+25 -25
View File
@@ -113,7 +113,7 @@ void ABufferVisualizer::render() {
modelMatrix = glm::translate(modelMatrix, glm::vec3(0, 0, -1));
modelMatrix = modelMatrix * rotation;
_pointcloudProgram->setUniform("ViewProjection", sgct::Engine::instance()->getActiveModelViewProjectionMatrix());
_pointcloudProgram->setUniform("ViewProjection", sgct::Engine::instance()->getCurrentModelViewProjectionMatrix());
_pointcloudProgram->setUniform("ModelTransform", modelMatrix);
#if defined(MARKER_POINTS)
@@ -145,30 +145,30 @@ void ABufferVisualizer::render() {
const glm::mat4 scale = glm::scale(glm::mat4(1.0), glm::vec3(0.04, 0.04, 0.04));
glm::mat4 translate, mvp;
translate = glm::translate(glm::mat4(1.0), glm::vec3(0, 0, 0));
mvp = sgct::Engine::instance()->getActiveModelViewProjectionMatrix()*modelMatrix*translate*rotationText*scale;
Freetype::print3d(fontLight, mvp, "(0,0,0)");
translate = glm::translate(glm::mat4(1.0), glm::vec3(0, 0, 1));
mvp = sgct::Engine::instance()->getActiveModelViewProjectionMatrix()*modelMatrix*translate*rotationText*scale;
Freetype::print3d(fontLight, mvp, "(0,0,1)");
translate = glm::translate(glm::mat4(1.0), glm::vec3(0, 1, 0));
mvp = sgct::Engine::instance()->getActiveModelViewProjectionMatrix()*modelMatrix*translate*rotationText*scale;
Freetype::print3d(fontLight, mvp, "(0,1,0)");
translate = glm::translate(glm::mat4(1.0), glm::vec3(1, 0, 0));
mvp = sgct::Engine::instance()->getActiveModelViewProjectionMatrix()*modelMatrix*translate*rotationText*scale;
Freetype::print3d(fontLight, mvp, "(1,0,0)");
translate = glm::translate(glm::mat4(1.0), glm::vec3(0, 1, 1));
mvp = sgct::Engine::instance()->getActiveModelViewProjectionMatrix()*modelMatrix*translate*rotationText*scale;
Freetype::print3d(fontLight, mvp, "(0,1,1)");
translate = glm::translate(glm::mat4(1.0), glm::vec3(1, 0, 1));
mvp = sgct::Engine::instance()->getActiveModelViewProjectionMatrix()*modelMatrix*translate*rotationText*scale;
Freetype::print3d(fontLight, mvp, "(1,0,1)");
translate = glm::translate(glm::mat4(1.0), glm::vec3(1, 1, 0));
mvp = sgct::Engine::instance()->getActiveModelViewProjectionMatrix()*modelMatrix*translate*rotationText*scale;
Freetype::print3d(fontLight, mvp, "(1,1,0)");
translate = glm::translate(glm::mat4(1.0), glm::vec3(1, 1, 1));
mvp = sgct::Engine::instance()->getActiveModelViewProjectionMatrix()*modelMatrix*translate*rotationText*scale;
Freetype::print3d(fontLight, mvp, "(1,1,1)");
// translate = glm::translate(glm::mat4(1.0), glm::vec3(0, 0, 0));
// mvp = sgct::Engine::instance()->getCurrentModelViewProjectionMatrix()*modelMatrix*translate*rotationText*scale;
// Freetype::print3d(fontLight, mvp, "(0,0,0)");
// translate = glm::translate(glm::mat4(1.0), glm::vec3(0, 0, 1));
// mvp = sgct::Engine::instance()->getCurrentModelViewProjectionMatrix()*modelMatrix*translate*rotationText*scale;
// Freetype::print3d(fontLight, mvp, "(0,0,1)");
// translate = glm::translate(glm::mat4(1.0), glm::vec3(0, 1, 0));
// mvp = sgct::Engine::instance()->getCurrentModelViewProjectionMatrix()*modelMatrix*translate*rotationText*scale;
// Freetype::print3d(fontLight, mvp, "(0,1,0)");
// translate = glm::translate(glm::mat4(1.0), glm::vec3(1, 0, 0));
// mvp = sgct::Engine::instance()->getCurrentModelViewProjectionMatrix()*modelMatrix*translate*rotationText*scale;
// Freetype::print3d(fontLight, mvp, "(1,0,0)");
// translate = glm::translate(glm::mat4(1.0), glm::vec3(0, 1, 1));
// mvp = sgct::Engine::instance()->getCurrentModelViewProjectionMatrix()*modelMatrix*translate*rotationText*scale;
// Freetype::print3d(fontLight, mvp, "(0,1,1)");
// translate = glm::translate(glm::mat4(1.0), glm::vec3(1, 0, 1));
// mvp = sgct::Engine::instance()->getCurrentModelViewProjectionMatrix()*modelMatrix*translate*rotationText*scale;
// Freetype::print3d(fontLight, mvp, "(1,0,1)");
// translate = glm::translate(glm::mat4(1.0), glm::vec3(1, 1, 0));
// mvp = sgct::Engine::instance()->getCurrentModelViewProjectionMatrix()*modelMatrix*translate*rotationText*scale;
// Freetype::print3d(fontLight, mvp, "(1,1,0)");
// translate = glm::translate(glm::mat4(1.0), glm::vec3(1, 1, 1));
// mvp = sgct::Engine::instance()->getCurrentModelViewProjectionMatrix()*modelMatrix*translate*rotationText*scale;
// Freetype::print3d(fontLight, mvp, "(1,1,1)");
}
void ABufferVisualizer::initializeMarkers() {
+6 -4
View File
@@ -690,10 +690,12 @@ void OpenSpaceEngine::render(const glm::mat4 &projectionMatrix, const glm::mat4
if (_isMaster) {
// If currently writing a command, render it to screen
sgct::SGCTWindow* w = sgct::Engine::instance()->getActiveWindowPtr();
if (_isMaster && !w->isUsingFisheyeRendering() && _console->isVisible()) {
_console->render();
}
sgct::SGCTWindow* w = sgct::Engine::instance()->getCurrentWindowPtr();
// !w->isUsingFisheyeRendering() does not exist anymore ---abock
// if (_isMaster && !w->isUsingFisheyeRendering() && _console->isVisible()) {
if (_isMaster && _console->isVisible()) {
_console->render();
}
if (_gui->isEnabled())
_gui->endFrame();
+7 -4
View File
@@ -286,7 +286,7 @@ void LuaConsole::charCallback(unsigned int codepoint) {
void LuaConsole::render() {
const float font_size = 10.0f;
int x1, xSize, y1, ySize;
sgct::Engine::instance()->getActiveWindowPtr()->getCurrentViewportPixelCoords(x1, y1, xSize, ySize);
sgct::Engine::instance()->getCurrentWindowPtr()->getCurrentViewportPixelCoords(x1, y1, xSize, ySize);
float startY = static_cast<float>(ySize) - 2.0f * font_size;
startY = startY - font_size * 15.0f * 2.0f;
@@ -294,8 +294,10 @@ void LuaConsole::render() {
const glm::vec4 green(0, 1, 0, 1);
const glm::vec4 white(1, 1, 1, 1);
const sgct_text::Font* font = sgct_text::FontManager::instance()->getFont(constants::fonts::keyMono, static_cast<int>(font_size));
Freetype::print(font, 15.0f, startY, red, "$");
Freetype::print(font, 15.0f + font_size, startY, white, "%s", _commands.at(_activeCommand).c_str());
// sgct_text::print(font, 15.0f, startY, red, "$");
// sgct_text::print(font, 15.0f + font_size, startY, white, "%s", _commands.at(_activeCommand).c_str());
sgct_text::print(font, 15.0f, startY, "$");
sgct_text::print(font, 15.0f + font_size, startY, "%s", _commands.at(_activeCommand).c_str());
size_t n = std::count(_commands.at(_activeCommand).begin(), _commands.at(_activeCommand).begin() + _inputPosition, '\n');
size_t p = _commands.at(_activeCommand).find_last_of('\n', _inputPosition);
@@ -318,7 +320,8 @@ void LuaConsole::render() {
std::stringstream ss;
ss << "%" << linepos + 1 << "s";
Freetype::print(font, 15.0f + font_size*0.5f, startY - (font_size)*(n + 1)*3.0f / 2.0f, green, ss.str().c_str(), "^");
// sgct_text::print(font, 15.0f + font_size*0.5f, startY - (font_size)*(n + 1)*3.0f / 2.0f, green, ss.str().c_str(), "^");
sgct_text::print(font, 15.0f + font_size*0.5f, startY - (font_size)*(n + 1)*3.0f / 2.0f, ss.str().c_str(), "^");
}
unsigned int LuaConsole::commandInputButton() {
+6 -6
View File
@@ -72,8 +72,8 @@ glm::vec3 MouseController::mapToCamera(glm::vec3 trackballPos) {
void MouseController::trackballRotate(int x, int y) {
// Normalize mouse coordinates to [0,1]
float width = static_cast<float>(sgct::Engine::instance()->getActiveXResolution());
float height = static_cast<float>(sgct::Engine::instance()->getActiveYResolution());
float width = static_cast<float>(sgct::Engine::instance()->getCurrentXResolution());
float height = static_cast<float>(sgct::Engine::instance()->getCurrentYResolution());
glm::vec2 mousePos = glm::vec2((float)x / width, (float)y / height);
mousePos = glm::clamp(mousePos, -0.5, 1.5); // Ugly fix #1: Camera position becomes NaN on mouse values outside [-0.5, 1.5]
@@ -167,7 +167,7 @@ void OrbitalMouseController::button(MouseAction action, MouseButton button) {
if (action == MouseAction::Press){
_leftMouseButtonDown = true;
double mouseX, mouseY;
sgct::Engine::instance()->getMousePos(sgct::Engine::instance()->getActiveWindowPtr()->getId(), &mouseX, &mouseY);
sgct::Engine::instance()->getMousePos(sgct::Engine::instance()->getCurrentWindowPtr()->getId(), &mouseX, &mouseY);
_previousCursorPos[MouseButtons::ButtonLeft] = glm::vec2(static_cast<float>(mouseX), static_cast<float>(mouseY));
}
else if (action == MouseAction::Release) {
@@ -179,7 +179,7 @@ void OrbitalMouseController::button(MouseAction action, MouseButton button) {
if (action == MouseAction::Press){
_rightMouseButtonDown = true;
double mouseX, mouseY;
sgct::Engine::instance()->getMousePos(sgct::Engine::instance()->getActiveWindowPtr()->getId(), &mouseX, &mouseY);
sgct::Engine::instance()->getMousePos(sgct::Engine::instance()->getCurrentWindowPtr()->getId(), &mouseX, &mouseY);
_previousCursorPos[MouseButtons::ButtonRight] = glm::vec2(static_cast<float>(mouseX), static_cast<float>(mouseY));
}
else if (action == MouseAction::Release) {
@@ -191,7 +191,7 @@ void OrbitalMouseController::button(MouseAction action, MouseButton button) {
if (action == MouseAction::Press){
_middleMouseButtonDown = true;
double mouseX, mouseY;
sgct::Engine::instance()->getMousePos(sgct::Engine::instance()->getActiveWindowPtr()->getId(), &mouseX, &mouseY);
sgct::Engine::instance()->getMousePos(sgct::Engine::instance()->getCurrentWindowPtr()->getId(), &mouseX, &mouseY);
_previousCursorPos[MouseButtons::ButtonMiddle] = glm::vec2(static_cast<float>(mouseX), static_cast<float>(mouseY));
}
else if (action == MouseAction::Release) {
@@ -203,7 +203,7 @@ void OrbitalMouseController::button(MouseAction action, MouseButton button) {
}
void OrbitalMouseController::move(float x, float y) {
int winID = sgct::Engine::instance()->getActiveWindowPtr()->getId();
int winID = sgct::Engine::instance()->getCurrentWindowPtr()->getId();
double mouseX, mouseY;
sgct::Engine::instance()->getMousePos(winID, &mouseX, &mouseY);
_currentCursorPos = glm::vec2(static_cast<float>(mouseX), static_cast<float>(mouseY));
+33 -22
View File
@@ -193,7 +193,7 @@ bool RenderEngine::initialize() {
bool RenderEngine::initializeGL() {
// LDEBUG("RenderEngine::initializeGL()");
sgct::SGCTWindow* wPtr = sgct::Engine::instance()->getActiveWindowPtr();
sgct::SGCTWindow* wPtr = sgct::Engine::instance()->getCurrentWindowPtr();
// TODO: Fix the power scaled coordinates in such a way that these
// values can be set to more realistic values
@@ -205,7 +205,7 @@ bool RenderEngine::initializeGL() {
// calculating the maximum field of view for the camera, used to
// determine visibility of objects in the scene graph
if (wPtr->isUsingFisheyeRendering()) {
/* if (sgct::Engine::instance()->getCurrentRenderTarget() == sgct::Engine::NonLinearBuffer) {
// fisheye mode, looking upwards to the "dome"
glm::vec4 upDirection(0, 1, 0, 0);
@@ -220,19 +220,19 @@ bool RenderEngine::initializeGL() {
_mainCamera->setMaxFov(wPtr->getFisheyeFOV());
_mainCamera->setLookUpVector(glm::vec3(0.0, 1.0, 0.0));
}
else {
else {*/
// get corner positions, calculating the forth to easily calculate center
glm::vec3 corners[4];
corners[0] = wPtr->getCurrentViewport()->getViewPlaneCoords(
sgct_core::Viewport::LowerLeft);
/*corners[0] = wPtr->getCurrentViewport()->getViewPlaneCoords(
sgct_core::SGCTProjectionPlane::LowerLeft);
corners[1] = wPtr->getCurrentViewport()->getViewPlaneCoords(
sgct_core::Viewport::UpperLeft);
sgct_core::SGCTProjectionPlane::UpperLeft);
corners[2] = wPtr->getCurrentViewport()->getViewPlaneCoords(
sgct_core::Viewport::UpperRight);
sgct_core::SGCTProjectionPlane::UpperRight);
corners[3] = glm::vec3(corners[2][0], corners[0][1], corners[2][2]);
*/
const glm::vec3 center = (corners[0] + corners[1] + corners[2] + corners[3])
/ 4.0f;
//#if 0
// // @TODO Remove the ifdef when the next SGCT version is released that requests the
@@ -267,7 +267,7 @@ bool RenderEngine::initializeGL() {
}
}
_mainCamera->setMaxFov(maxFov);
}
//}
LINFO("Initializing ABuffer");
_abuffer->initialize();
@@ -347,8 +347,9 @@ void RenderEngine::postSynchronizationPreDraw() {
void RenderEngine::render(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix) {
// We need the window pointer
sgct::SGCTWindow* w = sgct::Engine::instance()->getActiveWindowPtr();
if (w->isUsingFisheyeRendering())
sgct::SGCTWindow* w = sgct::Engine::instance()->getCurrentWindowPtr();
if (sgct::Engine::instance()->getCurrentRenderTarget() == sgct::Engine::NonLinearBuffer)
_abuffer->clear();
// SGCT resets certain settings
@@ -399,8 +400,10 @@ void RenderEngine::render(const glm::mat4 &projectionMatrix, const glm::mat4 &vi
#if 1
#define PrintText(__i__, __format__, ...) Freetype::print(font, 10.f, static_cast<float>(startY - font_size_mono * __i__ * 2), __format__, __VA_ARGS__);
#define PrintColorTextArg(__i__, __format__, __size__, __color__, ...) Freetype::print(font, __size__, static_cast<float>(startY - font_size_mono * __i__ * 2), __color__, __format__, __VA_ARGS__);
#define PrintColorText(__i__, __format__, __size__, __color__) Freetype::print(font, __size__, static_cast<float>(startY - font_size_mono * __i__ * 2), __color__, __format__);
#define PrintColorTextArg(__i__, __format__, __size__, __color__, ...) Freetype::print(font, __size__, static_cast<float>(startY - font_size_mono * __i__ * 2), __format__, __VA_ARGS__);
#define PrintColorText(__i__, __format__, __size__, __color__) Freetype::print(font, __size__, static_cast<float>(startY - font_size_mono * __i__ * 2), __format__);
//#define PrintColorTextArg(__i__, __format__, __size__, __color__, ...) Freetype::print(font, __size__, static_cast<float>(startY - font_size_mono * __i__ * 2), __color__, __format__, __VA_ARGS__);
//#define PrintColorText(__i__, __format__, __size__, __color__) Freetype::print(font, __size__, static_cast<float>(startY - font_size_mono * __i__ * 2), __color__, __format__);
if (_onScreenInformation._node != -1) {
//int thisId = sgct_core::ClusterManager::instance()->getThisNodeId();
@@ -415,7 +418,8 @@ void RenderEngine::render(const glm::mat4 &projectionMatrix, const glm::mat4 &vi
}
// Print some useful information on the master viewport
if (OsEng.ref().isMaster() && !w->isUsingFisheyeRendering()) {
if (OsEng.ref().isMaster() && sgct::Engine::instance()->getCurrentRenderTarget() != sgct::Engine::NonLinearBuffer) {
// TODO: Adjust font_size properly when using retina screen
const int font_size_mono = 10;
@@ -429,7 +433,7 @@ void RenderEngine::render(const glm::mat4 &projectionMatrix, const glm::mat4 &vi
if (_showInfo) {
const sgct_text::Font* font = fontMono;
int x1, xSize, y1, ySize;
sgct::Engine::instance()->getActiveWindowPtr()->getCurrentViewportPixelCoords(x1, y1, xSize, ySize);
sgct::Engine::instance()->getCurrentWindowPtr()->getCurrentViewportPixelCoords(x1, y1, xSize, ySize);
int startY = ySize - 2 * font_size_time;
//const glm::vec2& scaling = _mainCamera->scaling();
//const glm::vec3& viewdirection = _mainCamera->viewDirection();
@@ -450,7 +454,8 @@ void RenderEngine::render(const glm::mat4 &projectionMatrix, const glm::mat4 &vi
if (timeString.size() > 11)
// This should never happen, but it's an emergency hack ---abock
timeString[11] = ' ';
Freetype::print(fontTime, 10, static_cast<float>(startY - font_size_mono * line++ * 2), glm::vec4(1), "Date: %s", timeString.c_str());
// Freetype::print(fontTime, 10, static_cast<float>(startY - font_size_mono * line++ * 2), glm::vec4(1), "Date: %s", timeString.c_str());
Freetype::print(fontTime, 10, static_cast<float>(startY - font_size_mono * line++ * 2), "Date: %s", timeString.c_str());
glm::vec4 targetColor(0.00, 0.75, 1.00, 1);
double dt = Time::ref().deltaTime();
@@ -609,7 +614,8 @@ void RenderEngine::render(const glm::mat4 &projectionMatrix, const glm::mat4 &vi
const std::string& message = e->message.substr(0, msg_length);
nr += std::count(message.begin(), message.end(), '\n');
Freetype::print(font, 10.f, static_cast<float>(font_size_light * nr * 2), white*alpha,
// Freetype::print(font, 10.f, static_cast<float>(font_size_light * nr * 2), white*alpha,
Freetype::print(font, 10.f, static_cast<float>(font_size_light * nr * 2),
"%-14s %s%s", // Format
e->timeString.c_str(), // Time string
e->category.substr(0, category_length).c_str(), // Category string (up to category_length)
@@ -625,11 +631,16 @@ void RenderEngine::render(const glm::mat4 &projectionMatrix, const glm::mat4 &vi
if (e->level == ghoul::logging::LogManager::LogLevel::Fatal)
color = blue;
Freetype::print(font, static_cast<float>(10 + 39 * font_with_light), static_cast<float>(font_size_light * nr * 2), color*alpha, "%s", lvl.c_str());
Freetype::print(font, static_cast<float>(10 + 39 * font_with_light), static_cast<float>(font_size_light * nr * 2), "%s", lvl.c_str());
Freetype::print(font, static_cast<float>(10 + 53 * font_with_light), static_cast<float>(font_size_light * nr * 2), white*alpha, "%s", message.c_str());
++nr;
Freetype::print(font, static_cast<float>(10 + 53 * font_with_light), static_cast<float>(font_size_light * nr * 2), "%s", message.c_str());
// Freetype::print(font, static_cast<float>(10 + 39 * font_with_light), static_cast<float>(font_size_light * nr * 2), color*alpha, "%s", lvl.c_str());
// Freetype::print(font, static_cast<float>(10 + 53 * font_with_light), static_cast<float>(font_size_light * nr * 2), white*alpha, "%s", message.c_str());
++nr;
}
}
}
@@ -728,8 +739,8 @@ void RenderEngine::startFading(int direction, float fadeDuration) {
void RenderEngine::generateGlslConfig() {
ghoul_assert(_abuffer != nullptr, "ABuffer not initialized");
LDEBUG("Generating GLSLS config, expect shader recompilation");
int xSize = sgct::Engine::instance()->getActiveWindowPtr()->getXFramebufferResolution();;
int ySize = sgct::Engine::instance()->getActiveWindowPtr()->getYFramebufferResolution();;
int xSize = sgct::Engine::instance()->getCurrentWindowPtr()->getXFramebufferResolution();;
int ySize = sgct::Engine::instance()->getCurrentWindowPtr()->getYFramebufferResolution();;
// TODO: Make this file creation dynamic and better in every way
// TODO: If the screen size changes it is enough if this file is regenerated to