13 #ifndef OGLPLUS_SHADER_1107121519_HPP
14 #define OGLPLUS_SHADER_1107121519_HPP
42 static void Gen(tag::Create, GLsizei count, GLuint* names, GLenum type)
44 assert(names !=
nullptr);
45 for(GLsizei i=0; i<count; ++i)
47 names[i] = OGLPLUS_GLFUNC(CreateShader)(type);
48 OGLPLUS_CHECK_SIMPLE(CreateShader);
54 void Gen(tag::Create create, GLsizei count, GLuint* names)
const
56 Gen(create, count, names, _type);
59 static void Delete(GLsizei count, GLuint* names)
61 assert(names !=
nullptr);
62 for(GLsizei i=0; i<count; ++i)
64 OGLPLUS_GLFUNC(DeleteShader)(names[i]);
65 OGLPLUS_VERIFY_SIMPLE(DeleteShader);
69 static GLboolean IsA(GLuint name)
72 GLboolean result = OGLPLUS_GLFUNC(IsShader)(name);
73 OGLPLUS_VERIFY_SIMPLE(IsShader);
81 typedef tag::Create Type;
94 #if OGLPLUS_DOCUMENTATION_ONLY || \
95 GL_ES_VERSION_3_0 || \
97 GL_ARB_ES2_compatibility
108 GLint* precision_log_2
111 OGLPLUS_GLFUNC(GetShaderPrecisionFormat)(
113 GLenum(precision_type),
117 OGLPLUS_VERIFY_SIMPLE(GetShaderPrecisionFormat);
148 OGLPLUS_GLFUNC(GetShaderiv)(
168 const GLchar*
const * srcs,
173 OGLPLUS_GLFUNC(ShaderSource)(
176 const_cast<const GLchar**
>(srcs),
187 template <
typename Src>
190 return Source(src.Count(), src.Parts(), src.Lengths());
200 return SourceTpl(source);
210 return SourceTpl(source);
220 return SourceTpl(glsl_source);
235 OGLPLUS_GLFUNC(GetShaderiv)(_name, GL_COMPILE_STATUS, &status);
242 return status == GL_TRUE;
254 String GetInfoLog(
void)
const;
268 #if OGLPLUS_DOCUMENTATION_ONLY || \
269 GL_ARB_shading_language_include
283 const GLchar*
const* paths,
299 return CompileInclude(
308 return CompileInclude(
315 ObjectOps& CompileInclude(
const GLSLSource& incl)
317 return CompileInclude(
325 #if OGLPLUS_DOCUMENTATION_ONLY || \
326 GL_ES_VERSION_3_0 || \
328 GL_ARB_ES2_compatibility
337 OGLPLUS_GLFUNC(ReleaseShaderCompiler)();
338 OGLPLUS_VERIFY_SIMPLE(ReleaseShaderCompiler);
344 typedef ObjectOps<tag::DirectState, tag::Shader>
348 struct ObjectSubtype<tag::
Shader>
364 :
public Object<ShaderOps>
369 using Object<ShaderOps>::Uninitialized_;
383 : Object<
ShaderOps>(type, std::move(description))
392 this->
Source(std::move(glsl_source));
399 ObjectDesc&& description,
401 ): Object<
ShaderOps>(type, std::move(description))
403 this->
Source(std::move(glsl_source));
413 this->
Source(std::move(glsl_source));
420 ObjectDesc&& description,
422 ): Object<
ShaderOps>(type, std::move(description))
424 this->
Source(std::move(glsl_source));
434 this->
Source(glsl_source);
441 ObjectDesc&& description,
443 ): Object<
ShaderOps>(type, std::move(description))
445 this->
Source(glsl_source);
456 Object<ShaderOps>::operator = (std::move(temp));
462 struct Classify<Shader>
463 : Classify<Object<ShaderOps>>
468 :
public Array<ObjectOps<tag::DirectState, tag::Shader>>
472 : Array<ObjectOps<tag::DirectState, tag::
Shader>>(n, type)
477 template <ShaderType ShType>
491 :
Shader(ShType, std::move(description))
496 :
Shader(ShType, std::move(glsl_source))
501 ObjectDesc&& description,
503 ):
Shader(ShType, std::move(description), std::move(glsl_source))
508 :
Shader(ShType, std::move(glsl_source))
513 ObjectDesc&& description,
515 ):
Shader(ShType, std::move(description), std::move(glsl_source))
520 :
Shader(ShType, glsl_source)
525 ObjectDesc&& description,
527 ):
Shader(ShType, std::move(description), glsl_source)
543 #if OGLPLUS_DOCUMENTATION_ONLY || GL_GEOMETRY_SHADER
561 #if OGLPLUS_DOCUMENTATION_ONLY || GL_TESS_CONTROL_SHADER
571 #if OGLPLUS_DOCUMENTATION_ONLY || GL_TESS_EVALUATION_SHADER
581 #if OGLPLUS_DOCUMENTATION_ONLY || GL_COMPUTE_SHADER
593 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
594 #include <oglplus/shader.ipp>
595 #endif // OGLPLUS_LINK_LIBRARY
597 #endif // include guard
ShaderType
The type of a Shader.
Definition: shader_type.hpp:26
ObjectOps< tag::DirectState, tag::Shader > ShaderOps
Shader operations (with direct state access)
Definition: shader.hpp:345
Shader(ShaderType type, ObjectDesc &&description, GLSLStrings &&glsl_source)
Construction with type, description and source code wrapper.
Definition: shader.hpp:418
OpenGL precision type-related declarations.
Shader(ShaderType type, GLSLString &&glsl_source)
Construction with type and source code wrapper.
Definition: shader.hpp:387
Shader(ShaderType type, ObjectDesc &&description)
Construction with type specifier and textual descriptor.
Definition: shader.hpp:382
ObjectOps & Source(GLSLStrings &&source)
Set the source code of the shader.
Definition: shader.hpp:208
SpecShader(GLSLStrings &&glsl_source)
Construction with a source code wrapper.
Definition: shader.hpp:507
SpecShader< ShaderType::Geometry > GeometryShader
Geometry shader wrapper.
Definition: shader.hpp:550
SpecShader< ShaderType::Vertex > VertexShader
Vertex shader wrapper.
Definition: shader.hpp:541
Shader(ShaderType type, ObjectDesc &&description, GLSLString &&glsl_source)
Construction with type, description and source code wrapper.
Definition: shader.hpp:397
Class storing source code in GLSL.
Definition: glsl_source.hpp:22
SpecShader< ShaderType::Fragment > FragmentShader
Fragment shader wrapper.
Definition: shader.hpp:559
Generic OpenGL object wrapper.
Shader(ShaderType type, GLSLStrings &&glsl_source)
Construction with type and source code wrapper.
Definition: shader.hpp:408
SpecShader< ShaderType::Compute > ComputeShader
Compute shader wrapper.
Definition: shader.hpp:588
Implements operations applicable to named (non-zero) objects.
Definition: wrap_tpl.hpp:45
SpecShader(GLSLString &&glsl_source)
Construction with a source code wrapper.
Definition: shader.hpp:495
Shader(ShaderType type, const GLSLSource &glsl_source)
Construction with type and source code wrapper.
Definition: shader.hpp:429
SpecShader< ShaderType::TessControl > TessControlShader
Tesselation control shader wrapper.
Definition: shader.hpp:568
SpecShader(ObjectDesc &&description)
Construction with a textual descriptor.
Definition: shader.hpp:490
ShaderType Type
The type of a Shader.
Definition: shader.hpp:136
Class for passing a set of strings as a Source to a Shader.
Definition: glsl_string.hpp:94
PrecisionType
Precision type enumeration.
Definition: precision_type.hpp:27
bool IsCompiled(void) const
Returns true if the shader is already compiled, returns false otherwise.
Definition: shader.hpp:231
Helper macro for optional checking of availability of GL function.
SpecShader(ObjectDesc &&description, const GLSLSource &glsl_source)
Construction with description and source code wrapper.
Definition: shader.hpp:524
ObjectOps & CompileInclude(GLSLString &&incl)
Compiles the shader using the specified include paths.
Definition: shader.hpp:297
ObjectOps & Source(GLSLString &&source)
Set the source code of the shader.
Definition: shader.hpp:198
ShaderType Type(void) const
Get the type of the shader.
Definition: shader.hpp:145
Shader(Uninitialized_ u)
Uninitialized construction.
Definition: shader.hpp:372
::std::basic_string< GLchar > String
String class.
Definition: def.hpp:36
ObjectOps & Source(const GLsizei count, const GLchar *const *srcs, const GLint *lens)
Set the source code of the shader.
Definition: shader.hpp:166
An object encasulating the shader object functionality.
Definition: shader.hpp:363
Object< SourceOps > Source
SpecShader(ObjectDesc &&description, GLSLStrings &&glsl_source)
Construction with description and source code wrapper.
Definition: shader.hpp:512
ObjectOps & Source(const GLSLSource &glsl_source)
Set the source code of the shader.
Definition: shader.hpp:218
SpecShader< ShaderType::TessEvaluation > TessEvaluationShader
Tesselation evaluation shader wrapper.
Definition: shader.hpp:578
SpecShader(ObjectDesc &&description, GLSLString &&glsl_source)
Construction with description and source code wrapper.
Definition: shader.hpp:500
Exception class for GL object-related errors.
Definition: object.hpp:24
static void ReleaseCompiler(void)
Indicate that the resources associated with the compiler can be freed.
Definition: shader.hpp:335
Base template for specialized shader types.
Definition: shader.hpp:478
Helper class storing source code in GLSL.
Shader(ShaderType type)
Construction with shader type specifier.
Definition: shader.hpp:377
static void PrecisionFormat(ShaderType shader_type, PrecisionType precision_type, GLint *range_log_2, GLint *precision_log_2)
Get the shader precision format.
Definition: shader.hpp:104
Implements operations applicable to any object and any operation kind.
Definition: fwd.hpp:151
Class for passing a single string as a Source to a Shader.
Definition: glsl_string.hpp:31
SpecShader(const GLSLSource &glsl_source)
Construction with a source code wrapper.
Definition: shader.hpp:519
A common template for "named" objects like textures, buffers, etc.
Definition: fwd.hpp:136
SpecShader(void)
Default construction.
Definition: shader.hpp:485
Class wrapping shader functions (with direct state access)
Definition: shader.hpp:126
Shader(Shader &&temp)
Shaders are movable.
Definition: shader.hpp:450
Shader(ShaderType type, ObjectDesc &&description, const GLSLSource &glsl_source)
Construction with type, description and source code wrapper.
Definition: shader.hpp:439