All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Luminous::Program Class Reference

A shader program, combining multiple Shader objects into one runnable program. More...

#include <Luminous/Program.hpp>

Inheritance diagram for Luminous::Program:
Luminous::RenderResource

Public Member Functions

LUMINOUS_API ShaderaddShader (const QByteArray &code, Shader::Type type)
 Adds shader for this program. More...
 
LUMINOUS_API Hash hash () const
 Hash value for this program which is calculated based on the hashes of attached shaders. More...
 
ShaderloadFragmentShader (const QString &filename)
 Reads fragment shader from the given file. More...
 
LUMINOUS_API ShaderloadShader (const QString &filename, Shader::Type type)
 Adds shader for this program. More...
 
ShaderloadVertexShader (const QString &filename)
 Reads vertex shader from the given file. More...
 
LUMINOUS_API Programoperator= (Program &&prog)
 
LUMINOUS_API Program ()
 Constructor for Program.
 
LUMINOUS_API Program (Program &&prog)
 Move constructor. More...
 
LUMINOUS_API void removeAllShaders ()
 Removes and destroys all shaders attached for this program.
 
LUMINOUS_API void removeShader (const Shader &shader)
 Removes given shader. More...
 
LUMINOUS_API float sampleShading () const
 Sample shading value for objects rendered with this shader, see glMinSampleShading This is not supported in OS X Mountain Lion. More...
 
LUMINOUS_API void setSampleShading (float sample)
 Sets sample shading. Used as a value for glMinSampleShading.
 
LUMINOUS_API void setTranslucency (bool translucency)
 Sets translucency flag. More...
 
LUMINOUS_API void setVertexDescription (const VertexDescription &description)
 Sets format for vertices used in program. More...
 
LUMINOUS_API Shadershader (size_t index) const
 Returns shader associated with the program. More...
 
LUMINOUS_API size_t shaderCount () const
 How many shaders are attached to this program. More...
 
LUMINOUS_API QStringList shaderFilenames () const
 Returns the list of filenames where shaders are read. More...
 
LUMINOUS_API bool translucent () const
 Does the program render translucent geometry. More...
 
LUMINOUS_API const
VertexDescription
vertexDescription () const
 Returns vertex format used in program. More...
 
LUMINOUS_API ~Program ()
 Destructor for Program.
 
- Public Member Functions inherited from Luminous::RenderResource
unsigned int expiration () const
 Returns resource expiration time. More...
 
int generation () const
 Returns generation of this resource. More...
 
void invalidate ()
 Invalidates correspondent GPU objects and forces uploading of data to GPU.
 
RenderResourceoperator= (RenderResource &&rr)
 Move assignment operator. More...
 
 RenderResource (Type type)
 Constructor of RenderResource. More...
 
 RenderResource (RenderResource &&rr)
 Move constructor. More...
 
Id resourceId () const
 Returns identifier of resource. More...
 
Type resourceType () const
 Returns type of the resource. More...
 
void setExpiration (unsigned int seconds)
 Set resource expiration time. More...
 
void setGeneration (int generation)
 Sets generation for this resource. More...
 
virtual ~RenderResource ()
 Destructor of RenderResource.
 

Additional Inherited Members

- Public Types inherited from Luminous::RenderResource
typedef uint64_t Id
 Id of a resource.
 
enum  Type {
  VertexArray, Buffer, Program, Texture,
  RenderBuffer, FrameBuffer
}
 Different types of render resources. More...
 
- Protected Member Functions inherited from Luminous::RenderResource
RenderResourceoperator= (const RenderResource &rr)
 Assignment operator. More...
 
 RenderResource (const RenderResource &rr)
 Copy constructor. More...
 

Detailed Description

A shader program, combining multiple Shader objects into one runnable program.

GPU correspondent of this class is ProgramGL.

Examples:
AdvancedRenderingExample.cpp, PostProcessingExample.cpp, and Widget3DExample.cpp.

Constructor & Destructor Documentation

LUMINOUS_API Luminous::Program::Program ( Program &&  prog)

Move constructor.

Parameters
progProgram to move

Member Function Documentation

LUMINOUS_API Shader* Luminous::Program::addShader ( const QByteArray &  code,
Shader::Type  type 
)

Adds shader for this program.

The newly created shader is managed by this object.

Parameters
codeSource code for the shader
typeType of the shader
Returns
Pointer to the shader
LUMINOUS_API Hash Luminous::Program::hash ( ) const

Hash value for this program which is calculated based on the hashes of attached shaders.

Returns
Hash value for this program
Shader* Luminous::Program::loadFragmentShader ( const QString &  filename)
inline

Reads fragment shader from the given file.

Parameters
filenameFile where shader source code is located
Returns
Pointer to the shader. nullptr if couldn't read
Examples:
AdvancedRenderingExample.cpp.
LUMINOUS_API Shader* Luminous::Program::loadShader ( const QString &  filename,
Shader::Type  type 
)

Adds shader for this program.

The newly created shader is managed by this object.

Parameters
filenameFile where shader source code is located
typeType of the shader
Returns
Pointer to the shader. nullptr if couldn't read
Shader* Luminous::Program::loadVertexShader ( const QString &  filename)
inline

Reads vertex shader from the given file.

Parameters
filenameFile where shader source code is located
Returns
Pointer to the shader. nullptr if couldn't read
Examples:
AdvancedRenderingExample.cpp.
LUMINOUS_API Program& Luminous::Program::operator= ( Program &&  prog)
Parameters
prog
Returns
Reference to this
LUMINOUS_API void Luminous::Program::removeShader ( const Shader shader)

Removes given shader.

The comparison between shaders is done based on the memory adresses of shaders.

Parameters
shaderShader to remove.
LUMINOUS_API float Luminous::Program::sampleShading ( ) const

Sample shading value for objects rendered with this shader, see glMinSampleShading This is not supported in OS X Mountain Lion.

LUMINOUS_API void Luminous::Program::setTranslucency ( bool  translucency)

Sets translucency flag.

Parameters
translucencyIs there possibility for translucent rendering
LUMINOUS_API void Luminous::Program::setVertexDescription ( const VertexDescription description)

Sets format for vertices used in program.

Parameters
descriptionDescription to use in vertex shaders
Examples:
AdvancedRenderingExample.cpp.
LUMINOUS_API Shader& Luminous::Program::shader ( size_t  index) const

Returns shader associated with the program.

Parameters
indexThe ordering number of shader (first read gets 0, second 1 etc)
Returns
Reference to the shader
LUMINOUS_API size_t Luminous::Program::shaderCount ( ) const

How many shaders are attached to this program.

Returns
Number of shaders
LUMINOUS_API QStringList Luminous::Program::shaderFilenames ( ) const

Returns the list of filenames where shaders are read.

Returns
List of filenames
LUMINOUS_API bool Luminous::Program::translucent ( ) const

Does the program render translucent geometry.

Is important for reordering of rendering commands.

Returns
Is there possibility for translucent rendering
LUMINOUS_API const VertexDescription& Luminous::Program::vertexDescription ( ) const

Returns vertex format used in program.

Returns
Vertex description used in program