demotool/ui-rendertarget.hh

85 lines
1.6 KiB
C++
Raw Normal View History

2017-09-30 14:59:15 +02:00
#pragma once
#ifndef REAL_BUILD
# include "externals.hh"
#endif
2017-11-01 23:45:09 +01:00
#include <ebcl/Arrays.hh>
2017-10-02 09:40:36 +02:00
struct T_Texture;
2017-09-30 14:59:15 +02:00
struct T_Rendertarget;
2017-10-02 09:40:36 +02:00
2017-09-30 14:59:15 +02:00
struct T_RendertargetSetup
{
T_RendertargetSetup( );
T_RendertargetSetup& add(
2017-11-03 09:08:19 +01:00
T_Texture& texture ,
const uint32_t level = 0 );
2017-09-30 14:59:15 +02:00
T_RendertargetSetup& depth(
2017-11-03 09:08:19 +01:00
T_Texture& texture );
2017-09-30 14:59:15 +02:00
T_Rendertarget create( );
private:
struct T_Attachment_ {
T_Texture* texture;
uint32_t level;
T_Attachment_(
2017-11-03 09:08:19 +01:00
T_Texture& texture ,
const uint32_t level )
2017-09-30 14:59:15 +02:00
: texture( &texture ) , level( level )
{}
};
2017-11-01 23:45:09 +01:00
using T_Attachments_ = ebcl::T_AutoArray< T_Attachment_ , 8 >;
2017-09-30 14:59:15 +02:00
void checkAttachment(
2017-11-03 09:08:19 +01:00
T_Texture const& texture ,
const uint32_t level );
2017-09-30 14:59:15 +02:00
bool hasAttachments_;
uint32_t width_ , height_;
2017-11-01 23:45:09 +01:00
T_Attachments_ colorAttachments_;
ebcl::T_Optional< T_Attachment_ > depthAttachment_;
2017-09-30 14:59:15 +02:00
};
struct T_Rendertarget
{
T_Rendertarget( T_Rendertarget const& ) = delete;
T_Rendertarget( );
2017-09-30 14:59:15 +02:00
T_Rendertarget(
2017-11-03 09:08:19 +01:00
const GLuint id ,
const uint32_t nCats ,
const uint32_t width ,
const uint32_t height );
2017-09-30 14:59:15 +02:00
2017-11-03 09:08:19 +01:00
T_Rendertarget( T_Rendertarget&& other ) noexcept;
2017-09-30 14:59:15 +02:00
T_Rendertarget& operator =(
2017-11-03 09:08:19 +01:00
T_Rendertarget&& ) noexcept;
2017-09-30 14:59:15 +02:00
~T_Rendertarget( );
void attach( T_Texture const& texture ,
uint32_t lod ,
uint32_t id );
void toggle( uint32_t id , bool active );
2017-09-30 14:59:15 +02:00
bool activate( );
GLuint id( ) const { return id_; }
uint32_t width( ) const { return width_; }
uint32_t height( ) const { return height_; }
2017-09-30 14:59:15 +02:00
static void MainOutput( );
private:
GLuint id_;
uint32_t nCats_ , width_ , height_;
2017-11-01 23:45:09 +01:00
ebcl::T_AutoArray< GLenum , 8 > buffers_;
2017-09-30 14:59:15 +02:00
};