mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-09 21:21:19 -06:00
created postFX functions in main and added a postFX pass to sgct engine to allow for a global fade after executing certain scripts.
added global opacity member variable with set/get methods in render engine. added two VERY simple shaders used in the post FX pass. Note these are not handled in openspace so updating files does not update shader
This commit is contained in:
30
src/main.cpp
30
src/main.cpp
@@ -24,8 +24,9 @@
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/logging/logging>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <sgct.h>
|
||||
|
||||
sgct::Engine* _sgctEngine;
|
||||
@@ -46,6 +47,12 @@ void mainDecodeFun();
|
||||
void mainExternalControlCallback(const char * receivedChars, int size);
|
||||
void mainLogCallback(const char* msg);
|
||||
|
||||
//temporary post-FX functions, TODO make a more permanent solution to this @JK
|
||||
void postFXPass();
|
||||
void setupPostFX();
|
||||
GLint _postFXTexLoc;
|
||||
GLint _postFXOpacityLoc;
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "main";
|
||||
}
|
||||
@@ -140,6 +147,9 @@ void mainInitFunc()
|
||||
std::cin.ignore(100);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
//temporary post-FX solution, TODO add a more permanent solution @JK
|
||||
setupPostFX();
|
||||
}
|
||||
|
||||
void mainPreSyncFunc()
|
||||
@@ -226,4 +236,22 @@ void mainLogCallback(const char* msg){
|
||||
std::string message = msg;
|
||||
// Remove the trailing \n that is passed along
|
||||
LINFOC("SGCT", message.substr(0, std::max<size_t>(message.size() - 1, 0)));
|
||||
}
|
||||
|
||||
void postFXPass(){
|
||||
glUniform1i(_postFXTexLoc, 0);
|
||||
glUniform1f(_postFXOpacityLoc, OsEng.ref().renderEngine()->globalOpacity());
|
||||
}
|
||||
|
||||
void setupPostFX(){
|
||||
sgct::PostFX fx[1];
|
||||
sgct::ShaderProgram *shader;
|
||||
fx[0].init("OpacityControl", absPath("${SHADERS}/postFX_vs.glsl"), absPath("${SHADERS}/postFX_fs.glsl"));
|
||||
fx[0].setUpdateUniformsFunction(postFXPass);
|
||||
shader = fx[0].getShaderProgram();
|
||||
shader->bind();
|
||||
_postFXTexLoc = shader->getUniformLocation("Tex");
|
||||
_postFXOpacityLoc = shader->getUniformLocation("Opacity");
|
||||
shader->unbind();
|
||||
_sgctEngine->addPostFX(fx[0]);
|
||||
}
|
||||
Reference in New Issue
Block a user