Commit 444de9ee authored by Robert Menzel's avatar Robert Menzel
Browse files

started working on internal fallback shaders

parent fdc6494d
#pragma once #pragma once
/** /**
* IMPORTANT: * IMPORTANT: DON'T EXPECT THIS CLASS TO HAVE A FINAL AND STABLE API!
* *
* This class needs the LibOVR version 0.2.4 or higher to work. * This class needs the LibOVR version 0.2.4 or higher to work.
* Headers of this lib need to be placed in the search path. * Headers of this lib need to be placed in the search path.
* *
* In addition ACGL_USE_OCULUS_RIFT has to be defined. * In addition ACGL_USE_OCULUS_RIFT has to be defined.
* *
*
*/ */
#include <ACGL/ACGL.hh> #include <ACGL/ACGL.hh>
#define ACGL_USE_OCULUS_RIFT
#ifdef ACGL_USE_OCULUS_RIFT #ifdef ACGL_USE_OCULUS_RIFT
#include <ACGL/Math/Math.hh> #include <ACGL/Math/Math.hh>
...@@ -159,6 +160,7 @@ public: ...@@ -159,6 +160,7 @@ public:
//! Note: if the user is just looking in the wrong direction, use setNeutralYaw(), if e.g. looking up should be //! Note: if the user is just looking in the wrong direction, use setNeutralYaw(), if e.g. looking up should be
//! neutral (laying on the ground), this is the way to go. //! neutral (laying on the ground), this is the way to go.
void setNeutralPosition(); void setNeutralPosition();
void resetNeutralRotation() {setNeutralPosition();}
//! Will define the current view direction as the neutral direction but only takes yaw into account. //! Will define the current view direction as the neutral direction but only takes yaw into account.
//! Will also reset the neutral position. //! Will also reset the neutral position.
...@@ -167,8 +169,8 @@ public: ...@@ -167,8 +169,8 @@ public:
private: private:
ACGL::OpenGL::ConstSharedShaderProgram mDistortShaderSideBySide; ACGL::OpenGL::SharedShaderProgram mDistortShaderSideBySide;
ACGL::OpenGL::ConstSharedShaderProgram mDistortShaderTwoTextures; ACGL::OpenGL::SharedShaderProgram mDistortShaderTwoTextures;
bool mUseDistortion; bool mUseDistortion;
bool mUseChromaticAberation; bool mUseChromaticAberation;
......
...@@ -205,8 +205,8 @@ public: ...@@ -205,8 +205,8 @@ public:
virtual ~MultiFileManager(void) {} virtual ~MultiFileManager(void) {}
template<typename CONTROLLER> template<typename CONTROLLER>
ConstSharedRESOURCE get(const CONTROLLER& _controller); SharedRESOURCE get(const CONTROLLER& _controller);
ConstSharedRESOURCE query(const std::string& _filename); SharedRESOURCE query(const std::string& _filename);
bool exists(const std::string& _key); bool exists(const std::string& _key);
bool erase(const std::string& key); bool erase(const std::string& key);
void eraseAll(void); void eraseAll(void);
...@@ -226,7 +226,7 @@ private: ...@@ -226,7 +226,7 @@ private:
}; };
template<typename RESOURCE> template<typename CONTROLLER> template<typename RESOURCE> template<typename CONTROLLER>
typename MultiFileManager<RESOURCE>::ConstSharedRESOURCE MultiFileManager<RESOURCE>::get(const CONTROLLER& _controller) typename MultiFileManager<RESOURCE>::SharedRESOURCE MultiFileManager<RESOURCE>::get(const CONTROLLER& _controller)
{ {
typename ResourceMap::iterator existingResource = mResourceMap.find(_controller.getResourceName()); typename ResourceMap::iterator existingResource = mResourceMap.find(_controller.getResourceName());
if(existingResource != mResourceMap.end()) if(existingResource != mResourceMap.end())
...@@ -249,7 +249,7 @@ typename MultiFileManager<RESOURCE>::ConstSharedRESOURCE MultiFileManager<RESOUR ...@@ -249,7 +249,7 @@ typename MultiFileManager<RESOURCE>::ConstSharedRESOURCE MultiFileManager<RESOUR
} }
template<typename RESOURCE> template<typename RESOURCE>
typename MultiFileManager<RESOURCE>::ConstSharedRESOURCE MultiFileManager<RESOURCE>::query(const std::string& _key) typename MultiFileManager<RESOURCE>::SharedRESOURCE MultiFileManager<RESOURCE>::query(const std::string& _key)
{ {
typename ResourceMap::iterator existingResource = mResourceMap.find(_key); typename ResourceMap::iterator existingResource = mResourceMap.find(_key);
if(existingResource != mResourceMap.end()) if(existingResource != mResourceMap.end())
......
...@@ -8,6 +8,7 @@ using namespace ACGL; ...@@ -8,6 +8,7 @@ using namespace ACGL;
using namespace ACGL::Utils; using namespace ACGL::Utils;
using namespace ACGL::Scene; using namespace ACGL::Scene;
using namespace ACGL::HardwareSupport; using namespace ACGL::HardwareSupport;
using namespace ACGL::OpenGL;
using namespace std; using namespace std;
...@@ -350,14 +351,33 @@ glm::vec4 SimpleRiftController::getChromAbParam() ...@@ -350,14 +351,33 @@ glm::vec4 SimpleRiftController::getChromAbParam()
// //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const char *VS_SOURCE = "foo";
const char *FS_SOURCE_SIDE_BY_SIDE = "bar";
const char *FS_SOURCE_TWO_TEXTURE = "TODO";
void SimpleRiftController::renderDistorted( OpenGL::ConstSharedTexture2D _sideBySideTexture ) void SimpleRiftController::renderDistorted( OpenGL::ConstSharedTexture2D _sideBySideTexture )
{ {
if (!mDistortShaderSideBySide) { if (!mDistortShaderSideBySide) {
// initialize shaders: // initialize shaders:
mDistortShaderSideBySide = OpenGL::ShaderProgramFileManager::the()->get( OpenGL::ShaderProgramCreator("RiftDistortSideBySide.fsh").andFile("RiftDistort.vsh") ); mDistortShaderSideBySide = OpenGL::ShaderProgramFileManager::the()->get( OpenGL::ShaderProgramCreator("RiftDistortSideBySide.fsh").andFile("RiftDistort.vsh") );
if (!mDistortShaderSideBySide) { if (!mDistortShaderSideBySide) {
ACGL::Utils::error() << "could not load distortion shader!" << std::endl; ACGL::Utils::debug() << "SimpleRiftController: using build-in shaders" << std::endl;
return;
mDistortShaderSideBySide = SharedShaderProgram( new ShaderProgram() );
SharedShader vs = SharedShader( new Shader( GL_VERTEX_SHADER ) );
vs->setSource( VS_SOURCE );
SharedShader fs = SharedShader( new Shader( GL_FRAGMENT_SHADER ) );
fs->setSource( FS_SOURCE_SIDE_BY_SIDE );
mDistortShaderSideBySide->attachShader( vs );
mDistortShaderSideBySide->attachShader( fs );
mDistortShaderSideBySide->link();
} else {
ACGL::Utils::debug() << "SimpleRiftController: using application provided shaders" << std::endl;
} }
} }
...@@ -372,8 +392,22 @@ void SimpleRiftController::renderDistorted( OpenGL::ConstSharedTexture2D _leftTe ...@@ -372,8 +392,22 @@ void SimpleRiftController::renderDistorted( OpenGL::ConstSharedTexture2D _leftTe
// initialize shaders: // initialize shaders:
mDistortShaderTwoTextures = OpenGL::ShaderProgramFileManager::the()->get( OpenGL::ShaderProgramCreator("RiftDistortTwoTexture.fsh").andFile("RiftDistort.vsh") ); mDistortShaderTwoTextures = OpenGL::ShaderProgramFileManager::the()->get( OpenGL::ShaderProgramCreator("RiftDistortTwoTexture.fsh").andFile("RiftDistort.vsh") );
if (!mDistortShaderTwoTextures) { if (!mDistortShaderTwoTextures) {
ACGL::Utils::error() << "could not load distortion shader!" << std::endl; ACGL::Utils::debug() << "SimpleRiftController: using build-in shaders" << std::endl;
return;
mDistortShaderTwoTextures = SharedShaderProgram( new ShaderProgram() );
SharedShader vs = SharedShader( new Shader( GL_VERTEX_SHADER ) );
vs->setSource( VS_SOURCE );
SharedShader fs = SharedShader( new Shader( GL_FRAGMENT_SHADER ) );
fs->setSource( FS_SOURCE_TWO_TEXTURE );
mDistortShaderTwoTextures->attachShader( vs );
mDistortShaderTwoTextures->attachShader( fs );
mDistortShaderTwoTextures->link();
} else {
ACGL::Utils::debug() << "SimpleRiftController: using application provided shaders" << std::endl;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment