demotool/programs.hh

69 lines
1.4 KiB
C++
Raw Normal View History

2017-10-01 19:40:38 +02:00
#pragma once
2017-10-02 09:40:36 +02:00
#include "filewatcher.hh"
2017-10-02 09:40:36 +02:00
2017-10-01 19:40:38 +02:00
/*= T_ShaderCode =============================================================*/
struct T_ShaderCode
{
T_ShaderCode( ) = delete;
T_ShaderCode( T_ShaderCode const& ) = delete;
T_ShaderCode( T_ShaderCode&& ) = delete;
explicit T_ShaderCode( __rd__ const int nparts );
~T_ShaderCode( );
void setPart(
__rd__ const int index ,
__rd__ char const* const string );
void setPart(
__rd__ const int index ,
__rd__ void const* const data ,
__rd__ const int size );
bool loadPart(
__rd__ const int index ,
__rd__ std::string const& source ,
__rw__ std::vector< std::string >& errors );
GLuint createProgram(
__rd__ GLenum type ,
__rw__ std::vector< std::string >& errors ) const;
private:
std::vector< char* > code;
};
struct T_ShaderProgram
{
T_ShaderProgram( ) = delete;
T_ShaderProgram( T_ShaderProgram const& ) = delete;
T_ShaderProgram( T_ShaderProgram&& ) = delete;
T_ShaderProgram( __rd__ GLenum programType );
2017-10-01 19:40:38 +02:00
~T_ShaderProgram( );
void addChunk( __rd__ std::string const& string );
void addFile( __rd__ std::string const& source );
void load( );
bool activate( ) const;
GLuint id( ) const { return program_; }
static T_ShaderProgram const& FullscreenQuad( );
2017-10-01 19:40:38 +02:00
private:
T_WatchedFiles files_;
std::vector< bool > chunksOrFiles_;
std::vector< std::string > parts_;
std::vector< std::string > errors_;
GLenum programType_;
GLuint program_;
};