Commit 369de43a authored by schurade's avatar schurade
Browse files

[ADD] moved modules to their new home, added some preliminary shader support

parent 9b490e28
......@@ -132,8 +132,9 @@ ELSE ( NOT CMAKE_BUILD_TYPE STREQUAL "Static" )
TARGET_LINK_LIBRARIES( walnut ${Boost_LIBRARIES} ${OSG_LIBRARIES} ${QT_LINK_LIBRARIES} ${GLEW_LIBRARY} )
ENDIF ( NOT CMAKE_BUILD_TYPE STREQUAL "Static" )
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin/shaders)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/modules/navigationSlices/slice.vs ${CMAKE_BINARY_DIR}/bin/shaders/)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/modules/navigationSlices/slice.fs ${CMAKE_BINARY_DIR}/bin/shaders/)
# Special targets:
#-------------------------------------------------------------------------------------------------------------
......
FILE( GLOB KERNEL_SRC "*.cpp" )
FILE( GLOB MODULES_SRC "../modules/navigationSlices/*.cpp" )
ADD_LIBRARY( kernel SHARED ${KERNEL_SRC} )
ADD_LIBRARY( kernel SHARED ${KERNEL_SRC} ${MODULES_SRC})
TARGET_LINK_LIBRARIES( kernel common ge )
......@@ -10,7 +11,6 @@ IF( CXXTEST_FOUND )
"" # no libs for linking required
"WKernel.cpp"
"WModule.cpp"
"WTestModule.cpp"
"WNavigationSliceModule.cpp"
"../modules/navigationSlices/WNavigationSliceModule.cpp"
)
ENDIF( CXXTEST_FOUND )
......@@ -30,8 +30,7 @@
#include "WKernel.h"
#include "WModule.h"
#include "WTestModule.h"
#include "WNavigationSliceModule.h"
#include "../modules/navigationSlices/WNavigationSliceModule.h"
#include "../common/WException.h"
#include "../graphicsEngine/WGraphicsEngine.h"
......
......@@ -30,7 +30,7 @@
#include <osg/Geometry>
#include "WNavigationSliceModule.h"
#include "WKernel.h"
#include "../../kernel/WKernel.h"
WNavigationSliceModule::WNavigationSliceModule():
WModule()
......@@ -51,12 +51,12 @@ WNavigationSliceModule::WNavigationSliceModule( const WNavigationSliceModule& ot
const std::string WNavigationSliceModule::getName() const
{
return "Test Module";
return "Navigation Slice Module";
}
const std::string WNavigationSliceModule::getDescription() const
{
return "This module is for testing and development";
return "This module shows 3 orthogonal navigation slices.";
}
void WNavigationSliceModule::threadMain()
......@@ -75,10 +75,10 @@ void WNavigationSliceModule::threadMain()
void WNavigationSliceModule::createSlices()
{
osg::Geode* sliceGeode = new osg::Geode();
osg::Geode* m_sliceNode = new osg::Geode();
osg::Geometry* sliceGeometry = new osg::Geometry();
sliceGeode->addDrawable( sliceGeometry );
m_sliceNode->addDrawable( sliceGeometry );
osg::Vec3Array* sliceVertices = new osg::Vec3Array;
sliceVertices->push_back( osg::Vec3( 0, 50, 0 ) );
......@@ -138,5 +138,54 @@ void WNavigationSliceModule::createSlices()
sliceGeometry->addPrimitiveSet( slice1 );
sliceGeometry->addPrimitiveSet( slice2 );
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->addChild( sliceGeode );
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->addChild( m_sliceNode );
// FIXME (schurade)
// code taken from http://www.linuxquestions.org/questions/programming-9/get-full-path-of-a-command-in-c-117965/
// move it to somewhere else and execute it on startup and store the app path somewhere central
int length;
char appPath[255];
length = readlink( "/proc/self/exe", appPath, sizeof( appPath ) );
// Catch some errors
if ( length < 0 )
{
fprintf( stderr, "Error resolving symlink /proc/self/exe.\n" );
exit( EXIT_FAILURE );
}
if ( length >= 255 )
{
fprintf( stderr, "Path too long. Truncated.\n" );
exit( EXIT_FAILURE );
}
// I don't know why, but the string this readlink() function
// returns is appended with a '@'.
appPath[length] = '\0';
// strip off the executable name
while ( appPath[length] != '/' )
{
appPath[length] = '\0';
--length;
}
std::string shaderPath( appPath );
shaderPath += "shaders/";
std::cout << "Full path is: " << shaderPath << std::endl;
osg::StateSet* sliceState = m_sliceNode->getOrCreateStateSet();
osg::Program* sliceProgramObject = new osg::Program;
osg::Shader* sliceVertexObject = osg::Shader::readShaderFile( osg::Shader::VERTEX, shaderPath + "slice.vs" );
osg::Shader* sliceFragmentObject = osg::Shader::readShaderFile( osg::Shader::FRAGMENT, shaderPath + "slice.fs" );
sliceProgramObject->addShader( sliceFragmentObject );
sliceProgramObject->addShader( sliceVertexObject );
sliceState->setAttributeAndModes( sliceProgramObject, osg::StateAttribute::ON );
}
......@@ -26,7 +26,8 @@
#include <string>
#include "WModule.h"
#include "../../kernel/WModule.h"
#include <osg/Node>
/**
* \par Description:
......@@ -78,6 +79,11 @@ protected:
virtual void threadMain();
private:
/**
*
*/
osg::Geode* m_sliceNode;
/**
*
*/
......
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