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
8d42450c
Commit
8d42450c
authored
Jan 27, 2010
by
Sebastian Eichelbaum
Browse files
[CHANGE] - reload request now gets propagated using signals
parent
32c25444
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
235 additions
and
1 deletion
+235
-1
src/graphicsEngine/WGESignals.cpp
src/graphicsEngine/WGESignals.cpp
+26
-0
src/graphicsEngine/WGESignals.h
src/graphicsEngine/WGESignals.h
+59
-0
src/graphicsEngine/WGraphicsEngine.cpp
src/graphicsEngine/WGraphicsEngine.cpp
+20
-0
src/graphicsEngine/WGraphicsEngine.h
src/graphicsEngine/WGraphicsEngine.h
+23
-0
src/graphicsEngine/WShader.cpp
src/graphicsEngine/WShader.cpp
+5
-0
src/graphicsEngine/WShader.h
src/graphicsEngine/WShader.h
+6
-0
src/graphicsEngine/exceptions/WGESignalSubscriptionFailed.cpp
...graphicsEngine/exceptions/WGESignalSubscriptionFailed.cpp
+38
-0
src/graphicsEngine/exceptions/WGESignalSubscriptionFailed.h
src/graphicsEngine/exceptions/WGESignalSubscriptionFailed.h
+57
-0
src/kernel/WModule.cpp
src/kernel/WModule.cpp
+1
-1
No files found.
src/graphicsEngine/WGESignals.cpp
0 → 100644
View file @
8d42450c
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include "WGESignals.h"
src/graphicsEngine/WGESignals.h
0 → 100644
View file @
8d42450c
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WGESIGNALS_H
#define WGESIGNALS_H
#include <boost/signals2/signal.hpp>
#include <boost/function.hpp>
/**
* Enum of all possible signals WGraphicsEngine instances can emit.
*/
typedef
enum
{
GE_RELOADSHADERS
// when a shader reload is requested
}
GE_SIGNAL
;
// **************************************************************************************************************************
// Types
// **************************************************************************************************************************
/**
* Signal for generic events like "GE_RELOADSHADERS".
*
*/
typedef
boost
::
function
<
void
(
void
)
>
t_GEGenericSignalHandlerType
;
/**
* Generic signal type used in the most signals.
*/
typedef
boost
::
signals2
::
signal
<
void
(
void
)
>
t_GEGenericSignalType
;
#endif // WGESIGNALS_H
src/graphicsEngine/WGraphicsEngine.cpp
View file @
8d42450c
...
...
@@ -43,6 +43,7 @@
#include "WGEViewer.h"
#include "WGraphicsEngine.h"
#include "exceptions/WGEInitFailed.h"
#include "exceptions/WGESignalSubscriptionFailed.h"
#include "WGEResourceManager.h"
// graphics engine instance as singleton
...
...
@@ -185,6 +186,25 @@ void WGraphicsEngine::notifyStop()
m_viewer
->
setDone
(
true
);
}
void
WGraphicsEngine
::
requestShaderReload
()
{
m_reloadShadersSignal
();
}
boost
::
signals2
::
connection
WGraphicsEngine
::
subscribeSignal
(
GE_SIGNAL
signal
,
t_GEGenericSignalHandlerType
notifier
)
{
switch
(
signal
)
{
case
GE_RELOADSHADERS
:
return
m_reloadShadersSignal
.
connect
(
notifier
);
default:
std
::
ostringstream
s
;
s
<<
"Could not subscribe to unknown signal."
;
throw
WGESignalSubscriptionFailed
(
s
.
str
()
);
break
;
}
}
osg
::
Vec4
wge
::
osgColor
(
const
WColor
&
color
)
{
return
osg
::
Vec4
(
color
.
getRed
(),
color
.
getGreen
(),
color
.
getBlue
(),
color
.
getAlpha
()
);
...
...
src/graphicsEngine/WGraphicsEngine.h
View file @
8d42450c
...
...
@@ -30,6 +30,8 @@
#include <vector>
#include <boost/shared_ptr.hpp>
#include <boost/signals2/signal.hpp>
#include <boost/function.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
...
...
@@ -48,6 +50,7 @@
#include "WGEGraphicsWindow.h"
#include "WGEScene.h"
#include "WGEViewer.h"
#include "WGESignals.h"
/**
* Base class for initializing the graphics engine. This Class also serves as adaptor to access the graphics
...
...
@@ -152,6 +155,21 @@ public:
*/
static
boost
::
shared_ptr
<
WGraphicsEngine
>
getGraphicsEngine
();
/**
* This requests all shaders to reload during the next update cycle.
*/
void
requestShaderReload
();
/**
* Subscribe a specified handler to the specified signal emited by the GE.
*
* \param signal the signal to connect to
* \param notifier the signal handler
*
* \return connection object.
*/
boost
::
signals2
::
connection
subscribeSignal
(
GE_SIGNAL
signal
,
t_GEGenericSignalHandlerType
notifier
);
protected:
/**
...
...
@@ -191,6 +209,11 @@ protected:
*/
osg
::
ref_ptr
<
osgViewer
::
CompositeViewer
>
m_viewer
;
/**
* Signal getting emitted whenever a reload shader request is waiting.
*/
t_GEGenericSignalType
m_reloadShadersSignal
;
private:
/**
* Singleton instance of WGraphicsEngine.
...
...
src/graphicsEngine/WShader.cpp
View file @
8d42450c
...
...
@@ -31,6 +31,8 @@
#include <boost/lexical_cast.hpp>
#include <boost/tokenizer.hpp>
#include <boost/regex.hpp>
#include <boost/signals2/signal.hpp>
#include <boost/function.hpp>
#include <osg/StateSet>
#include <osg/Node>
...
...
@@ -55,11 +57,14 @@ WShader::WShader( std::string name ):
addShader
(
m_vertexShader
);
addShader
(
m_fragmentShader
);
addShader
(
m_geometryShader
);
m_reloadSignalConnection
=
WGraphicsEngine
::
getGraphicsEngine
()
->
subscribeSignal
(
GE_RELOADSHADERS
,
boost
::
bind
(
&
WShader
::
reload
,
this
)
);
}
WShader
::~
WShader
()
{
// cleanup
m_reloadSignalConnection
.
disconnect
();
}
void
WShader
::
apply
(
osg
::
ref_ptr
<
osg
::
Node
>
node
)
...
...
src/graphicsEngine/WShader.h
View file @
8d42450c
...
...
@@ -29,6 +29,7 @@
#include <string>
#include <boost/filesystem.hpp>
#include <boost/signals2/signal.hpp>
#include <osg/Shader>
#include <osg/Program>
...
...
@@ -110,6 +111,11 @@ protected:
*/
bool
m_reload
;
/**
* Connection object to the reload signal from WGraphbicsEngine.
*/
boost
::
signals2
::
connection
m_reloadSignalConnection
;
/**
* a map of all set defines
*/
...
...
src/graphicsEngine/exceptions/WGESignalSubscriptionFailed.cpp
0 → 100644
View file @
8d42450c
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <string>
#include "WGESignalSubscriptionFailed.h"
WGESignalSubscriptionFailed
::
WGESignalSubscriptionFailed
(
const
std
::
string
&
msg
)
:
WGEException
(
msg
)
{
// initialize members
}
WGESignalSubscriptionFailed
::~
WGESignalSubscriptionFailed
()
throw
()
{
// cleanup
}
src/graphicsEngine/exceptions/WGESignalSubscriptionFailed.h
0 → 100644
View file @
8d42450c
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WGESIGNALSUBSCRIPTIONFAILED_H
#define WGESIGNALSUBSCRIPTIONFAILED_H
#include <string>
#include "WGEException.h"
/**
* Exception thrown if a notifier could not be subscribed to a signal.
* \ingroup ge
*/
class
WGESignalSubscriptionFailed
:
public
WGEException
{
public:
/**
* Default constructor.
* \param msg the exception message.
*/
explicit
WGESignalSubscriptionFailed
(
const
std
::
string
&
msg
=
"Could not subscribe to unknown signal."
);
/**
* Destructor.
*/
virtual
~
WGESignalSubscriptionFailed
()
throw
();
protected:
private:
};
#endif // WGESIGNALSUBSCRIPTIONFAILED_H
src/kernel/WModule.cpp
View file @
8d42450c
...
...
@@ -173,7 +173,7 @@ const std::set<boost::shared_ptr< WModuleOutputConnector > >& WModule::getOutput
boost
::
signals2
::
connection
WModule
::
subscribeSignal
(
MODULE_SIGNAL
signal
,
t_ModuleGenericSignalHandlerType
notifier
)
{
switch
(
signal
)
switch
(
signal
)
{
case
WM_READY
:
return
signal_ready
.
connect
(
notifier
);
...
...
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