13 #ifndef OGLPLUS_VERTEX_ATTRIB_1107121519_HPP 
   14 #define OGLPLUS_VERTEX_ATTRIB_1107121519_HPP 
   25 #include <oglplus/prog_var/varpara_fns.hpp> 
   26 #include <oglplus/prog_var/set_ops.hpp> 
   29 #include <type_traits> 
   34 class ProgVarLocOps<tag::VertexAttrib>
 
   37     static const char* MsgGettingInactive(
void);
 
   39     static const char* MsgUsingInactive(
void);
 
   49     static void BindLocation(
 
   51         VertexAttribSlot location,
 
   55         OGLPLUS_GLFUNC(BindAttribLocation)(
 
   64             Identifier(identifier).
 
   65             Index(GLuint(location))
 
   82     static GLint GetLocation(
 
   88         GLint result = OGLPLUS_GLFUNC(GetAttribLocation)(
 
   96             Identifier(identifier)
 
   98         OGLPLUS_HANDLE_ERROR_IF(
 
   99             active_only && (result < 0),
 
  100             GL_INVALID_OPERATION,
 
  101             MsgGettingInactive(),
 
  104             Identifier(identifier)
 
  109     static VertexAttribSlot GetLocation(
 
  114         return VertexAttribSlot(GetLocation(program, identifier, 
true));
 
  122     static bool QueryActiveLocation(
 
  125         VertexAttribSlot& location
 
  128         GLint result = GetLocation(program, identifier, 
false);
 
  129         if(result < 0) 
return false;
 
  130         location = VertexAttribSlot(result);
 
  180     static bool QueryCommonLocation(
 
  181         const Sequence<ProgramName>& programs,
 
  183         VertexAttribSlot& location
 
  227     static VertexAttribSlot GetCommonLocation(
 
  228         const Sequence<ProgramName>& programs,
 
  234 class ProgVarSetters<tag::ImplicitSel, tag::VertexAttrib, tag::NativeTypes>
 
  237     OGLPLUS_ERROR_CONTEXT(VertexAttrib, VertexAttrib)
 
  239     OGLPLUS_AUX_VARPARA_FNS(VertexAttrib, f, t, GLfloat)
 
  240 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_3_0 
  241     OGLPLUS_AUX_VARPARA_FNS(VertexAttrib, d, t, GLdouble)
 
  242     OGLPLUS_AUX_VARPARA_FNS(VertexAttrib, s, t, GLshort)
 
  244     OGLPLUS_AUX_VARPARA_FNS(VertexAttribI, i, t, GLint)
 
  245     OGLPLUS_AUX_VARPARA_FNS(VertexAttribI, ui, t, GLuint)
 
  248     OGLPLUS_AUX_VARPARA_FNS(VertexAttrib, fv, v, GLfloat)
 
  249 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_3_0 
  250     OGLPLUS_AUX_VARPARA_FNS(VertexAttrib, dv, v, GLdouble)
 
  251     OGLPLUS_AUX_VARPARA_FNS(VertexAttrib, sv, v, GLshort)
 
  253     OGLPLUS_AUX_VARPARA_FNS(VertexAttribI, i, v, GLint)
 
  254     OGLPLUS_AUX_VARPARA_FNS(VertexAttribI, ui, v, GLuint)
 
  259 class ProgVarCommonOps<tag::VertexAttrib>
 
  260  : 
public ProgVarLoc<tag::VertexAttrib>
 
  263     ProgVarCommonOps(VertexAttribLoc valoc)
 
  268     template <
typename T>
 
  269     static GLint _get_vpv(
T*) { 
return 1; }
 
  271     template <
typename T, std::
size_t N>
 
  272     static GLint _get_vpv(Vector<T, N>*) { 
return N; }
 
  274     template <
typename T, std::
size_t Rows, std::
size_t Cols>
 
  275     static GLint _get_vpv(Matrix<T, Rows, Cols>*) { 
return Rows*Cols; }
 
  278     template <
typename T>
 
  279     static T _get_et(
T* p);
 
  281     template <
typename T, std::
size_t N>
 
  282     static T _get_et(Vector<T, N>*);
 
  284     template <
typename T, std::
size_t Rows, std::
size_t Cols>
 
  285     static T _get_et(Matrix<T, Rows, Cols>*);
 
  296 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_3_3 
  303     void Divisor(GLuint divisor)
 const 
  305         OGLPLUS_GLFUNC(VertexAttribDivisor)(
 
  309         OGLPLUS_CHECK_SIMPLE(VertexAttribDivisor);
 
  318 template <
typename OpsTag, 
typename T>
 
  319 class ProgVarGetSetOps<OpsTag, tag::VertexAttrib, T>
 
  320  : 
public ProgVarCommonOps<tag::VertexAttrib>
 
  321  , 
public ProgVarBaseSetOps<OpsTag, tag::VertexAttrib, tag::NativeTypes, T, 16>
 
  325      : ProgVarCommonOps<tag::VertexAttrib>(valoc)
 
  335         this->_do_set(_program, _location, value);
 
  339 template <
typename OpsTag, 
typename T, std::
size_t N>
 
  340 class ProgVarGetSetOps<OpsTag, tag::VertexAttrib, Vector<T, N>>
 
  341  : 
public ProgVarCommonOps<tag::VertexAttrib>
 
  342  , 
public ProgVarBaseSetOps<OpsTag, tag::VertexAttrib, tag::NativeTypes, T, 4>
 
  345     ProgVarGetSetOps(VertexAttribLoc valoc)
 
  346      : ProgVarCommonOps<tag::VertexAttrib>(valoc)
 
  349     void SetValue(
const Vector<T, N>& value)
 
  351         this->
template _do_set<N>(_program, _location, Data(value));
 
  355 template <
typename OpsTag, 
typename T, std::
size_t R, std::
size_t C>
 
  356 class ProgVarGetSetOps<OpsTag, tag::VertexAttrib, Matrix<T, R, C>>
 
  357  : 
public ProgVarCommonOps<tag::VertexAttrib>
 
  358  , 
public ProgVarBaseSetOps<OpsTag, tag::VertexAttrib, tag::NativeTypes, T, 16>
 
  361     ProgVarGetSetOps(VertexAttribLoc valoc)
 
  362      : ProgVarCommonOps<tag::VertexAttrib>(valoc)
 
  365     void SetValue(
const Matrix<T, R, C>& value)
 
  367         this->
template _do_set<R*C>(_program, _location, Data(value));
 
  382 class VertexArrayAttrib
 
  383  : public ProgVarCommonOps<tag::VertexAttrib>
 
  392      : ProgVarCommonOps<tag::VertexAttrib>(
VertexAttribLoc(GLint(location)))
 
  401      : ProgVarCommonOps<tag::VertexAttrib>(
 
  411      : ProgVarCommonOps<tag::VertexAttrib>(
 
  451     const VertexArrayAttrib& Setup(
 
  452         GLint values_per_vertex,
 
  489     const VertexArrayAttrib& Setup(
 
  490         GLint values_per_vertex,
 
  491         std::integral_constant<DataType, DataType::Float>
 
  504     const VertexArrayAttrib& Setup(
 
  505         GLint values_per_vertex,
 
  506         std::integral_constant<DataType, DataType::Double>
 
  518     template <DataType DataTypeValue>
 
  519     const VertexArrayAttrib& Setup(
 
  520         GLint values_per_vertex,
 
  521         std::integral_constant<DataType, DataTypeValue>
 
  541     template <
typename T>
 
  542     const VertexArrayAttrib& Setup(GLuint n = 1)
 const 
  544         typedef decltype(_get_et((T*)
nullptr)) elem_type;
 
  547             _get_vpv((T*)
nullptr)*n,
 
  548             typename DataTypeCT<elem_type>::type()
 
  557     const VertexArrayAttrib& Pointer(
 
  558         GLint values_per_vertex,
 
  565         OGLPLUS_GLFUNC(VertexAttribPointer)(
 
  569             normalized ? GL_TRUE : GL_FALSE,
 
  576             EnumParam(data_type).
 
  587     const VertexArrayAttrib& IPointer(
 
  588         GLuint values_per_vertex,
 
  594         OGLPLUS_GLFUNC(VertexAttribIPointer)(
 
  602             VertexAttribIPointer,
 
  604             EnumParam(data_type).
 
  611 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_2 || GL_ARB_vertex_attrib_64bit 
  617     const VertexArrayAttrib& LPointer(
 
  618         GLuint values_per_vertex,
 
  624         OGLPLUS_GLFUNC(VertexAttribLPointer)(
 
  631         OGLPLUS_CHECK(VertexAttribLPointer,
 
  633             EnumParam(data_type).
 
  639     const VertexArrayAttrib& LPointer(
 
  647         "The glVertexAttribLPointer function is " 
  648         "required but not available! Double-precision " 
  649         "vertex attribute values are not supported." 
  655 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_3 || GL_ARB_vertex_attrib_binding 
  661     const VertexArrayAttrib& 
Format(
 
  662         GLint values_per_vertex,
 
  665         GLuint relative_offset
 
  668         OGLPLUS_GLFUNC(VertexAttribFormat)(
 
  672             normalized ? GL_TRUE : GL_FALSE,
 
  678             EnumParam(data_type).
 
  689     const VertexArrayAttrib& IFormat(
 
  690         GLint values_per_vertex,
 
  692         GLuint relative_offset
 
  695         OGLPLUS_GLFUNC(VertexAttribIFormat)(
 
  704             EnumParam(data_type).
 
  715     const VertexArrayAttrib& LFormat(
 
  716         GLint values_per_vertex,
 
  718         GLuint relative_offset
 
  721         OGLPLUS_GLFUNC(VertexAttribLFormat)(
 
  730             EnumParam(data_type).
 
  742     const VertexArrayAttrib& Enable(
void)
 const 
  744         OGLPLUS_GLFUNC(EnableVertexAttribArray)(_location);
 
  746             EnableVertexArrayAttrib,
 
  758     const VertexArrayAttrib& Disable(
void)
 const 
  760         OGLPLUS_GLFUNC(DisableVertexAttribArray)(_location);
 
  762             DisableVertexArrayAttrib,
 
  776 template <std::
size_t N>
 
  777 inline VertexArrayAttrib operator | (
 
  779     const GLchar (&identifier)[N]
 
  782     return VertexArrayAttrib(program, identifier);
 
  791 inline VertexArrayAttrib operator | (
 
  801 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY) 
  802 #include <oglplus/vertex_attrib.ipp> 
  805 #endif // include guard 
const Char * c_str(void) const 
Returns the null-terminated c-string. 
Definition: ref_tpl.hpp:200
 
Program variable wrapper. 
 
Program variable location wrapper. 
 
DataType
OpenGL data type enumeration. 
Definition: data_type.hpp:34
 
void SetValue(T value)
Set the value of the vertex attribute. 
Definition: vertex_attrib.hpp:333
 
ProgVarLoc(void)
Default construction. 
Definition: location.hpp:55
 
OGLPLUS_DECLARE_PROG_VAR(Uniform, tag::ImplicitSel, tag::Uniform, tag::NoTypecheck) typedef Uniform< GLint > UniformSampler
Uniform sampler. 
 
GLuint GetGLName(ObjectName< ObjTag > named)
Returns the GLuint OpenGL name assigned to named object. 
Definition: name.hpp:38
 
Sequence of Object names. 
 
String const reference wrapper template. 
Definition: ref_tpl.hpp:72
 
Helper macro for optional checking of availability of GL function. 
 
Data type-related declarations. 
 
Type for the vertex attribute slot (implementation-dependent limited) number. 
Definition: vertex_attrib_slot.hpp:27
 
Exception class for general OpenGL errors. 
Definition: basic.hpp:43
 
Base class for OpenGL "named" objects. 
 
Declaration of OGLplus program-variable-related error. 
 
A common template for "named" objects like textures, buffers, etc. 
Definition: fwd.hpp:136
 
PixelDataFormat Format
Alias for PixelDataFormat. 
Definition: pixel_data.hpp:66