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

started working on internal fallback shaders

parent fdc6494d
#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.
* Headers of this lib need to be placed in the search path.
*
* In addition ACGL_USE_OCULUS_RIFT has to be defined.
*
*
*/
#include <ACGL/ACGL.hh>
#define ACGL_USE_OCULUS_RIFT
#ifdef ACGL_USE_OCULUS_RIFT
#include <ACGL/Math/Math.hh>
......@@ -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
//! neutral (laying on the ground), this is the way to go.
void setNeutralPosition();
void resetNeutralRotation() {setNeutralPosition();}
//! Will define the current view direction as the neutral direction but only takes yaw into account.
//! Will also reset the neutral position.
......@@ -167,8 +169,8 @@ public:
private:
ACGL::OpenGL::ConstSharedShaderProgram mDistortShaderSideBySide;
ACGL::OpenGL::ConstSharedShaderProgram mDistortShaderTwoTextures;
ACGL::OpenGL::SharedShaderProgram mDistortShaderSideBySide;
ACGL::OpenGL::SharedShaderProgram mDistortShaderTwoTextures;
bool mUseDistortion;
bool mUseChromaticAberation;
......
......@@ -205,8 +205,8 @@ public:
virtual ~MultiFileManager(void) {}
template<typename CONTROLLER>
ConstSharedRESOURCE get(const CONTROLLER& _controller);
ConstSharedRESOURCE query(const std::string& _filename);
SharedRESOURCE get(const CONTROLLER& _controller);
SharedRESOURCE query(const std::string& _filename);
bool exists(const std::string& _key);
bool erase(const std::string& key);
void eraseAll(void);
......@@ -226,7 +226,7 @@ private:
};
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());
if(existingResource != mResourceMap.end())
......@@ -249,7 +249,7 @@ typename MultiFileManager<RESOURCE>::ConstSharedRESOURCE MultiFileManager<RESOUR
}
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);
if(existingResource != mResourceMap.end())
......
......@@ -8,6 +8,7 @@ using namespace ACGL;
using namespace ACGL::Utils;
using namespace ACGL::Scene;
using namespace ACGL::HardwareSupport;
using namespace ACGL::OpenGL;
using namespace std;
......@@ -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 )
{
if (!mDistortShaderSideBySide) {
// initialize shaders:
mDistortShaderSideBySide = OpenGL::ShaderProgramFileManager::the()->get( OpenGL::ShaderProgramCreator("RiftDistortSideBySide.fsh").andFile("RiftDistort.vsh") );
if (!mDistortShaderSideBySide) {
ACGL::Utils::error() << "could not load distortion shader!" << std::endl;
return;
ACGL::Utils::debug() << "SimpleRiftController: using build-in shaders" << std::endl;
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
// initialize shaders:
mDistortShaderTwoTextures = OpenGL::ShaderProgramFileManager::the()->get( OpenGL::ShaderProgramCreator("RiftDistortTwoTexture.fsh").andFile("RiftDistort.vsh") );
if (!mDistortShaderTwoTextures) {
ACGL::Utils::error() << "could not load distortion shader!" << std::endl;
return;
ACGL::Utils::debug() << "SimpleRiftController: using build-in shaders" << std::endl;
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