Some EBCL use, mostly for testing
This commit is contained in:
parent
90abab29a3
commit
792c09b06f
4 changed files with 20 additions and 13 deletions
|
@ -48,6 +48,7 @@ flags = [
|
||||||
'-I','imgui',
|
'-I','imgui',
|
||||||
'-I','glm',
|
'-I','glm',
|
||||||
'-I','picojson',
|
'-I','picojson',
|
||||||
|
'-I','ebcl/include',
|
||||||
'-I','/usr/include/SDL2' ,
|
'-I','/usr/include/SDL2' ,
|
||||||
'-D','GLM_ENABLE_EXPERIMENTAL',
|
'-D','GLM_ENABLE_EXPERIMENTAL',
|
||||||
]
|
]
|
||||||
|
|
6
Makefile
6
Makefile
|
@ -3,9 +3,10 @@ OUTDIR = output
|
||||||
CXXFLAGS += $(shell sdl2-config --cflags) -std=c++14 -Wall -g
|
CXXFLAGS += $(shell sdl2-config --cflags) -std=c++14 -Wall -g
|
||||||
CFLAGS += $(shell sdl2-config --cflags)
|
CFLAGS += $(shell sdl2-config --cflags)
|
||||||
CPPFLAGS += -I. -I$(OUTDIR) \
|
CPPFLAGS += -I. -I$(OUTDIR) \
|
||||||
-Iimgui -Iglm -Ipicojson \
|
-Iimgui -Iglm -Ipicojson -Iebcl/include \
|
||||||
-DREAL_BUILD -DGLM_ENABLE_EXPERIMENTAL
|
-DREAL_BUILD -DGLM_ENABLE_EXPERIMENTAL
|
||||||
LIBS += $(shell sdl2-config --libs) -lGL -lGLEW -ldl
|
LIBS += $(shell sdl2-config --libs) -lGL -lGLEW -ldl \
|
||||||
|
$(LIBEBCL) -latomic
|
||||||
|
|
||||||
FILEDUMPS =
|
FILEDUMPS =
|
||||||
|
|
||||||
|
@ -54,6 +55,7 @@ clean:
|
||||||
rm -f $(OBJS) $(FILEDUMPS) demo $(PCH)
|
rm -f $(OBJS) $(FILEDUMPS) demo $(PCH)
|
||||||
|
|
||||||
fullclean: clean
|
fullclean: clean
|
||||||
|
@+make -C ebcl fullclean CONFIG=../ebcl-config
|
||||||
rm -f $(DEMO_DEPS)
|
rm -f $(DEMO_DEPS)
|
||||||
|
|
||||||
.PHONY: clean fullclean
|
.PHONY: clean fullclean
|
||||||
|
|
|
@ -11,7 +11,7 @@ T_RendertargetSetup& T_RendertargetSetup::add(
|
||||||
__rd__ const uint32_t level )
|
__rd__ const uint32_t level )
|
||||||
{
|
{
|
||||||
checkAttachment( texture , level );
|
checkAttachment( texture , level );
|
||||||
colorAttachments_.push_back( T_Attachment_{ texture , level } );
|
colorAttachments_.add( T_Attachment_{ texture , level } );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,9 +19,9 @@ T_RendertargetSetup& T_RendertargetSetup::add(
|
||||||
T_RendertargetSetup& T_RendertargetSetup::depth(
|
T_RendertargetSetup& T_RendertargetSetup::depth(
|
||||||
__rw__ T_Texture& texture )
|
__rw__ T_Texture& texture )
|
||||||
{
|
{
|
||||||
assert( !depthAttachment_ );
|
assert( !depthAttachment_.present( ) );
|
||||||
checkAttachment( texture , 0 );
|
checkAttachment( texture , 0 );
|
||||||
depthAttachment_ = std::make_unique< T_Attachment_ >( texture , 0 );
|
depthAttachment_.setNew( texture , 0 );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,11 +65,12 @@ T_Rendertarget T_RendertargetSetup::create( )
|
||||||
colorAttachments_[ i ].texture->id( ) ,
|
colorAttachments_[ i ].texture->id( ) ,
|
||||||
colorAttachments_[ i ].level );
|
colorAttachments_[ i ].level );
|
||||||
}
|
}
|
||||||
if ( depthAttachment_ ) {
|
if ( depthAttachment_.present( ) ) {
|
||||||
|
T_Attachment_ const& de( depthAttachment_ );
|
||||||
glFramebufferTexture( GL_FRAMEBUFFER ,
|
glFramebufferTexture( GL_FRAMEBUFFER ,
|
||||||
GL_DEPTH_ATTACHMENT ,
|
GL_DEPTH_ATTACHMENT ,
|
||||||
depthAttachment_->texture->id( ) ,
|
de.texture->id( ) ,
|
||||||
depthAttachment_->level );
|
de.level );
|
||||||
}
|
}
|
||||||
assert( glCheckFramebufferStatus( GL_FRAMEBUFFER ) == GL_FRAMEBUFFER_COMPLETE );
|
assert( glCheckFramebufferStatus( GL_FRAMEBUFFER ) == GL_FRAMEBUFFER_COMPLETE );
|
||||||
glBindFramebuffer( GL_FRAMEBUFFER , 0 );
|
glBindFramebuffer( GL_FRAMEBUFFER , 0 );
|
||||||
|
@ -79,7 +80,7 @@ T_Rendertarget T_RendertargetSetup::create( )
|
||||||
// Reset config
|
// Reset config
|
||||||
hasAttachments_ = false;
|
hasAttachments_ = false;
|
||||||
colorAttachments_.clear( );
|
colorAttachments_.clear( );
|
||||||
depthAttachment_.reset( );
|
depthAttachment_.clear( );
|
||||||
|
|
||||||
return T_Rendertarget( id , nca , width_ , height_ );
|
return T_Rendertarget( id , nca , width_ , height_ );
|
||||||
}
|
}
|
||||||
|
@ -129,7 +130,7 @@ bool T_Rendertarget::activate( )
|
||||||
if ( nCats_ != buffers_.size( ) ) {
|
if ( nCats_ != buffers_.size( ) ) {
|
||||||
buffers_.clear( );
|
buffers_.clear( );
|
||||||
for ( auto i = 0u ; i < nCats_ ; i ++ ) {
|
for ( auto i = 0u ; i < nCats_ ; i ++ ) {
|
||||||
buffers_.push_back( GL_COLOR_ATTACHMENT0 + i );
|
buffers_.add( GL_COLOR_ATTACHMENT0 + i );
|
||||||
}
|
}
|
||||||
#ifdef INTRUSIVE_TRACES
|
#ifdef INTRUSIVE_TRACES
|
||||||
printf( "fb %d: created buffers (%d items)\n" , id_ ,
|
printf( "fb %d: created buffers (%d items)\n" , id_ ,
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
# include "externals.hh"
|
# include "externals.hh"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <ebcl/Arrays.hh>
|
||||||
#include "texture.hh"
|
#include "texture.hh"
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,6 +33,7 @@ struct T_RendertargetSetup
|
||||||
: texture( &texture ) , level( level )
|
: texture( &texture ) , level( level )
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
using T_Attachments_ = ebcl::T_AutoArray< T_Attachment_ , 8 >;
|
||||||
|
|
||||||
void checkAttachment(
|
void checkAttachment(
|
||||||
__rw__ T_Texture const& texture ,
|
__rw__ T_Texture const& texture ,
|
||||||
|
@ -39,8 +41,9 @@ struct T_RendertargetSetup
|
||||||
|
|
||||||
bool hasAttachments_;
|
bool hasAttachments_;
|
||||||
uint32_t width_ , height_;
|
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:
|
private:
|
||||||
GLuint id_;
|
GLuint id_;
|
||||||
uint32_t nCats_ , width_ , height_;
|
uint32_t nCats_ , width_ , height_;
|
||||||
std::vector< GLenum > buffers_;
|
ebcl::T_AutoArray< GLenum , 8 > buffers_;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue