PrevUpHomeNext

Uniform subroutines

#include <oglplus/uniform_subroutines.hpp>

Basic location operations

template <>
class ProgVarLocOps<tag::Subroutine>
{
public:
	static GLint GetLocation(
		ProgramName program,
		ShaderType stage,
		StrCRef identifier,
		bool active_only
	); 1

	GLint GetLocation(
		ProgramName program,
		StrCRef identifier,
		bool active_only
	) const;

	ShaderType Stage(void) const; 2
};

1

Finds the location of the subroutine specified by identifier in the stage of a program. If active_only is true then throws ProgVarError if no such subroutine exists or if it is not active. See glGetSubroutineIndex.

2

Returns this subroutine's program stage.

template <>
class ProgVarLocOps<tag::SubroutineUniform>
{
public:
	static GLint GetLocation(
		ProgramName program,
		ShaderType stage,
		StrCRef identifier,
		bool active_only
	); 1

	GLint GetLocation(
		ProgramName program,
		StrCRef identifier,
		bool active_only
	) const;

	ShaderType Stage(void) const; 2
};

1

Finds the location of the subroutine uniform specified by identifier in the stage of a program. If active_only is true then throws ProgVarError if no such uniform exists or if it is not active. See glGetSubroutineUniformLocation.

2

Returns this subroutine uniforms's program stage.

Specializations of ProgVar

template <>
class ProgVar<tag::ImplicitSel, tag::Subroutine, tag::NoTypecheck, void>
 : public ProgVarLoc<tag::Subroutine>
{
public:
	ProgVar(ProgVarLoc<tag::Subroutine> pvloc);

	ProgVar(ProgramName program, ShaderType stage, StrCRef identifier);

	ProgVar(
		ProgramName program,
		ShaderType stage,
		StrCRef identifier,
		bool active_only
	);
};
template <>
class ProgVar<tag::ImplicitSel, tag::SubroutineUniform, tag::NoTypecheck, void>
 : public ProgVarLoc<tag::SubroutineUniform>
{
public:
	ProgVar(ProgVarLoc<tag::SubroutineUniform> pvloc);

	ProgVar(ProgramName program, ShaderType stage, StrCRef identifier);

	ProgVar(
		ProgramName program,
		ShaderType stage,
		StrCRef identifier,
		bool active_only
	);
};

Definitions

typedef ProgVar<
	tag::ImplicitSel,
	tag::Subroutine,
	tag::NoTypecheck,
	void
> Subroutine;
typedef ProgVar<
	tag::ImplicitSel,
	tag::SubroutineUniform,
	tag::NoTypecheck,
	void
> SubroutineUniform;

Manager

class UniformSubroutines
{
public:
	UniformSubroutines(ProgramName program, ShaderType stage); 1

	UniformSubroutines& Assign(
		const SubroutineUniform& uniform,
		const Subroutine& subroutine
	); 2

	void Apply(void); 3

	class Preset 4
	{
	public:
		Preset(Preset&&);
	};

	Preset Save(void); 5
	void Load(const Preset& preset); 6

	void Apply(const Preset& preset); 7
};

1

Constructs a uniform subroutine manager for a stage of a program.

2

Remembers the assignment of a subroutine to the specified subroutine uniform.

[Note] Note

This function does not immediately apply the changes to the actual uniform variables in the managed stage of a GPU program. Use the member Apply function to do this after the subroutines are assigned to subroutine uniforms.

3

Applies all changes made by Assign.

4

Preset stores a setting of the whole set of subroutine uniforms. which can be later applied or loaded. Applications should treat this type as opaque and use it only with the Save, Load and Apply functions.

5

Saves the current setting of subroutine uniforms into a preset.

6

Loads the setting of subroutine uniforms from a preset.

[Note] Note

Only presets from the same instance of UniformSubroutines that saved them can be loaded or applied.

7

Applies the setting from a preset without changing the current setting of this instance of UniformSubroutines.

[Note] Note

Only presets from the same instance of UniformSubroutines that saved them can be loaded or applied.


PrevUpHomeNext