13 #ifndef OGLPLUS_PROGRAM_1107121519_HPP
14 #define OGLPLUS_PROGRAM_1107121519_HPP
16 #include <oglplus/config/compiler.hpp>
28 #include <oglplus/detail/base_range.hpp>
36 class VertexAttribOps;
50 static void Gen(tag::Create, GLsizei count, GLuint* names)
52 assert(names !=
nullptr);
53 for(GLsizei i=0; i<count; ++i)
55 names[i] = OGLPLUS_GLFUNC(CreateProgram)();
56 OGLPLUS_CHECK_SIMPLE(CreateProgram);
60 static void Delete(GLsizei count, GLuint* names)
62 assert(names !=
nullptr);
63 for(GLsizei i=0; i<count; ++i)
65 OGLPLUS_GLFUNC(DeleteProgram)(names[i]);
66 OGLPLUS_VERIFY_SIMPLE(DeleteProgram);
70 static GLboolean IsA(GLuint name)
73 GLboolean result = OGLPLUS_GLFUNC(IsProgram)(name);
74 OGLPLUS_VERIFY_SIMPLE(IsProgram);
82 typedef tag::Create Type;
90 static GLuint _binding(
void)
93 OGLPLUS_GLFUNC(GetIntegerv)(GL_CURRENT_PROGRAM, &name);
97 EnumParam(GLenum(GL_CURRENT_PROGRAM))
119 OGLPLUS_GLFUNC(UseProgram)(
GetGLName(program));
135 ,
public ObjBindingOps<tag::Program>
177 :
public ObjZeroOps<tag::DirectState, tag::Program>
182 GLint GetIntParam(GLenum query)
const
185 OGLPLUS_GLFUNC(GetProgramiv)(_name, query, &result);
195 #if GL_VERSION_4_0 || GL_ARB_shader_subroutine
196 GLint GetStageIntParam(GLenum stage, GLenum query)
const
199 OGLPLUS_GLFUNC(GetProgramStageiv)(_name, stage, query, &result);
238 return GetIntParam(GL_LINK_STATUS) == GL_TRUE;
250 String GetInfoLog(
void)
const;
282 #if OGLPLUS_DOCUMENTATION_ONLY ||\
283 GL_ARB_shading_language_include
302 const GLchar*
const* paths,
315 ObjectOps& BuildInclude(GLSLStrings&& incl)
324 ObjectOps& BuildInclude(
const GLSLSource&& incl)
344 return GetIntParam(GL_VALIDATE_STATUS) == GL_TRUE;
367 void TransformFeedbackVaryings(
369 const GLchar** varyings,
382 TransformFeedbackVaryings(
388 template <
typename std::
size_t N>
389 void TransformFeedbackVaryings(
390 const GLchar* (&varyings)[N],
394 TransformFeedbackVaryings(N, varyings, mode);
404 void TransformFeedbackVaryings(
405 const std::vector<String>& varyings,
409 #if OGLPLUS_DOCUMENTATION_ONLY
415 class ActiveVariableInfo
419 GLuint Index(
void)
const;
422 const String& Name(
void)
const;
425 const GLint Size(
void)
const;
458 typedef aux::ActiveVariableInfo ActiveVariableInfo;
462 typedef aux::ContextElementRange<
463 aux::ProgramInterfaceContext,
468 typedef aux::ContextElementRange<
469 aux::ProgramInterfaceContext,
470 aux::ActiveAttribInfo
473 typedef aux::ContextElementRange<
474 aux::ProgramInterfaceContext,
475 aux::ActiveUniformInfo
478 #if GL_VERSION_4_0 || GL_ARB_shader_subroutine
479 typedef aux::ContextElementRange<
480 aux::ProgramInterfaceContext,
481 aux::ActiveSubroutineInfo
482 > ActiveSubroutineRange;
484 typedef aux::ContextElementRange<
485 aux::ProgramInterfaceContext,
486 aux::ActiveSubroutineUniformInfo
489 typedef aux::ContextElementRange<
490 aux::ProgramInterfaceContext,
491 aux::TransformFeedbackVaryingInfo
494 struct ShaderIterationContext
496 std::vector<GLuint> _shader_names;
498 ShaderIterationContext(GLuint name, GLuint count);
500 ShaderIterationContext(ShaderIterationContext&& temp)
501 : _shader_names(std::move(temp._shader_names))
505 struct IteratedShaderName
509 const ShaderIterationContext& context,
511 ):
ShaderName(context._shader_names.at(index))
515 typedef aux::ContextElementRange<
516 ShaderIterationContext,
519 #endif // !OGLPLUS_DOCUMENTATION_ONLY
521 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_3
545 InterfaceContext ActiveAttribContext(
void)
const;
554 ActiveAttribRange ActiveAttribs(
void)
const;
560 InterfaceContext ActiveUniformContext(
void)
const;
569 ActiveUniformRange ActiveUniforms(
void)
const;
571 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_0 || GL_ARB_shader_subroutine
577 InterfaceContext ActiveSubroutineContext(
ShaderType stage)
const;
588 ActiveSubroutineRange ActiveSubroutines(
ShaderType stage)
const;
594 InterfaceContext ActiveSubroutineUniformContext(
ShaderType stage)
const;
605 ActiveSubroutineUniformRange ActiveSubroutineUniforms(
ShaderType stage)
const;
612 InterfaceContext TransformFeedbackVaryingContext(
void)
const;
621 TransformFeedbackVaryingRange TransformFeedbackVaryings(
void)
const;
624 ShaderRange AttachedShaders(
void)
const;
626 #if OGLPLUS_DOCUMENTATION_ONLY
633 class ActiveUniformBlockInfo
636 GLuint Index(
void)
const;
639 const String& Name(
void)
const;
647 typedef aux::ContextElementRange<
648 aux::ProgramInterfaceContext,
649 aux::ActiveUniformBlockInfo
650 > ActiveUniformBlockRange;
660 ActiveUniformBlockRange ActiveUniformBlocks(
void)
const;
662 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_1 || GL_ARB_separate_shader_objects
669 ObjectOps& MakeSeparable(
bool para =
true);
670 #endif // separate shader objects
672 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_1 || GL_ARB_get_program_binary
681 ObjectOps& MakeRetrievable(
bool para =
true);
694 void GetBinary(std::vector<GLubyte>& binary, GLenum& format)
const;
705 void Binary(
const std::vector<GLubyte>& binary, GLenum format);
706 #endif // get program binary
717 GetIntParam(GL_TRANSFORM_FEEDBACK_BUFFER_MODE)
721 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_3_2
730 return GetIntParam(GL_GEOMETRY_VERTICES_OUT);
734 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_1 || GL_ARB_gpu_shader5
745 return GetIntParam(GL_GEOMETRY_SHADER_INVOCATIONS);
747 #endif // gpu shader 5
749 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_3_2
776 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_0 || GL_ARB_tessellation_shader
823 return GetIntParam(GL_TESS_GEN_POINT_MODE) == GL_TRUE;
825 #endif // tessellation shader
837 OGLPLUS_GLFUNC(BindAttribLocation)(
839 GLuint(vertex_attrib_slot),
846 Identifier(identifier).
847 Index(GLuint(vertex_attrib_slot))
853 typedef ObjectOps<tag::DirectState, tag::Program>
860 typedef ObjectZero<ObjZeroOps<tag::DirectState, tag::Program>>
880 struct ProgAndXFBMode
891 inline ProgAndXFBMode operator << (
896 return ProgAndXFBMode(prog, mode);
899 template <std::
size_t N>
902 const GLchar* (&varyings)[N]
905 pam.prog.TransformFeedbackVaryings(varyings, pam.mode);
909 struct ProgXFBModeAndNames
913 std::vector<const GLchar*> names;
915 ProgXFBModeAndNames(ProgAndXFBMode pam,
const GLchar* name)
920 names.push_back(name);
923 ProgXFBModeAndNames(ProgXFBModeAndNames&& pman,
const GLchar* name)
926 , names(std::move(pman.names))
928 names.push_back(name);
931 ProgXFBModeAndNames(ProgXFBModeAndNames&& tmp)
934 , names(std::move(tmp.names))
938 #if !OGLPLUS_NO_DELETED_FUNCTIONS
939 ProgXFBModeAndNames(
const ProgXFBModeAndNames&) =
delete;
942 ProgXFBModeAndNames(
const ProgXFBModeAndNames&);
946 ~ProgXFBModeAndNames(
void)
950 prog.TransformFeedbackVaryings(
959 inline ProgXFBModeAndNames operator << (
964 return ProgXFBModeAndNames(pam, name);
967 inline ProgXFBModeAndNames operator << (
968 ProgXFBModeAndNames&& pman,
972 return ProgXFBModeAndNames(std::move(pman), name);
976 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_1 || GL_ARB_separate_shader_objects
991 const GLchar*
const* strings
994 template <
typename Src>
997 return _make(shader_type, source.Count(), source.Parts());
1009 ):
Program(_make(shader_type, source))
1019 ObjectDesc&& object_desc
1020 ):
Program(_make(shader_type, source), std::move(object_desc))
1030 ):
Program(_make(shader_type, source))
1040 ObjectDesc&& object_desc
1041 ):
Program(_make(shader_type, source), std::move(object_desc))
1051 ):
Program(_make(shader_type, glsl_source.Count(), glsl_source.Parts()))
1061 ObjectDesc&& object_desc
1063 _make(shader_type, glsl_source.Count(), glsl_source.Parts()),
1064 std::move(object_desc)
1083 AttachShaders(shaders);
1090 ObjectDesc&& object_desc,
1092 ):
Program(std::move(object_desc))
1094 AttachShaders(shaders);
1099 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_1 || GL_ARB_separate_shader_objects
1106 AttachShaders(shaders);
1107 if(separable) MakeSeparable();
1117 ObjectDesc&& object_desc,
1120 ):
Program(std::move(object_desc))
1122 AttachShaders(shaders);
1123 if(separable) MakeSeparable();
1132 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
1133 #include <oglplus/program.ipp>
1134 #endif // OGLPLUS_LINK_LIBRARY
1136 #endif // include guard
Range< ActiveUniformBlockInfo > ActiveUniformRange
The type of the range for traversing active uniform blocks.
Definition: program.hpp:645
const Char * c_str(void) const
Returns the null-terminated c-string.
Definition: ref_tpl.hpp:200
ShaderType
The type of a Shader.
Definition: shader_type.hpp:26
Information about a single active program resource.
Definition: program_resource.hpp:46
static ProgramName Binding(void)
Returns the currently bound (active) Program.
Definition: program.hpp:107
Common base class for Object name sequences.
Definition: fwd.hpp:139
TessGenPrimitiveSpacing
Tesselation primitive spacing.
Definition: primitive_type.hpp:61
ObjectOps & AttachShader(ShaderName shader)
Attaches the shader to this program.
Range< ActiveVariableInfo > ActiveAttribRange
The type of the range for traversing active vertex attributes.
Definition: program.hpp:448
Wrapper class for all ranges that can be used for Element traversal.
Definition: ranges.hpp:39
ShaderProgram(ShaderType shader_type, GLSLString &&source, ObjectDesc &&object_desc)
Creates a program with a single shader with specified type and source.
Definition: program.hpp:1016
void Use(void) const
Uses this program object.
Definition: program.hpp:165
QuickProgram(const Sequence< ShaderName > &shaders)
Attaches shaders, links and uses the program.
Definition: program.hpp:1081
A class that allows to build programs in the constructor.
Definition: program.hpp:1076
Range< ActiveVariableInfo > ActiveUniformRange
The type of the range for traversing active uniforms.
Definition: program.hpp:450
void TransformFeedbackVarying(const GLchar *varying)
Sets the variable that will be captured during transform feedback.
Definition: program.hpp:380
TessGenPrimitiveType TessGenMode(void) const
Returns the tesselation generator output primitive type.
Definition: program.hpp:797
bool IsValid(void) const
Returns true if the program is validated, false otherwise.
Definition: program.hpp:342
ShaderProgram(ShaderType shader_type, GLSLString &&source)
Creates a program with a single shader with specified type and source.
Definition: program.hpp:1006
ShaderProgram(ShaderType shader_type, const GLSLSource &glsl_source, ObjectDesc &&object_desc)
Creates a single shader program with specified type, source and desc.
Definition: program.hpp:1058
PrimitiveType
Primitive type enumeration.
Definition: primitive_type.hpp:29
bool TessGenPointMode(void) const
Returns true if point mode is enabled in tesslation eval. shader.
Definition: program.hpp:821
Class storing source code in GLSL.
Definition: glsl_source.hpp:22
Generic OpenGL object wrapper.
static void Bind(ProgramName program)
Binds (uses) the specified program.
Definition: program.hpp:117
OpenGL primitive type-related declarations.
ShaderProgram(ShaderType shader_type, GLSLStrings &&source)
Creates a program with a single shader with specified type and source.
Definition: program.hpp:1027
Implements operations applicable to named (non-zero) objects.
Definition: wrap_tpl.hpp:45
A standalone program with a single shader of a specified type from GLSL source.
Definition: program.hpp:984
GLint GeometryShaderInvocations(void) const
Returns the number of invocations of geometry shader per primitive.
Definition: program.hpp:743
PrimitiveType GeometryOutputType(void) const
Returns the geometry shader output primitive type.
Definition: program.hpp:770
GLuint GetGLName(ObjectName< ObjTag > named)
Returns the GLuint OpenGL name assigned to named object.
Definition: name.hpp:38
FaceOrientation
Face orientation enumeration.
Definition: face_mode.hpp:62
Range< ActiveVariableInfo > ActiveSubroutineUniformRange
The type of the range for traversing active subroutine uniforms.
Definition: program.hpp:452
OpenGL face type-related enumeration.
ObjectZero< ObjZeroOps< tag::DirectState, tag::Program > > NoProgram
Class that can be used to unbind the currently active program.
Definition: program.hpp:861
ProgramInterface
Program interface enumeration.
Definition: program_interface.hpp:33
QuickProgram(ObjectDesc &&object_desc, bool separable, const Sequence< ShaderName > &shaders)
Attaches shaders, makes separable, links and uses the program.
Definition: program.hpp:1116
Class for passing a set of strings as a Source to a Shader.
Definition: glsl_string.hpp:94
Sequence of Object names.
OpenGL program resource wrapper.
String const reference wrapper template.
Definition: ref_tpl.hpp:72
TessGenPrimitiveType
Tesselation generation stage primitive type.
Definition: primitive_type.hpp:45
void Bind(void) const
Binds (uses) this program object.
Definition: program.hpp:151
Implements operations applicable to any object including object 0 (zero)
Definition: fwd.hpp:157
Data type-related declarations.
Exception class for GL program-variable-related errors.
Definition: prog_var.hpp:22
Type for the vertex attribute slot (implementation-dependent limited) number.
Definition: vertex_attrib_slot.hpp:27
Unspecified InterfaceContext
Helper class for efficient iteration of Program interface items.
Definition: program.hpp:442
::std::basic_string< GLchar > String
String class.
Definition: def.hpp:36
Range< ActiveVariableInfo > TransformFeedbackVaryingRange
The type of the range for traversing transform feedback varyings.
Definition: program.hpp:454
ObjectOps< tag::DirectState, tag::Program > ProgramOps
Program operations with direct state access.
Definition: program.hpp:854
Exception class for general OpenGL errors.
Definition: basic.hpp:43
Exception class for GL object-related errors.
Definition: object.hpp:24
Object< ProgramOps > Program
An oglplus_object encapsulating the program object functionality.
Definition: program.hpp:867
TransformFeedbackMode TransformFeedbackBufferMode(void) const
Returns the transform feedback buffer mode.
Definition: program.hpp:714
GLint GeometryVerticesOut(void) const
Returns the number of vertices that the geometry shader will output.
Definition: program.hpp:728
ShaderProgram(ShaderType shader_type, GLSLStrings &&source, ObjectDesc &&object_desc)
Creates a program with a single shader with specified type and source.
Definition: program.hpp:1037
void BindLocation(VertexAttribSlot vertex_attrib_slot, StrCRef identifier)
Binds the location of a SL variable to the vertex_attrib.
Definition: program.hpp:832
Helper class storing source code in GLSL.
TessGenPrimitiveSpacing TessGenSpacing(void) const
Returns the tesselation generator primitive spacing mode.
Definition: program.hpp:809
QuickProgram(ObjectDesc &&object_desc, const Sequence< ShaderName > &shaders)
Attaches shaders, links, uses and describes the program.
Definition: program.hpp:1089
TransformFeedbackMode
The mode used to capture the varying variables in TF.
Definition: transform_feedback_mode.hpp:25
Unspecified internal type.
Definition: doc.hpp:364
Class wrapping program functions (with direct state access)
Definition: program.hpp:176
Implements operations applicable to any object and any operation kind.
Definition: fwd.hpp:151
SLDataType
OpenGL Shading Language data type enumeration.
Definition: data_type.hpp:123
QuickProgram(bool separable, const Sequence< ShaderName > &shaders)
Attaches shaders, makes separable, links and uses the program.
Definition: program.hpp:1104
bool IsLinked(void) const
Returns true if the program is already linked, false otherwise.
Definition: program.hpp:236
Declaration of OGLplus program-variable-related error.
Class for passing a single string as a Source to a Shader.
Definition: glsl_string.hpp:31
FaceOrientation TessGenVertexOrder(void) const
Returns the vertex order in tesselation evaluation shader.
Definition: program.hpp:785
PrimitiveType GeometryInputType(void) const
Returns the geometry shader input primitive type.
Definition: program.hpp:758
ShaderProgram(ShaderType shader_type, const GLSLSource &glsl_source)
Creates a program with a single shader with specified type and source.
Definition: program.hpp:1048
Range< Managed< Shader > > ShaderRange
The type of the range for traversing program's shaders.
Definition: program.hpp:456
Range< ProgramResource > ActiveResourceRange
The type of the range for traversing program resource information.
Definition: program.hpp:445