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

Detailed Description

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

Definition at line 382 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 389 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 392 of file GLUtil.hh.

◆ ~ShaderProgram()

gl::ShaderProgram::~ShaderProgram ( )
inline

Destroy handler object (release the underlying openGL object).

Definition at line 395 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 279 of file GLUtil.cc.

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

◆ allocate()

void gl::ShaderProgram::allocate ( )

Allocate a shader program handle.

Definition at line 209 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 234 of file GLUtil.cc.

References gl::Shader::isOK().

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

◆ 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 266 of file GLUtil.cc.

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

◆ get()

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

Returns the underlying openGL handler id.

0 iff no openGL program is allocated.

Definition at line 406 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 271 of file GLUtil.cc.

References isOK().

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

◆ 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 226 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 246 of file GLUtil.cc.

References isOK(), openmsx::Version::RELEASE, and VLA.

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

◆ operator=()

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

◆ reset()

void gl::ShaderProgram::reset ( )

Release the shader program handle.

Definition at line 217 of file GLUtil.cc.

Referenced by ~ShaderProgram().

◆ validate()

void gl::ShaderProgram::validate ( ) const

Definition at line 285 of file GLUtil.cc.

References VLA.


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