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
 
 ShaderProgram (ShaderProgram &&)=delete
 
ShaderProgramoperator= (const ShaderProgram &)=delete
 
ShaderProgramoperator= (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 362 of file GLUtil.hh.

Constructor & Destructor Documentation

◆ ShaderProgram() [1/4]

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

◆ ShaderProgram() [2/4]

gl::ShaderProgram::ShaderProgram ( ShaderProgram &&  )
delete

◆ ShaderProgram() [3/4]

gl::ShaderProgram::ShaderProgram ( )
inline

Create handler and allocate underlying openGL object.

Definition at line 371 of file GLUtil.hh.

References allocate().

◆ ShaderProgram() [4/4]

gl::ShaderProgram::ShaderProgram ( Null  )
inlineexplicit

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

Definition at line 374 of file GLUtil.hh.

◆ ~ShaderProgram()

gl::ShaderProgram::~ShaderProgram ( )
inline

Destroy handler object (release the underlying openGL object).

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

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

◆ allocate()

void gl::ShaderProgram::allocate ( )

Allocate a shader program handle.

Definition at line 212 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 237 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 269 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 388 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 274 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 229 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 249 of file GLUtil.cc.

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

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

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ reset()

void gl::ShaderProgram::reset ( )

Release the shader program handle.

Definition at line 220 of file GLUtil.cc.

Referenced by ~ShaderProgram().

◆ validate()

void gl::ShaderProgram::validate ( ) const

Definition at line 288 of file GLUtil.cc.


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