PixelLightAPI  .
Public Member Functions | Public Attributes | Protected Member Functions
PLRenderer::Program Class Reference

Abstract renderer program resource. More...

#include <Program.h>

Inheritance diagram for PLRenderer::Program:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual PLRENDERER_API ~Program ()
 Destructor.
virtual PLCore::String GetShaderLanguage () const =0
 Returns the name of the shader language the program is using.
virtual PLRenderer::VertexShaderGetVertexShader () const =0
 Returns the vertex shader the program is using.
virtual bool SetVertexShader (PLRenderer::VertexShader *pVertexShader)=0
 Sets the vertex shader the program is using.
virtual
PLRenderer::GeometryShader
GetGeometryShader () const =0
 Returns the geometry shader the program is using.
virtual bool SetGeometryShader (PLRenderer::GeometryShader *pGeometryShader)=0
 Sets the geometry shader the program is using.
virtual
PLRenderer::FragmentShader
GetFragmentShader () const =0
 Returns the fragment shader the program is using.
virtual bool SetFragmentShader (PLRenderer::FragmentShader *pFragmentShader)=0
 Sets the fragment shader the program is using.
virtual bool IsValid ()=0
 Returns whether or not the program is valid (successfully compiled, linked and ready to be used)
virtual PLCore::String GetCompiledProgram ()=0
 Returns the compiled program.
virtual const PLCore::Array
< ProgramAttribute * > & 
GetAttributes ()=0
 Get attributes.
virtual ProgramAttributeGetAttribute (const PLCore::String &sName)=0
 Get attribute.
virtual const PLCore::Array
< ProgramUniform * > & 
GetUniforms ()=0
 Get uniforms.
virtual ProgramUniformGetUniform (const PLCore::String &sName)=0
 Get uniform.
virtual const PLCore::Array
< ProgramUniformBlock * > & 
GetUniformBlocks ()=0
 Get uniform blocks.
virtual ProgramUniformBlockGetUniformBlock (const PLCore::String &sName)=0
 Get uniform block.

Public Attributes

PLCore::Event< Program * > EventDirty

Protected Member Functions

virtual bool MakeCurrent ()=0
 Makes this program to the renderers currently used program.
virtual bool UnmakeCurrent ()=0
 This program will no longer be the renderers currently used program.
PLRENDERER_API Program (Renderer &cRenderer)
 Constructor.

Detailed Description

Abstract renderer program resource.

Note:
  • While each program must have a vertex shader and a fragment shader, a geometry shader is optional
  • The program is using lazy evaluation, so the program is only compiled & linked when really required
  • In performance critical situations, use uniform blocks if they are available
  • In performance critical situations, you may want to request e.g. the pointer to uniforms only once, not constantly

Constructor & Destructor Documentation

virtual PLRENDERER_API PLRenderer::Program::~Program ( ) [virtual]

Destructor.

PLRENDERER_API PLRenderer::Program::Program ( Renderer cRenderer) [protected]

Constructor.

Parameters:
[in]cRendererOwner renderer

Member Function Documentation

virtual PLCore::String PLRenderer::Program::GetShaderLanguage ( ) const [pure virtual]

Returns the name of the shader language the program is using.

Returns:
The name of the shader language the program is using (for example "GLSL" or "Cg")

Returns the vertex shader the program is using.

Returns:
Vertex shader the program is using (do not delete it), can be a null pointer
virtual bool PLRenderer::Program::SetVertexShader ( PLRenderer::VertexShader pVertexShader) [pure virtual]

Sets the vertex shader the program is using.

Parameters:
[in]pVertexShaderVertex shader the program is using, can be a null pointer, vertex shader and program language must match!
Returns:
'true' if all went fine, else 'false' (maybe shader language mismatch?)
Note:
  • The given vertex shader instance is just shared and will not be destroyed automatically by this program
  • The given vertex shader instance must stay valid as long as it's used within this program

Returns the geometry shader the program is using.

Returns:
Geometry shader the program is using (do not delete it), can be a null pointer
virtual bool PLRenderer::Program::SetGeometryShader ( PLRenderer::GeometryShader pGeometryShader) [pure virtual]

Sets the geometry shader the program is using.

Parameters:
[in]pGeometryShaderGeometry shader the program is using, can be a null pointer, geometry shader and program language must match!
Returns:
'true' if all went fine, else 'false' (maybe shader language mismatch?)
Note:
  • The given geometry shader instance is just shared and will not be destroyed automatically by this program
  • The given geometry shader instance must stay valid as long as it's used within this program

Returns the fragment shader the program is using.

Returns:
Fragment shader the program is using (do not delete it), can be a null pointer
virtual bool PLRenderer::Program::SetFragmentShader ( PLRenderer::FragmentShader pFragmentShader) [pure virtual]

Sets the fragment shader the program is using.

Parameters:
[in]pFragmentShaderFragment shader the program is using, can be a null pointer, fragment shader and program language must match!
Returns:
'true' if all went fine, else 'false' (maybe shader language mismatch?)
Note:
  • The given fragment shader instance is just shared and will not be destroyed automatically by this program
  • The given fragment shader instance must stay valid as long as it's used within this program
virtual bool PLRenderer::Program::IsValid ( ) [pure virtual]

Returns whether or not the program is valid (successfully compiled, linked and ready to be used)

Returns:
'true' if the program is valid, else 'false'

Returns the compiled program.

Returns:
The compiled program
Remarks:
		*    Usage example writing the compiled program into a text file:
		*
		*    PLCore::File cFile("d:\\CompiledProgram.txt");
		*    if (cFile.Open(PLCore::File::FileCreate|PLCore::File::FileWrite)) {
		*        const PLCore::String sProgram = pMyProgram->GetCompiledProgram();
		*        cFile.Write(sProgram.GetASCII(), sProgram.GetLength(), 1);
		*        cFile.Close();
		*    }
		*  
Note:
  • The compiled program depends on the used shader language, it's also possible that an implementation is not able to return a compiled program

Get attributes.

Returns:
List of attributes (do NOT delete the program attribute instances!)
virtual ProgramAttribute* PLRenderer::Program::GetAttribute ( const PLCore::String sName) [pure virtual]

Get attribute.

Parameters:
[in]sNameAttribute name
Returns:
Attribute (do not delete it, can be a null pointer, if no attribute with that name could be found)
virtual const PLCore::Array<ProgramUniform*>& PLRenderer::Program::GetUniforms ( ) [pure virtual]

Get uniforms.

Returns:
List of uniforms (do NOT delete the program uniform instances!)
virtual ProgramUniform* PLRenderer::Program::GetUniform ( const PLCore::String sName) [pure virtual]

Get uniform.

Parameters:
[in]sNameUniform name
Returns:
Uniform (do not delete it, can be a null pointer, if no uniform with that name could be found)
See also:
  • "ProgramUniform"-class for more information

Get uniform blocks.

Returns:
List of uniform blocks (do NOT delete the program uniform block instances!)
virtual ProgramUniformBlock* PLRenderer::Program::GetUniformBlock ( const PLCore::String sName) [pure virtual]

Get uniform block.

Parameters:
[in]sNameUniform block name
Returns:
Uniform block (do not delete it, can be a null pointer, if no uniform block with that name could be found)
virtual bool PLRenderer::Program::MakeCurrent ( ) [protected, pure virtual]

Makes this program to the renderers currently used program.

Returns:
'true' if all went fine, else 'false'
virtual bool PLRenderer::Program::UnmakeCurrent ( ) [protected, pure virtual]

This program will no longer be the renderers currently used program.

Returns:
'true' if all went fine, else 'false'

Member Data Documentation

The program became dirty, previous pointers to attributes or uniforms may no longer be valid, pointer to this program as parameter (always valid, do not delete it)


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


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:23
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported