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 () const
 

Detailed Description

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

Definition at line 378 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 385 of file GLUtil.hh.

References allocate().

◆ ShaderProgram() [3/3]

gl::ShaderProgram::ShaderProgram ( Null  )
inlineexplicit

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

Definition at line 388 of file GLUtil.hh.

◆ ~ShaderProgram()

gl::ShaderProgram::~ShaderProgram ( )
inline

Destroy handler object (release the underlying openGL object).

Definition at line 391 of file GLUtil.hh.

References reset().

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 298 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 231 of file GLUtil.cc.

Referenced by gl::Context::Context(), and ShaderProgram().

◆ attach()

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

Adds a given shader to this program.

Definition at line 253 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 285 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 402 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 290 of file GLUtil.cc.

References 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 245 of file GLUtil.cc.

Referenced by getUniformLocation(), and link().

◆ link()

void gl::ShaderProgram::link ( )

Links all attached shaders together into one program.

This should be done before activating the program.

Definition at line 265 of file GLUtil.cc.

References 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 239 of file GLUtil.cc.

Referenced by ~ShaderProgram().

◆ validate()

void gl::ShaderProgram::validate ( ) const

Definition at line 304 of file GLUtil.cc.

References VLA.


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