@ -248,19 +248,17 @@ Basic workflow with %AbstractShaderProgram subclasses is: instance shader
class , configure attribute binding in meshes ( see @ ref Mesh - configuration " Mesh documentation "
class , configure attribute binding in meshes ( see @ ref Mesh - configuration " Mesh documentation "
for more information ) and map shader outputs to framebuffer attachments if
for more information ) and map shader outputs to framebuffer attachments if
needed ( see @ ref Framebuffer - usage " Framebuffer documentation " for more
needed ( see @ ref Framebuffer - usage " Framebuffer documentation " for more
information ) . In each draw event set uniforms , mark the shader for use , bind
information ) . In each draw event set uniforms , bind specific framebuffer ( if
specific framebuffer ( if needed ) and bind required textures to their
needed ) and bind required textures to their respective layers using
respective layers using @ ref AbstractTexture : : bind ( Int ) . Then call
@ ref AbstractTexture : : bind ( Int ) . Then call @ ref Mesh : : draw ( ) . Example :
@ ref Mesh : : draw ( ) . Example :
@ code
@ code
shader . setTransformation ( transformation )
shader . setTransformation ( transformation )
. setProjection ( projection )
. setProjection ( projection ) ;
. use ( ) ;
diffuseTexture . bind ( MyShader : : DiffuseTextureLayer ) ;
diffuseTexture . bind ( MyShader : : DiffuseTextureLayer ) ;
specularTexture . bind ( MyShader : : SpecularTextureLayer ) ;
specularTexture . bind ( MyShader : : SpecularTextureLayer ) ;
mesh . draw ( ) ;
mesh . draw ( shader ) ;
@ endcode
@ endcode
@ section AbstractShaderProgram - types Mapping between GLSL and Magnum types
@ section AbstractShaderProgram - types Mapping between GLSL and Magnum types
@ -303,9 +301,8 @@ also @ref Attribute::DataType enum for additional type options.
@ section AbstractShaderProgram - performance - optimization Performance optimizations
@ section AbstractShaderProgram - performance - optimization Performance optimizations
The engine tracks currently used shader program to avoid unnecessary calls to
% Shader limits ( such as @ ref maxVertexAttributes ( ) ) are cached , so repeated
@ fn_gl { UseProgram } . % Shader limits ( such as @ ref maxVertexAttributes ( ) )
queries don ' t result in repeated @ fn_gl { Get } calls .
are cached , so repeated queries don ' t result in repeated @ fn_gl { Get } calls .
If extension @ extension { ARB , separate_shader_objects } ( part of OpenGL 4.1 ) or
If extension @ extension { ARB , separate_shader_objects } ( part of OpenGL 4.1 ) or
@ extension { EXT , direct_state_access } is available , uniform setting functions
@ extension { EXT , direct_state_access } is available , uniform setting functions
@ -323,6 +320,8 @@ comes in handy.
@ todo ` GL_NUM_ { PROGRAM , SHADER } _BINARY_FORMATS ` + ` GL_ { PROGRAM , SHADER } _BINARY_FORMATS ` ( vector ) , ( @ extension { ARB , ES2_compatibility } )
@ todo ` GL_NUM_ { PROGRAM , SHADER } _BINARY_FORMATS ` + ` GL_ { PROGRAM , SHADER } _BINARY_FORMATS ` ( vector ) , ( @ extension { ARB , ES2_compatibility } )
*/
*/
class MAGNUM_EXPORT AbstractShaderProgram : public AbstractObject {
class MAGNUM_EXPORT AbstractShaderProgram : public AbstractObject {
friend class Mesh ;
friend class MeshView ;
friend struct Implementation : : ShaderProgramState ;
friend struct Implementation : : ShaderProgramState ;
public :
public :
@ -549,12 +548,13 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject {
*/
*/
std : : pair < bool , std : : string > validate ( ) ;
std : : pair < bool , std : : string > validate ( ) ;
# ifdef MAGNUM_BUILD_DEPRECATED
/**
/**
* @ brief Use shader for rendering
* @ brief Use shader for rendering
*
* @ deprecated Use @ ref Magnum : : Mesh : : draw ( AbstractShaderProgram & ) " Mesh::draw(AbstractShaderProgram&) " instead .
* @ see @ fn_gl { UseProgram }
*/
*/
void use ( ) ;
void use ( ) ;
# endif
protected :
protected :
# ifndef MAGNUM_TARGET_GLES2
# ifndef MAGNUM_TARGET_GLES2
@ -790,6 +790,10 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject {
# endif
# endif
private :
private :
# ifndef MAGNUM_BUILD_DEPRECATED
void use ( ) ;
# endif
void MAGNUM_LOCAL uniformImplementationDefault ( GLint location , GLsizei count , const GLfloat * values ) ;
void MAGNUM_LOCAL uniformImplementationDefault ( GLint location , GLsizei count , const GLfloat * values ) ;
void MAGNUM_LOCAL uniformImplementationDefault ( GLint location , GLsizei count , const Math : : Vector < 2 , GLfloat > * values ) ;
void MAGNUM_LOCAL uniformImplementationDefault ( GLint location , GLsizei count , const Math : : Vector < 2 , GLfloat > * values ) ;
void MAGNUM_LOCAL uniformImplementationDefault ( GLint location , GLsizei count , const Math : : Vector < 3 , GLfloat > * values ) ;
void MAGNUM_LOCAL uniformImplementationDefault ( GLint location , GLsizei count , const Math : : Vector < 3 , GLfloat > * values ) ;