openMSX
Public Member Functions | List of all members
gl::ShaderProgram Class Reference

Wrapper around an OpenGL program: a collection of vertex and fragment shaders. More...

#include <GLUtil.hh>

Public Member Functions

 ShaderProgram (const ShaderProgram &)=delete
 
ShaderProgramoperator= (const ShaderProgram &)=delete
 
 ShaderProgram ()
 Create handler and allocate underlying openGL object. More...
 
 ShaderProgram (Null)
 Create null handler (don't yet allocate a openGL object). More...
 
 ~ShaderProgram ()
 Destroy handler object (release the underlying openGL object). More...
 
void allocate ()
 Allocate a shader program handle. More...
 
void reset ()
 Release the shader program handle. More...
 
GLuint get () const
 Returns the underlying openGL handler id. More...
 
bool isOK () const
 Returns true iff this program was linked without errors. More...
 
void attach (const Shader &shader)
 Adds a given shader to this program. More...
 
void link ()
 Links all attached shaders together into one program. More...
 
void bindAttribLocation (unsigned index, const char *name)
 Bind the given name for a vertex shader attribute to the given location. More...
 
GLint getUniformLocation (const char *name) const
 Gets a reference to a uniform variable declared in the shader source. More...
 
void activate () const
 Makes this program the active shader program. More...
 
void validate ()
 

Detailed Description

Wrapper around an OpenGL program: a collection of vertex and fragment shaders.

Definition at line 393 of file GLUtil.hh.

Constructor & Destructor Documentation

◆ ShaderProgram() [1/3]

gl::ShaderProgram::ShaderProgram ( const ShaderProgram )
delete

◆ ShaderProgram() [2/3]

gl::ShaderProgram::ShaderProgram ( )
inline

Create handler and allocate underlying openGL object.

Definition at line 400 of file GLUtil.hh.

◆ ShaderProgram() [3/3]

gl::ShaderProgram::ShaderProgram ( Null  )
inlineexplicit

Create null handler (don't yet allocate a openGL object).

Definition at line 403 of file GLUtil.hh.

◆ ~ShaderProgram()

gl::ShaderProgram::~ShaderProgram ( )
inline

Destroy handler object (release the underlying openGL object).

Definition at line 406 of file GLUtil.hh.

Member Function Documentation

◆ activate()

void gl::ShaderProgram::activate ( ) const

Makes this program the active shader program.

This requires that the program is already linked.

Definition at line 309 of file GLUtil.cc.

Referenced by gl::Context::Context(), openmsx::GLRGBScaler::GLRGBScaler(), openmsx::GLSimpleScaler::GLSimpleScaler(), and openmsx::GLTVScaler::GLTVScaler().

◆ allocate()

void gl::ShaderProgram::allocate ( )

Allocate a shader program handle.

Definition at line 242 of file GLUtil.cc.

Referenced by gl::Context::Context().

◆ attach()

void gl::ShaderProgram::attach ( const Shader shader)

Adds a given shader to this program.

Definition at line 264 of file GLUtil.cc.

References gl::Shader::isOK().

Referenced by gl::Context::Context(), and openmsx::GLPostProcessor::GLPostProcessor().

◆ bindAttribLocation()

void gl::ShaderProgram::bindAttribLocation ( unsigned  index,
const char *  name 
)

Bind the given name for a vertex shader attribute to the given location.

Definition at line 296 of file GLUtil.cc.

Referenced by gl::Context::Context(), and openmsx::GLPostProcessor::GLPostProcessor().

◆ get()

GLuint gl::ShaderProgram::get ( ) const
inline

Returns the underlying openGL handler id.

0 iff no openGL program is allocated.

Definition at line 417 of file GLUtil.hh.

◆ getUniformLocation()

GLint gl::ShaderProgram::getUniformLocation ( const char *  name) const

Gets a reference to a uniform variable declared in the shader source.

Note that you have to activate this program before you can change the uniform variable's value.

Definition at line 301 of file GLUtil.cc.

References gl::Shader::isOK().

Referenced by gl::Context::Context(), openmsx::GLRGBScaler::GLRGBScaler(), openmsx::GLSimpleScaler::GLSimpleScaler(), and openmsx::GLTVScaler::GLTVScaler().

◆ isOK()

bool gl::ShaderProgram::isOK ( ) const

Returns true iff this program was linked without errors.

Note that this will certainly return false until link() is called.

Definition at line 256 of file GLUtil.cc.

◆ link()

void gl::ShaderProgram::link ( )

Links all attached shaders together into one program.

This should be done before activating the program.

Definition at line 276 of file GLUtil.cc.

References gl::Shader::isOK(), openmsx::YM2413Okazaki::RELEASE, and VLA.

Referenced by gl::Context::Context(), and openmsx::GLPostProcessor::GLPostProcessor().

◆ operator=()

ShaderProgram& gl::ShaderProgram::operator= ( const ShaderProgram )
delete

◆ reset()

void gl::ShaderProgram::reset ( )

Release the shader program handle.

Definition at line 250 of file GLUtil.cc.

◆ validate()

void gl::ShaderProgram::validate ( )

Definition at line 315 of file GLUtil.cc.

References VLA.


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