Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libRendering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STORM
repos
Radium
libRendering
Commits
26159586
Commit
26159586
authored
4 years ago
by
Mathias Paulin
Browse files
Options
Downloads
Patches
Plain Diff
Add simple demo of a custom pipeline.
parent
bc5996bb
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/CMakeLists.txt
+3
-0
3 additions, 0 deletions
src/CMakeLists.txt
src/DemoApp/CMakeLists.txt
+88
-0
88 additions, 0 deletions
src/DemoApp/CMakeLists.txt
src/DemoApp/main.cpp
+124
-0
124 additions, 0 deletions
src/DemoApp/main.cpp
with
215 additions
and
0 deletions
src/CMakeLists.txt
+
3
−
0
View file @
26159586
...
...
@@ -5,4 +5,7 @@ endif (WITH_H3D_SUPPORT)
add_subdirectory
(
Plugin
)
set
(
MARA_IN_BUILD_TREE True
)
add_subdirectory
(
Mara EXCLUDE_FROM_ALL
)
set
(
VIEWER_IN_BUILD_TREE True
)
add_subdirectory
(
DemoApp EXCLUDE_FROM_ALL
)
#add_subdirectory(Mara)
This diff is collapsed.
Click to expand it.
src/DemoApp/CMakeLists.txt
0 → 100644
+
88
−
0
View file @
26159586
cmake_minimum_required
(
VERSION 3.6
)
if
(
${
CMAKE_MAJOR_VERSION
}
.
${
CMAKE_MINOR_VERSION
}
VERSION_GREATER
"3.9"
)
cmake_policy
(
SET CMP0071 NEW
)
endif
()
if
(
APPLE
)
cmake_policy
(
SET CMP0042 NEW
)
endif
(
APPLE
)
set
(
CMAKE_DISABLE_SOURCE_CHANGES ON
)
set
(
CMAKE_DISABLE_IN_SOURCE_BUILD ON
)
project
(
SimpleViewer VERSION 0.0.1
)
if
(
NOT CMAKE_BUILD_TYPE
)
set
(
CMAKE_BUILD_TYPE Release
)
endif
()
# Set default install location to installed-<Compiler_ID> folder in build dir
# we do not want to install to /usr by default
if
(
CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT
)
set
(
CMAKE_INSTALL_PREFIX
"
${
CMAKE_CURRENT_BINARY_DIR
}
/installed-
${
CMAKE_CXX_COMPILER_ID
}
-
${
CMAKE_BUILD_TYPE
}
"
CACHE PATH
"Install path prefix, prepended onto install directories."
FORCE
)
message
(
"Set install prefix to
${
CMAKE_INSTALL_PREFIX
}
"
)
endif
()
set
(
CMAKE_CXX_STANDARD 17
)
set
(
CMAKE_CXX_STANDARD_REQUIRED ON
)
# ///////////////////////////////
find_package
(
Qt5 COMPONENTS Core Widgets REQUIRED
)
set
(
Qt5_LIBRARIES Qt5::Core Qt5::Widgets
)
set
(
CMAKE_AUTOMOC ON
)
set
(
CMAKE_AUTORCC ON
)
set
(
CMAKE_INCLUDE_CURRENT_DIR ON
)
find_package
(
Radium REQUIRED Core Engine Gui PluginBase IO
)
set
(
app_sources
main.cpp
)
set
(
app_headers
)
set
(
app_uis
)
qt5_wrap_ui
(
app_uis_moc
${
app_uis
}
)
set
(
app_resources
)
add_executable
(
${
PROJECT_NAME
}
MACOSX_BUNDLE
${
app_sources
}
${
app_headers
}
${
app_uis
}
${
app_resources
}
)
target_compile_features
(
${
PROJECT_NAME
}
PUBLIC cxx_std_17
)
target_include_directories
(
${
PROJECT_NAME
}
PRIVATE
${
RADIUM_INCLUDE_DIRS
}
${
CMAKE_CURRENT_BINARY_DIR
}
# Moc
${
CMAKE_CURRENT_SOURCE_DIR
}
)
if
(
VIEWER_IN_BUILD_TREE
)
message
(
STATUS
" ***
${
PROJECT_NAME
}
*** Building application into the lib and plugin build tree"
)
else
()
message
(
STATUS
" ***
${
PROJECT_NAME
}
*** Building application from the installed library"
)
# If the application is built as standalone, uses libGLTF from its installed tree
find_package
(
RadiumNBR REQUIRED
)
endif
()
target_link_libraries
(
${
PROJECT_NAME
}
PUBLIC
Radium::Core Radium::Engine Radium::Gui Radium::IO
RadiumNBR::NBR
RadiumNBR::NBRGui
# ${Qt5_LIBRARIES}
)
configure_radium_app
(
NAME
${
PROJECT_NAME
}
USE_PLUGINS
)
This diff is collapsed.
Click to expand it.
src/DemoApp/main.cpp
0 → 100644
+
124
−
0
View file @
26159586
// Include Radium base application and its simple Gui
#include
<Gui/BaseApplication.hpp>
#include
<Gui/RadiumWindow/SimpleWindowFactory.hpp>
// Include the customizable renderer system (only the used part here)
#include
<RadiumNBR/NodeBasedRenderer.hpp>
#include
<RadiumNBR/Passes/ClearPass.hpp>
#include
<RadiumNBR/Passes/GeomPrepass.hpp>
#include
<RadiumNBR/Passes/WireframePass.hpp>
/**
* This class parameterize the renderer just after the OpenGL system was initialized.
* In the functor, The OpenGL context of the drawing window is activated.
*/
class
RendererBuilder
{
public:
void
operator
()(
RadiumNBR
::
NodeBasedRenderer
*
renderer
,
int
w
,
int
h
)
{
LOG
(
Ra
::
Core
::
Utils
::
logINFO
)
<<
"Customizing the renderer "
<<
renderer
->
getRendererName
();
//! [Caching some helpers and data from the Engine and the renderer]
auto
resourcesCheck
=
Ra
::
Core
::
Resources
::
getResourcesPath
(
reinterpret_cast
<
void
*>
(
&
RadiumNBR
::
NodeBasedRendererMagic
),
{
"Resources/RadiumNBR"
}
);
if
(
!
resourcesCheck
)
{
LOG
(
Ra
::
Core
::
Utils
::
logERROR
)
<<
"Unable to find resources for NodeBasedRenderer!"
;
return
;
}
else
{
LOG
(
Ra
::
Core
::
Utils
::
logINFO
)
<<
"NodeBasedRenderer Resources are at "
<<
*
resourcesCheck
;
}
auto
resourcesPath
{
*
resourcesCheck
};
auto
shaderManager
=
Ra
::
Engine
::
RadiumEngine
::
getInstance
()
->
getShaderProgramManager
();
auto
colortexture
=
renderer
->
sharedTextures
().
find
(
"Linear RGB (RadiumNBR)"
);
auto
depthtexture
=
renderer
->
sharedTextures
().
find
(
"Depth (RadiumNBR)"
);
//! [Caching some helpers and data from the Engine and the renderer]
//! [Adding a clear-screen pass]
{
// pass that draw no object and is positionned at rank 0
auto
pass
=
std
::
make_shared
<
RadiumNBR
::
ClearPass
>
(
nullptr
,
0
);
// set the output of the pass : clear the renderer Linear RGB output texture
pass
->
setOutput
(
*
colortexture
);
// set the clear color (pass internal state)
pass
->
setBackground
(
renderer
->
getBackgroundColor
());
pass
->
initializePass
(
w
,
h
,
shaderManager
);
// add the pass to the renderer and activate it
renderer
->
addPass
(
pass
,
pass
->
index
());
pass
->
activate
();
}
//! [Adding a clear-screen pass]
//! [Adding a Z-only pass]
{
// the z-only pass takes all the objects and draw them only on the shared depth buffer.
auto
pass
=
std
::
make_shared
<
RadiumNBR
::
GeomPrePass
>
(
renderer
->
allRenderObjects
(),
1
);
// set the output to the shared depth texture
pass
->
setOutput
(
*
depthtexture
);
// configure access to shader/resources files and initialize the pass
pass
->
setResourcesDir
(
resourcesPath
);
pass
->
initializePass
(
w
,
h
,
shaderManager
);
// add the pass to the renderer and activate it
renderer
->
addPass
(
pass
,
pass
->
index
());
pass
->
activate
();
}
//! [Adding a Z-only pass]
//! [Adding a wireframe pass]
{
// this pass draw all the objects in wareframe, using the shared z-buffer for hidden line removal and drawing
// in the shared color buffer.
auto
pass
=
std
::
make_shared
<
RadiumNBR
::
WireframePass
>
(
renderer
->
allRenderObjects
(),
2
);
// set the input/output textures
pass
->
setInputs
(
*
depthtexture
);
pass
->
setOutput
(
*
colortexture
);
// configure access to shader/resources files and initialize the pass
pass
->
setResourcesDir
(
resourcesPath
);
pass
->
initializePass
(
w
,
h
,
shaderManager
);
// add the pass to the renderer and activate it
renderer
->
addPass
(
pass
,
pass
->
index
());
pass
->
activate
();
}
//! [Adding a wireframe pass]
}
};
/**
* Define a factory that set the wanted renderer on the window
*/
class
DemoWindowFactory
:
public
Ra
::
Gui
::
BaseApplication
::
WindowFactory
{
public:
DemoWindowFactory
()
=
delete
;
~
DemoWindowFactory
()
=
default
;
explicit
DemoWindowFactory
(
std
::
shared_ptr
<
RadiumNBR
::
NodeBasedRenderer
>
r
)
:
renderer
(
r
)
{}
inline
Ra
::
Gui
::
MainWindowInterface
*
createMainWindow
()
const
override
{
auto
window
=
new
Ra
::
Gui
::
SimpleWindow
();
window
->
addRenderer
(
renderer
->
getRendererName
(),
renderer
);
return
window
;
}
private
:
std
::
shared_ptr
<
RadiumNBR
::
NodeBasedRenderer
>
renderer
;
};
int
main
(
int
argc
,
char
*
argv
[]
)
{
if
(
argc
<
2
)
{
std
::
cerr
<<
"usage : "
<<
argv
[
0
]
<<
" -f <scene_file>"
<<
std
::
endl
;
return
1
;
}
//! [Instatiating the renderer giving a customization functor]
auto
renderer
=
std
::
make_shared
<
RadiumNBR
::
NodeBasedRenderer
>
(
RendererBuilder
{}
);
//! [Instatiating the renderer giving a customization functor]
//! [Instatiating the application]
Ra
::
Gui
::
BaseApplication
app
(
argc
,
argv
);
//! [Instatiating the application]
//! [Initializing the application]
// The customization functor is called here
app
.
initialize
(
DemoWindowFactory
(
renderer
)
);
//! [Initializing the application]
return
app
.
exec
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment