From 792c09b06fd9d0b1884e615bb9b425b77e64b988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Wed, 1 Nov 2017 23:45:09 +0100 Subject: [PATCH] Some EBCL use, mostly for testing --- .vim.local/ycm_extra_conf.py | 1 + Makefile | 6 ++++-- rendertarget.cc | 17 +++++++++-------- rendertarget.hh | 9 ++++++--- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.vim.local/ycm_extra_conf.py b/.vim.local/ycm_extra_conf.py index 00f328a..b4ecac1 100644 --- a/.vim.local/ycm_extra_conf.py +++ b/.vim.local/ycm_extra_conf.py @@ -48,6 +48,7 @@ flags = [ '-I','imgui', '-I','glm', '-I','picojson', + '-I','ebcl/include', '-I','/usr/include/SDL2' , '-D','GLM_ENABLE_EXPERIMENTAL', ] diff --git a/Makefile b/Makefile index 9eba200..80e936f 100644 --- a/Makefile +++ b/Makefile @@ -3,9 +3,10 @@ OUTDIR = output CXXFLAGS += $(shell sdl2-config --cflags) -std=c++14 -Wall -g CFLAGS += $(shell sdl2-config --cflags) CPPFLAGS += -I. -I$(OUTDIR) \ - -Iimgui -Iglm -Ipicojson \ + -Iimgui -Iglm -Ipicojson -Iebcl/include \ -DREAL_BUILD -DGLM_ENABLE_EXPERIMENTAL -LIBS += $(shell sdl2-config --libs) -lGL -lGLEW -ldl +LIBS += $(shell sdl2-config --libs) -lGL -lGLEW -ldl \ + $(LIBEBCL) -latomic FILEDUMPS = @@ -54,6 +55,7 @@ clean: rm -f $(OBJS) $(FILEDUMPS) demo $(PCH) fullclean: clean + @+make -C ebcl fullclean CONFIG=../ebcl-config rm -f $(DEMO_DEPS) .PHONY: clean fullclean diff --git a/rendertarget.cc b/rendertarget.cc index c9e0652..1caa673 100644 --- a/rendertarget.cc +++ b/rendertarget.cc @@ -11,7 +11,7 @@ T_RendertargetSetup& T_RendertargetSetup::add( __rd__ const uint32_t level ) { checkAttachment( texture , level ); - colorAttachments_.push_back( T_Attachment_{ texture , level } ); + colorAttachments_.add( T_Attachment_{ texture , level } ); return *this; } @@ -19,9 +19,9 @@ T_RendertargetSetup& T_RendertargetSetup::add( T_RendertargetSetup& T_RendertargetSetup::depth( __rw__ T_Texture& texture ) { - assert( !depthAttachment_ ); + assert( !depthAttachment_.present( ) ); checkAttachment( texture , 0 ); - depthAttachment_ = std::make_unique< T_Attachment_ >( texture , 0 ); + depthAttachment_.setNew( texture , 0 ); return *this; } @@ -65,11 +65,12 @@ T_Rendertarget T_RendertargetSetup::create( ) colorAttachments_[ i ].texture->id( ) , colorAttachments_[ i ].level ); } - if ( depthAttachment_ ) { + if ( depthAttachment_.present( ) ) { + T_Attachment_ const& de( depthAttachment_ ); glFramebufferTexture( GL_FRAMEBUFFER , GL_DEPTH_ATTACHMENT , - depthAttachment_->texture->id( ) , - depthAttachment_->level ); + de.texture->id( ) , + de.level ); } assert( glCheckFramebufferStatus( GL_FRAMEBUFFER ) == GL_FRAMEBUFFER_COMPLETE ); glBindFramebuffer( GL_FRAMEBUFFER , 0 ); @@ -79,7 +80,7 @@ T_Rendertarget T_RendertargetSetup::create( ) // Reset config hasAttachments_ = false; colorAttachments_.clear( ); - depthAttachment_.reset( ); + depthAttachment_.clear( ); return T_Rendertarget( id , nca , width_ , height_ ); } @@ -129,7 +130,7 @@ bool T_Rendertarget::activate( ) if ( nCats_ != buffers_.size( ) ) { buffers_.clear( ); for ( auto i = 0u ; i < nCats_ ; i ++ ) { - buffers_.push_back( GL_COLOR_ATTACHMENT0 + i ); + buffers_.add( GL_COLOR_ATTACHMENT0 + i ); } #ifdef INTRUSIVE_TRACES printf( "fb %d: created buffers (%d items)\n" , id_ , diff --git a/rendertarget.hh b/rendertarget.hh index 099166c..ac476e2 100644 --- a/rendertarget.hh +++ b/rendertarget.hh @@ -3,6 +3,7 @@ # include "externals.hh" #endif +#include #include "texture.hh" @@ -32,6 +33,7 @@ struct T_RendertargetSetup : texture( &texture ) , level( level ) {} }; + using T_Attachments_ = ebcl::T_AutoArray< T_Attachment_ , 8 >; void checkAttachment( __rw__ T_Texture const& texture , @@ -39,8 +41,9 @@ struct T_RendertargetSetup bool hasAttachments_; uint32_t width_ , height_; - std::vector< T_Attachment_ > colorAttachments_; - std::unique_ptr< T_Attachment_ > depthAttachment_; + + T_Attachments_ colorAttachments_; + ebcl::T_Optional< T_Attachment_ > depthAttachment_; }; @@ -72,5 +75,5 @@ struct T_Rendertarget private: GLuint id_; uint32_t nCats_ , width_ , height_; - std::vector< GLenum > buffers_; + ebcl::T_AutoArray< GLenum , 8 > buffers_; };