Beatmup
Beatmup::GL::Shader Class Reference

GLSL shader base class. More...

#include <program.h>

Inheritance diagram for Beatmup::GL::Shader:
Beatmup::GL::ComputeProgram::Shader Beatmup::GL::FragmentShader Beatmup::GL::VertexShader

Public Member Functions

 ~Shader ()
 

Protected Member Functions

 Shader (const GraphicPipeline &gpu, const uint32_t type)
 
handle_t getHandle () const
 
uint32_t getType () const
 
void compile (const GraphicPipeline &gpu, const char *source)
 

Private Member Functions

 Shader (const Shader &)=delete
 disabling copying constructor More...
 

Private Attributes

handle_t handle
 
uint32_t type
 

Friends

class Program
 

Detailed Description

GLSL shader base class.

Definition at line 75 of file program.h.

Constructor & Destructor Documentation

◆ Shader() [1/2]

Beatmup::GL::Shader::Shader ( const Shader )
privatedelete

disabling copying constructor

◆ Shader() [2/2]

Shader::Shader ( const GraphicPipeline gpu,
const uint32_t  type 
)
protected

Definition at line 40 of file program.cpp.

40  : type(type) {
41  handle = glCreateShader(type);
42 }
uint32_t type
Definition: program.h:80
handle_t handle
Definition: program.h:79

◆ ~Shader()

Shader::~Shader ( )

Definition at line 45 of file program.cpp.

45  {
46  glDeleteShader(handle);
47 }

Member Function Documentation

◆ getHandle()

handle_t Beatmup::GL::Shader::getHandle ( ) const
inlineprotected

Definition at line 83 of file program.h.

83 { return handle; }

◆ getType()

uint32_t Beatmup::GL::Shader::getType ( ) const
inlineprotected

Definition at line 84 of file program.h.

84 { return type; }

◆ compile()

void Shader::compile ( const GraphicPipeline gpu,
const char *  source 
)
protected

Definition at line 50 of file program.cpp.

50  {
51  glShaderSource(handle, 1, &source, 0);
52  glCompileShader(handle);
53 
54  GLint status;
55  glGetShaderiv(handle, GL_COMPILE_STATUS, &status);
56  if (status == GL_TRUE)
57  return;
58  GLint logLength;
59  glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &logLength);
60  if (logLength > 0) {
61  GLchar* log = (GLchar*)malloc(logLength);
62  glGetShaderInfoLog(handle, logLength, &logLength, log);
63  std::string msg((char*)log);
64  free(log);
65 #ifdef BEATMUP_DEBUG
66  msg = msg + "\n" + source;
67 #endif
68  throw GL::GLException(msg.c_str());
69  }
70  else
71  throw GL::GLException("Shader compilation failed (no log).");
72 }
GPU exception.
Definition: bgl.h:56

Friends And Related Function Documentation

◆ Program

friend class Program
friend

Definition at line 76 of file program.h.

Member Data Documentation

◆ handle

handle_t Beatmup::GL::Shader::handle
private

Definition at line 79 of file program.h.

◆ type

uint32_t Beatmup::GL::Shader::type
private

Definition at line 80 of file program.h.


The documentation for this class was generated from the following files: