demotool/rendertarget.hh

76 lines
1.4 KiB
C++
Raw Normal View History

2017-09-30 14:59:15 +02:00
#pragma once
#ifndef REAL_BUILD
# include "externals.hh"
#endif
2017-10-02 09:40:36 +02:00
#include "texture.hh"
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(
__rw__ T_Texture& texture ,
__rd__ const uint32_t level = 0 );
T_RendertargetSetup& depth(
__rw__ T_Texture& texture );
T_Rendertarget create( );
private:
struct T_Attachment_ {
T_Texture* texture;
uint32_t level;
T_Attachment_(
__rw__ T_Texture& texture ,
__rd__ const uint32_t level )
: texture( &texture ) , level( level )
{}
};
void checkAttachment(
__rw__ T_Texture const& texture ,
__rd__ const uint32_t level );
bool hasAttachments_;
uint32_t width_ , height_;
std::vector< T_Attachment_ > colorAttachments_;
std::unique_ptr< T_Attachment_ > depthAttachment_;
};
struct T_Rendertarget
{
T_Rendertarget( ) = delete;
T_Rendertarget( T_Rendertarget const& ) = delete;
T_Rendertarget(
__rd__ const GLuint id ,
__rd__ const uint32_t nCats ,
__rd__ const uint32_t width ,
__rd__ const uint32_t height );
T_Rendertarget( __rw__ T_Rendertarget&& other ) noexcept;
T_Rendertarget& operator =(
__rw__ T_Rendertarget&& ) noexcept;
~T_Rendertarget( );
bool activate( );
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_;
std::vector< GLenum > buffers_;
};