Skip to content
Snippets Groups Projects
Commit 8b7c3c14 authored by Mathias Paulin's avatar Mathias Paulin :speech_balloon:
Browse files

[librender] fix segfault on linux due tu std::uuid constructor

parent 544db444
Branches
No related tags found
No related merge requests found
......@@ -164,7 +164,7 @@ void NodeBasedRenderer::resizeInternal() {
#ifdef PASSES_LOG
if ( m_postprocessFbo->checkStatus() != GL_FRAMEBUFFER_COMPLETE )
{
LOG( logERROR ) << "FBO Error (AdvancedRenderer::m_postprocessFbo) : "
LOG( Ra::Core::Utils::logERROR ) << "FBO Error (NodeBasedRenderer::m_postprocessFbo) : "
<< m_postprocessFbo->checkStatus();
}
#endif
......@@ -281,11 +281,11 @@ void NodeBasedRenderer::uiInternal( const ViewingParameters& renderData ) {
}
void NodeBasedRenderer::postProcessInternal( const ViewingParameters& /* renderData */ ) {
if (m_colorTexture) {
if (true/*m_colorTexture*/) {
m_postprocessFbo->bind();
GL_ASSERT( glDrawBuffers( 1, buffers ) );
//GL_ASSERT( glDrawBuffers( 1, buffers ) );
GL_ASSERT( glDrawBuffer(GL_COLOR_ATTACHMENT0) );
GL_ASSERT( glDisable( GL_DEPTH_TEST ) );
GL_ASSERT( glDepthMask( GL_FALSE ) );
......@@ -316,6 +316,7 @@ void NodeBasedRenderer::updateStepInternal( const ViewingParameters& renderData
if ( m_originalRenderGraph.m_recompile )
{
std::cerr << "NodeBasedRenderer::updateStepInternal :Recompiling Graph\n";
compileRenderGraph();
m_originalRenderGraph.m_recompile = false;
}
......@@ -345,8 +346,8 @@ void NodeBasedRenderer::setDisplayNode( DisplaySinkNode* displayNode ) {
void NodeBasedRenderer::observeDisplaySink( const std::vector<NodeTypeTexture*>& graphOutput ) {
// TODO : find a way to make the renderer observable to manage ouput texture in the applicaiton
// gui if needed
// std::cout << "NodeBasedRenderer::observeDisplaySink - connected textures ("
// << graphOutput.size() << ") : \n";
std::cout << "NodeBasedRenderer::observeDisplaySink - connected textures ("
<< graphOutput.size() << ") : \n";
/*
for ( const auto t : graphOutput )
{
......@@ -380,11 +381,6 @@ void NodeBasedRenderer::observeDisplaySink( const std::vector<NodeTypeTexture*>&
}
}
}
else
{
m_colorTexture = m_fancyTexture.get();
colorTextureSet = true;
}
if ( !colorTextureSet )
{
......
......@@ -5,13 +5,14 @@ using namespace Ra::Core::Utils;
bool Node::s_uuidGeneratorInitialized {false};
uuids::uuid_random_generator* Node::s_uidGenerator{nullptr};
void Node::createUuidGenerator() {
std::random_device rd;
auto seed_data = std::array<int, std::mt19937::state_size> {};
std::generate(std::begin(seed_data), std::end(seed_data), std::ref(rd));
std::seed_seq seq(std::begin(seed_data), std::end(seed_data));
std::mt19937 generator(seq);
s_uidGenerator = new uuids::uuid_random_generator(generator);
auto generator = new std::mt19937(seq);
s_uidGenerator = new uuids::uuid_random_generator(*generator);
s_uuidGeneratorInitialized = true;
}
......@@ -25,9 +26,8 @@ void Node::generateUuid() {
/// Gets the UUID of the node as a string
std::string Node::getUuid() const {
if ( m_uuid.is_nil() ) {
// generates the uuid (need to remove const attribute ...
// generates the uuid (need to remove const attribute) ...
const_cast<Node*>(this)->generateUuid();
std::string guuid = "{" + uuids::to_string(m_uuid) + "}";
}
std::string struuid = "{" + uuids::to_string(m_uuid) + "}";
return struuid;
......
......@@ -14,7 +14,7 @@ SimpleNode::SimpleNode( const std::string& name ) : Node( name, getTypename() )
auto portInL = new PortIn<std::vector<NodeTypeLight>>( "inLights", this );
addInput( portInL );
Ra::Engine::Data::TextureParameters colorTexParams = { "Color Texture",
Ra::Engine::Data::TextureParameters colorTexParams = { "Simple Color image",
gl::GL_TEXTURE_2D,
1,
1,
......@@ -30,10 +30,10 @@ SimpleNode::SimpleNode( const std::string& name ) : Node( name, getTypename() )
nullptr };
m_colorTexture = new Ra::Engine::Data::Texture( colorTexParams );
auto portOutColorTex = new PortOut<NodeTypeTexture>( "Color Texture", this );
auto portOutColorTex = new PortOut<NodeTypeTexture>( "Color image", this );
addOutput( portOutColorTex, m_colorTexture );
Ra::Engine::Data::TextureParameters depthTexParams = { "Depth Texture",
Ra::Engine::Data::TextureParameters depthTexParams = { "Simple Depth image",
gl::GL_TEXTURE_2D,
1,
1,
......@@ -49,13 +49,14 @@ SimpleNode::SimpleNode( const std::string& name ) : Node( name, getTypename() )
nullptr };
m_depthTexture = new Ra::Engine::Data::Texture( depthTexParams );
auto portOutDepthTex = new PortOut<NodeTypeTexture>( "Depth Texture", this );
auto portOutDepthTex = new PortOut<NodeTypeTexture>( "Depth image", this );
addOutput( portOutDepthTex, m_depthTexture );
}
void SimpleNode::init() {
m_framebuffer = new globjects::Framebuffer();
float blankAO[4] = { 1.f, 1.f, 1.f, 1.f };
Ra::Engine::Data::TextureParameters texParams;
texParams.target = gl::GL_TEXTURE_2D;
......@@ -70,7 +71,7 @@ void SimpleNode::init() {
texParams.texels = &blankAO;
m_blankAO = new Ra::Engine::Data::Texture( texParams );
m_blankAO->initializeGL();
/*
m_nodeState = new globjects::State(globjects::State::DeferredMode);
m_nodeState->enable( gl::GL_DEPTH_TEST );
m_nodeState->depthMask( gl::GL_TRUE );
......@@ -78,7 +79,7 @@ void SimpleNode::init() {
m_nodeState->colorMask( gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE );
m_nodeState->blendFunc( gl::GL_ONE, gl::GL_ONE );
m_nodeState->disable( gl::GL_BLEND );
*/
}
void SimpleNode::update() {}
......@@ -106,15 +107,21 @@ void SimpleNode::execute() {
auto& lights = inputLight->getData();
m_framebuffer->bind();
m_framebuffer->attachTexture( gl::GL_DEPTH_ATTACHMENT, m_depthTexture->texture() );
m_framebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT0, m_colorTexture->texture() );
const gl::GLenum buffers[] = { gl::GL_COLOR_ATTACHMENT0 };
gl::glDrawBuffers( 1, buffers );
auto currentState = globjects::State::currentState();
m_nodeState->apply();
float clearBlack[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
//auto currentState = globjects::State::currentState();
//m_nodeState->apply();
gl::glEnable( gl::GL_DEPTH_TEST );
gl::glDepthMask( gl::GL_TRUE );
gl::glDepthFunc( gl::GL_LEQUAL );
gl::glColorMask( gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE );
gl::glDisable( gl::GL_BLEND );
float clearBlack[4] = { 0.0f, 1.0f, 0.0f, 0.0f };
float clearDepth = 1.0f;
gl::glClearBufferfv( gl::GL_COLOR, 0, clearBlack );
gl::glClearBufferfv( gl::GL_DEPTH, 0, &clearDepth );
......@@ -130,15 +137,18 @@ void SimpleNode::execute() {
for ( const auto& ro : renderObjects )
{ ro->render( inPassParams, cameras[0], m_idx ); }
if (first_light) {
//break;
first_light = false;
gl::glEnable( gl::GL_BLEND );
gl::glBlendFunc( gl::GL_ONE, gl::GL_ONE );
gl::glDepthMask( gl::GL_FALSE );
}
}
}
gl::glDisable( gl::GL_BLEND );
gl::glDepthMask( gl::GL_TRUE );
//currentState->apply();
currentState->apply();
m_framebuffer->detach( gl::GL_DEPTH_ATTACHMENT );
m_framebuffer->detach( gl::GL_COLOR_ATTACHMENT0 );
m_framebuffer->unbind();
}
......@@ -149,8 +159,13 @@ void SimpleNode::destroy() {
}
void SimpleNode::resize( uint32_t width, uint32_t height ) {
std::cout << "SimpleNode::resize\n";
m_colorTexture->resize( width, height );
m_depthTexture->resize( width, height );
m_framebuffer->bind();
m_framebuffer->attachTexture( gl::GL_DEPTH_ATTACHMENT, m_depthTexture->texture() );
m_framebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT0, m_colorTexture->texture() );
m_framebuffer->unbind();
}
void SimpleNode::buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment