OGLplus (0.52.0) a C++ wrapper for OpenGL

vertex_array.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_VERTEX_ARRAY_1107121519_HPP
14 #define OGLPLUS_VERTEX_ARRAY_1107121519_HPP
15 
16 #include <oglplus/glfunc.hpp>
18 #include <oglplus/error/object.hpp>
19 #include <cassert>
20 
21 namespace oglplus {
22 
24 
31 template <>
32 class ObjGenDelOps<tag::VertexArray>
33 {
34 protected:
35  static void Gen(tag::Generate, GLsizei count, GLuint* names)
36  {
37  assert(names != nullptr);
38  OGLPLUS_GLFUNC(GenVertexArrays)(count, names);
39  OGLPLUS_CHECK_SIMPLE(GenVertexArrays);
40  }
41 #if GL_VERSION_4_5 || GL_ARB_direct_state_access
42  static void Gen(tag::Create, GLsizei count, GLuint* names)
43  {
44  assert(names != nullptr);
45  OGLPLUS_GLFUNC(CreateVertexArrays)(count, names);
46  OGLPLUS_CHECK_SIMPLE(CreateVertexArrays);
47  }
48 #endif
49 
50  static void Delete(GLsizei count, GLuint* names)
51  {
52  assert(names != nullptr);
53  OGLPLUS_GLFUNC(DeleteVertexArrays)(count, names);
54  OGLPLUS_VERIFY_SIMPLE(DeleteVertexArrays);
55  }
56 
57  static GLboolean IsA(GLuint name)
58  {
59  assert(name != 0);
60  GLboolean result = OGLPLUS_GLFUNC(IsVertexArray)(name);
61  OGLPLUS_VERIFY_SIMPLE(IsVertexArray);
62  return result;
63  }
64 };
65 
67 template <>
68 class ObjBindingOps<tag::VertexArray>
69 {
70 protected:
71  static GLuint _binding(void)
72  {
73  GLint name = 0;
74  OGLPLUS_GLFUNC(GetIntegerv)(GL_VERTEX_ARRAY_BINDING, &name);
75  OGLPLUS_VERIFY(
76  GetIntegerv,
78  EnumParam(GLenum(GL_VERTEX_ARRAY_BINDING))
79  );
80  return name;
81  }
82 public:
84 
88  static VertexArrayName Binding(void)
89  {
90  return VertexArrayName(_binding());
91  }
92 
94 
98  static void Bind(VertexArrayName vertex_array)
99  {
100  OGLPLUS_GLFUNC(BindVertexArray)(GetGLName(vertex_array));
101  OGLPLUS_VERIFY(
102  BindVertexArray,
103  ObjectError,
104  Object(vertex_array)
105  );
106  }
107 };
108 
110 
113 template <>
115  : public VertexArrayName
116  , public ObjBindingOps<tag::VertexArray>
117 {
118 protected:
119  ObjCommonOps(void){ }
120 public:
122 
124 
128  void Bind(void) const
129  {
130  Bind(*this);
131  }
132 };
133 
134 
136 typedef ObjectOps<tag::ImplicitSel, tag::VertexArray>
138 
140 
143 typedef ObjectZero<ObjZeroOps<tag::ImplicitSel, tag::VertexArray>>
145 
147 
150 typedef Object<VertexArrayOps> VertexArray;
151 
152 } // namespace oglplus
153 
154 #endif // include guard
ObjectOps< tag::ImplicitSel, tag::VertexArray > VertexArrayOps
VertexArray operations with implicit selector.
Definition: vertex_array.hpp:137
static VertexArrayName Binding(void)
Returns the currently bound VertexArray.
Definition: vertex_array.hpp:88
Declaration of OGLplus object-related error.
Generic OpenGL object wrapper.
void Bind(void) const
Binds this vertex array object.
Definition: vertex_array.hpp:128
static void Bind(VertexArrayName vertex_array)
Binds the specified vertex_array object.
Definition: vertex_array.hpp:98
GLuint GetGLName(ObjectName< ObjTag > named)
Returns the GLuint OpenGL name assigned to named object.
Definition: name.hpp:38
Helper macro for optional checking of availability of GL function.
ObjectZero< ObjZeroOps< tag::ImplicitSel, tag::VertexArray > > NoVertexArray
An oglplus_object encapsulating vertex array zero functionality.
Definition: vertex_array.hpp:144
Exception class for GL object-related errors.
Definition: object.hpp:24
Implements operations applicable to any object and any operation kind.
Definition: fwd.hpp:151
A common template for "named" objects like textures, buffers, etc.
Definition: fwd.hpp:136
Object< VertexArrayOps > VertexArray
An oglplus_object encapsulating vertex array object functionality.
Definition: vertex_array.hpp:150

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).