OGLplus (0.52.0) a C++ wrapper for OpenGL

object.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_ERROR_OBJECT_1107121317_HPP
14 #define OGLPLUS_ERROR_OBJECT_1107121317_HPP
15 
16 #include <oglplus/error/basic.hpp>
17 #include <oglplus/object/tags.hpp>
18 #include <oglplus/object/type.hpp>
19 #include <oglplus/object/name.hpp>
20 
21 namespace oglplus {
22 
25  : public Error
26 {
27 private:
28 #if !OGLPLUS_ERROR_NO_OBJECT_TYPE
29  GLenum _obj_type;
30 #endif
31 #if !OGLPLUS_ERROR_NO_BIND_TARGET
32  GLenum _bind_tgt;
33 #endif
34 #if !OGLPLUS_ERROR_NO_TARGET_NAME
35  const char* _tgt_name;
36 #endif
37  int _obj_typeid;
38  GLuint _obj_name;
39 public:
40  ObjectError(const char* message);
41 
43  {
44 #if !OGLPLUS_ERROR_NO_OBJECT_TYPE
45  _obj_type = GLenum(obj_type);
46 #endif
47  (void)obj_type;
48  return *this;
49  }
50 
52  GLenum ObjectType(void) const;
53 
55  const char* ObjectTypeName(void) const;
56 
57  template <typename BindTarget_>
58  ObjectError& BindTarget(BindTarget_ bind_tgt)
59  {
60 #if !OGLPLUS_ERROR_NO_BIND_TARGET
61  _bind_tgt = GLenum(bind_tgt);
62 #endif
63 #if !OGLPLUS_ERROR_NO_TARGET_NAME
64  _tgt_name = EnumValueName(bind_tgt).c_str();
65 #endif
66  (void)bind_tgt;
67  return *this;
68  }
69 
71  GLenum BindTarget(void) const;
72 
74  const char* TargetName(void) const;
75 
76  template <typename ObjTag>
78  {
79 #if !OGLPLUS_ERROR_NO_OBJECT_TYPE
80  _obj_type = GLenum(ObjTypeOps<ObjTag>::ObjectType());
81 #endif
82  _obj_typeid = ObjTag::value;
83  _obj_name = GetGLName(object);
84  return *this;
85  }
86 
88  GLint ObjectName(void) const;
89 
91  const String& ObjectDesc(void) const;
92 
93  template <typename BindTarget_>
94  ObjectError& ObjectBinding(BindTarget_ bind_tgt)
95  {
96  typedef typename ObjectTargetTag<BindTarget_>::Type Tag;
97  Object(ObjBindingOps<Tag>::Binding(bind_tgt));
98  return BindTarget(bind_tgt);
99  }
100 
101  template <typename BindTarget_>
102  ObjectError& ObjectBinding(BindTarget_ bind_tgt, GLuint index)
103  {
104  typedef typename ObjectTargetTag<BindTarget_>::Type Tag;
105  Object(ObjBindingOps<Tag>::Binding(bind_tgt, index));
106  return BindTarget(bind_tgt);
107  }
108 };
109 
110 class ObjectPairError
111  : public ObjectError
112 {
113 private:
114 #if !OGLPLUS_ERROR_NO_OBJECT_TYPE
115  GLenum _sub_type;
116 #endif
117  int _sub_typeid;
118  GLuint _sub_name;
119 public:
120  ObjectPairError(const char* message);
121 
122  ObjectPairError& SubjectType(oglplus::ObjectType sub_type)
123  {
124 #if !OGLPLUS_ERROR_NO_OBJECT_TYPE
125  _sub_type = GLenum(sub_type);
126 #endif
127  (void)sub_type;
128  return *this;
129  }
130 
132  GLenum SubjectType(void) const;
133 
135  const char* SubjectTypeName(void) const;
136 
137  template <typename ObjTag>
138  ObjectPairError& Subject(oglplus::ObjectName<ObjTag> subject)
139  {
140  _sub_typeid = ObjTag::value;
141  _sub_name = GetGLName(subject);
142  return *this;
143  }
144 
146  GLint SubjectName(void) const;
147 
149  const String& SubjectDesc(void) const;
150 
151  template <typename BindTarget_>
152  ObjectPairError& SubjectBinding(BindTarget_ bind_tgt)
153  {
154  typedef typename ObjectTargetTag<BindTarget_>::Type Tag;
155  return Subject(ObjBindingOps<Tag>::Binding(bind_tgt));
156  }
157 };
158 
159 } // namespace oglplus
160 
161 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
162 #include <oglplus/error/object.ipp>
163 #endif
164 
165 #endif // include guard
const Char * c_str(void) const
Returns the null-terminated c-string.
Definition: ref_tpl.hpp:200
const String & ObjectDesc(void) const
Object textual description.
StrCRef EnumValueName(Enum enum_value)
Returns the name of the GL enumerated value for an OGLplus enum value.
GLint ObjectName(void) const
Object GL name.
const char * ObjectTypeName(void) const
Returns the class name.
ObjectType enumeration.
::std::basic_string< ALchar > String
GLuint GetGLName(ObjectName< ObjTag > named)
Returns the GLuint OpenGL name assigned to named object.
Definition: name.hpp:38
ObjectType
Enumeration of object types.
Definition: type.hpp:25
GL Object tag types.
::std::basic_string< GLchar > String
String class.
Definition: def.hpp:36
Exception class for general OpenGL errors.
Definition: basic.hpp:43
const char * TargetName(void) const
Returns the bind target name.
Exception class for GL object-related errors.
Definition: object.hpp:24
Declaration of basic OGLplus' exceptions.
GLenum ObjectType(void) const
Returns the object type.
Base class for OpenGL "named" objects.
GLenum BindTarget(void) const
Returns the bind target.
A common template for "named" objects like textures, buffers, etc.
Definition: fwd.hpp:136

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