OGLplus (0.52.0) a C++ wrapper for OpenGL

vertex_attrib.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_DSA_VERTEX_ATTRIB_1107121519_HPP
14 #define OGLPLUS_DSA_VERTEX_ATTRIB_1107121519_HPP
15 
17 #include <oglplus/error/object.hpp>
18 
19 namespace oglplus {
20 
21 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_5 || GL_ARB_direct_state_access
22 
23 class DSAVertexArrayAttrib
24  : public ProgVarCommonOps<tag::VertexAttrib>
25 {
26 private:
27  GLuint _vao;
28 public:
30 
34  DSAVertexArrayAttrib(
35  VertexArrayName vao,
36  VertexAttribSlot location
37  ): ProgVarCommonOps<tag::VertexAttrib>(VertexAttribLoc(GLint(location)))
38  , _vao(GetGLName(vao))
39  { }
40 
42 
46  DSAVertexArrayAttrib(
47  VertexArrayName vao,
48  ProgramName program,
49  StrCRef identifier
50  ): ProgVarCommonOps<tag::VertexAttrib>(VertexAttribLoc(program, identifier))
51  , _vao(GetGLName(vao))
52  { }
53 
55 
59  const DSAVertexArrayAttrib& Enable(void) const
60  {
61  OGLPLUS_GLFUNC(EnableVertexArrayAttrib)(
62  _vao,
63  GLuint(_location)
64  );
65  OGLPLUS_CHECK_SIMPLE(EnableVertexArrayAttrib);
66  return *this;
67  }
68 
70 
74  const DSAVertexArrayAttrib& Disable(void) const
75  {
76  OGLPLUS_GLFUNC(DisableVertexArrayAttrib)(
77  _vao,
78  GLuint(_location)
79  );
80  OGLPLUS_CHECK_SIMPLE(DisableVertexArrayAttrib);
81  return *this;
82  }
83 
85  const DSAVertexArrayAttrib& VertexBuffer(
86  BufferName buffer,
87  GLintptr offset,
88  GLsizei stride
89  )
90  {
91  OGLPLUS_GLFUNC(VertexArrayVertexBuffer)(
92  _vao,
93  GLuint(_location),
94  GetGLName(buffer),
95  offset,
96  stride
97  );
98  OGLPLUS_CHECK(
99  VertexArrayVertexBuffer,
100  ObjectPairError,
101  Subject(buffer).
102  Object(VertexArrayName(_vao))
103  );
104  return *this;
105  }
106 
108 
112  const DSAVertexArrayAttrib& Format(
113  GLint values_per_vertex,
114  DataType data_type,
115  bool normalized,
116  GLuint relative_offset
117  ) const
118  {
119  OGLPLUS_GLFUNC(VertexArrayAttribFormat)(
120  _vao,
121  GLuint(_location),
122  values_per_vertex,
123  GLenum(data_type),
124  normalized ? GL_TRUE : GL_FALSE,
125  relative_offset
126  );
127  OGLPLUS_CHECK(
128  VertexArrayAttribFormat,
129  ObjectError,
130  Object(VertexArrayName(_vao)).
131  EnumParam(data_type)
132  );
133  return *this;
134  }
135 
137 
141  const DSAVertexArrayAttrib& IFormat(
142  GLint values_per_vertex,
143  DataType data_type,
144  GLuint relative_offset
145  ) const
146  {
147  OGLPLUS_GLFUNC(VertexArrayAttribIFormat)(
148  _vao,
149  GLuint(_location),
150  values_per_vertex,
151  GLenum(data_type),
152  relative_offset
153  );
154  OGLPLUS_CHECK(
155  VertexArrayAttribIFormat,
156  ObjectError,
157  Object(VertexArrayName(_vao)).
158  EnumParam(data_type)
159  );
160  return *this;
161  }
162 
164 
168  const DSAVertexArrayAttrib& LFormat(
169  GLint values_per_vertex,
170  DataType data_type,
171  GLuint relative_offset
172  ) const
173  {
174  OGLPLUS_GLFUNC(VertexArrayAttribLFormat)(
175  _vao,
176  GLuint(_location),
177  values_per_vertex,
178  GLenum(data_type),
179  relative_offset
180  );
181  OGLPLUS_CHECK(
182  VertexArrayAttribLFormat,
183  ObjectError,
184  Object(VertexArrayName(_vao)).
185  EnumParam(data_type)
186  );
187  return *this;
188  }
189 };
190 
191 #endif // GL_ARB_direct_state_access
192 
193 } // namespace oglplus
194 
195 #endif // include guard
DataType
OpenGL data type enumeration.
Definition: data_type.hpp:34
Declaration of OGLplus object-related error.
GLuint GetGLName(ObjectName< ObjTag > named)
Returns the GLuint OpenGL name assigned to named object.
Definition: name.hpp:38
String const reference wrapper template.
Definition: ref_tpl.hpp:72
VertexAttrib wrappers.
PixelDataFormat Format
Alias for PixelDataFormat.
Definition: pixel_data.hpp:66

Copyright © 2010-2014 Matúš Chochlík, University of Žilina, Žilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Mon Sep 22 2014 by Doxygen (version 1.8.6).