Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
369de43a
Commit
369de43a
authored
Sep 16, 2009
by
schurade
Browse files
[ADD] moved modules to their new home, added some preliminary shader support
parent
9b490e28
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
69 additions
and
14 deletions
+69
-14
src/CMakeLists.txt
src/CMakeLists.txt
+3
-2
src/kernel/CMakeLists.txt
src/kernel/CMakeLists.txt
+3
-3
src/kernel/WKernel.cpp
src/kernel/WKernel.cpp
+1
-2
src/modules/navigationSlices/WNavigationSliceModule.cpp
src/modules/navigationSlices/WNavigationSliceModule.cpp
+55
-6
src/modules/navigationSlices/WNavigationSliceModule.h
src/modules/navigationSlices/WNavigationSliceModule.h
+7
-1
src/modules/testModule/WTestModule.cpp
src/modules/testModule/WTestModule.cpp
+0
-0
src/modules/testModule/WTestModule.h
src/modules/testModule/WTestModule.h
+0
-0
No files found.
src/CMakeLists.txt
View file @
369de43a
...
...
@@ -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:
#-------------------------------------------------------------------------------------------------------------
...
...
src/kernel/CMakeLists.txt
View file @
369de43a
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
)
src/kernel/WKernel.cpp
View file @
369de43a
...
...
@@ -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"
...
...
src/
kernel
/WNavigationSliceModule.cpp
→
src/
modules/navigationSlices
/WNavigationSliceModule.cpp
View file @
369de43a
...
...
@@ -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
*
slice
Ge
ode
=
new
osg
::
Geode
();
osg
::
Geode
*
m_
slice
N
ode
=
new
osg
::
Geode
();
osg
::
Geometry
*
sliceGeometry
=
new
osg
::
Geometry
();
slice
Ge
ode
->
addDrawable
(
sliceGeometry
);
m_
slice
N
ode
->
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
);
}
src/
kernel
/WNavigationSliceModule.h
→
src/
modules/navigationSlices
/WNavigationSliceModule.h
View file @
369de43a
...
...
@@ -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
;
/**
*
*/
...
...
src/
kernel
/WTestModule.cpp
→
src/
modules/testModule
/WTestModule.cpp
View file @
369de43a
File moved
src/
kernel
/WTestModule.h
→
src/
modules/testModule
/WTestModule.h
View file @
369de43a
File moved
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment