Some EBCL use, mostly for testing

This commit is contained in:
Emmanuel BENOîT 2017-11-01 23:45:09 +01:00
parent 90abab29a3
commit 792c09b06f
4 changed files with 20 additions and 13 deletions

View file

@ -48,6 +48,7 @@ flags = [
'-I','imgui',
'-I','glm',
'-I','picojson',
'-I','ebcl/include',
'-I','/usr/include/SDL2' ,
'-D','GLM_ENABLE_EXPERIMENTAL',
]

View file

@ -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

View file

@ -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_ ,

View file

@ -3,6 +3,7 @@
# include "externals.hh"
#endif
#include <ebcl/Arrays.hh>
#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_;
};