demotool/programs.hh

72 lines
1.5 KiB
C++

#pragma once
#ifndef REAL_BUILD
# include "externals.hh"
# include "utilities.hh"
#endif
/*= 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 ,
__rw__ T_FilesWatcher& watcher );
~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(
__rw__ T_FilesWatcher& watcher );
private:
T_WatchedFiles files_;
std::vector< bool > chunksOrFiles_;
std::vector< std::string > parts_;
std::vector< std::string > errors_;
GLenum programType_;
GLuint program_;
};