OGLplus (0.52.0) a C++ wrapper for OpenGL

renderbuffer.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_RENDERBUFFER_1107121519_HPP
14 #define OGLPLUS_RENDERBUFFER_1107121519_HPP
15 
16 #include <oglplus/glfunc.hpp>
17 #include <oglplus/error/object.hpp>
19 #include <oglplus/pixel_data.hpp>
21 #include <oglplus/images/fwd.hpp>
22 #include <cassert>
23 
24 namespace oglplus {
25 
27 
34 template <>
35 class ObjGenDelOps<tag::Renderbuffer>
36 {
37 protected:
38  static void Gen(tag::Generate, GLsizei count, GLuint* names)
39  {
40  assert(names != nullptr);
41  OGLPLUS_GLFUNC(GenRenderbuffers)(count, names);
42  OGLPLUS_CHECK_SIMPLE(GenRenderbuffers);
43  }
44 #if GL_VERSION_4_5 || GL_ARB_direct_state_access
45  static void Gen(tag::Create, GLsizei count, GLuint* names)
46  {
47  assert(names != nullptr);
48  OGLPLUS_GLFUNC(CreateRenderbuffers)(count, names);
49  OGLPLUS_CHECK_SIMPLE(CreateRenderbuffers);
50  }
51 #endif
52 
53  static void Delete(GLsizei count, GLuint* names)
54  {
55  assert(names != nullptr);
56  OGLPLUS_GLFUNC(DeleteRenderbuffers)(count, names);
57  OGLPLUS_VERIFY_SIMPLE(DeleteRenderbuffers);
58  }
59 
60  static GLboolean IsA(GLuint name)
61  {
62  assert(name != 0);
63  GLboolean result = OGLPLUS_GLFUNC(IsRenderbuffer)(name);
64  OGLPLUS_VERIFY_SIMPLE(IsRenderbuffer);
65  return result;
66  }
67 };
68 
70 template <>
71 class ObjBindingOps<tag::Renderbuffer>
72 {
73 private:
74  static GLenum _binding_query(RenderbufferTarget target);
75 protected:
76  static GLuint _binding(RenderbufferTarget target);
77 public:
80 
82 
87  {
88  return RenderbufferName(_binding(target));
89  }
90 
92 
96  static void Bind(
97  Target target,
98  RenderbufferName renderbuffer
99  )
100  {
101  OGLPLUS_GLFUNC(BindRenderbuffer)(
102  GLenum(target),
103  GetGLName(renderbuffer)
104  );
105  OGLPLUS_VERIFY(
106  BindRenderbuffer,
107  ObjectError,
108  Object(renderbuffer).
109  BindTarget(target)
110  );
111  }
112 };
113 
115 
118 template <>
120  : public RenderbufferName
121  , public ObjBindingOps<tag::Renderbuffer>
122 {
123 protected:
124  ObjCommonOps(void){ }
125 public:
127 
129 
133  void Bind(Target target = Target::Renderbuffer) const
134  {
135  Bind(target, *this);
136  }
137 };
138 
140 
142 template <>
143 class ObjectOps<tag::ExplicitSel, tag::Renderbuffer>
144  : public ObjZeroOps<tag::ExplicitSel, tag::Renderbuffer>
145 {
146 protected:
147  ObjectOps(void){ }
148 public:
149  static GLint GetIntParam(Target target, GLenum query);
150 
152 
156  static void Storage(
157  Target target,
158  PixelDataInternalFormat internalformat,
159  GLsizei width,
160  GLsizei height
161  )
162  {
163  OGLPLUS_GLFUNC(RenderbufferStorage)(
164  GLenum(target),
165  GLenum(internalformat),
166  width,
167  height
168  );
169  OGLPLUS_CHECK(
170  RenderbufferStorage,
171  ObjectError,
172  ObjectBinding(target).
173  EnumParam(internalformat)
174  );
175  }
176 
178 
182  static void Storage(Target target, const images::ImageSpec& image_spec);
183 
185 
189  static void StorageMultisample(
190  Target target,
191  GLsizei samples,
192  PixelDataInternalFormat internalformat,
193  GLsizei width,
194  GLsizei height
195  )
196  {
197  OGLPLUS_GLFUNC(RenderbufferStorageMultisample)(
198  GLenum(target),
199  samples,
200  GLenum(internalformat),
201  width,
202  height
203  );
204  OGLPLUS_CHECK(
205  RenderbufferStorageMultisample,
206  ObjectError,
207  ObjectBinding(target).
208  EnumParam(internalformat)
209  );
210  }
211 
212 
214 
221  static GLsizei Width(Target target)
222  {
223  return GLsizei(GetIntParam(target, GL_RENDERBUFFER_WIDTH));
224  }
225 
227 
234  static GLsizei Height(Target target)
235  {
236  return GLsizei(GetIntParam(target, GL_RENDERBUFFER_HEIGHT));
237  }
238 
240 
249  static GLsizei RedSize(Target target)
250  {
251  return GLsizei(GetIntParam(target, GL_RENDERBUFFER_RED_SIZE));
252  }
253 
255 
266  static GLsizei GreenSize(Target target)
267  {
268  return GLsizei(GetIntParam(target, GL_RENDERBUFFER_GREEN_SIZE));
269  }
270 
272 
283  static GLsizei BlueSize(Target target)
284  {
285  return GLsizei(GetIntParam(target, GL_RENDERBUFFER_BLUE_SIZE));
286  }
287 
289 
300  static GLsizei AlphaSize(Target target)
301  {
302  return GLsizei(GetIntParam(target, GL_RENDERBUFFER_ALPHA_SIZE));
303  }
304 
306 
317  static GLsizei DepthSize(Target target)
318  {
319  return GLsizei(GetIntParam(target, GL_RENDERBUFFER_DEPTH_SIZE));
320  }
321 
323 
334  static GLsizei StencilSize(Target target)
335  {
336  return GLsizei(GetIntParam(target,GL_RENDERBUFFER_STENCIL_SIZE));
337  }
338 
340 
345  static GLsizei Samples(Target target)
346  {
347  return GLsizei(GetIntParam(target,GL_RENDERBUFFER_SAMPLES));
348  }
349 
351 
357  {
359  GetIntParam(target, GL_RENDERBUFFER_INTERNAL_FORMAT)
360  );
361  }
362 };
363 
365 typedef ObjectOps<tag::ExplicitSel, tag::Renderbuffer>
367 
368 // syntax-sugar operators
369 
370 // Bind
371 inline RenderbufferTarget operator << (
372  const RenderbufferOps& rbo,
373  RenderbufferTarget target
374 )
375 {
376  rbo.Bind(target);
377  return target;
378 }
379 
380 // Storage
381 inline RenderbufferTarget operator << (
382  RenderbufferTarget target,
383  const images::ImageSpec& image_spec
384 )
385 {
386  RenderbufferOps::Storage(target, image_spec);
387  return target;
388 }
389 
391 
394 typedef ObjectZero<ObjZeroOps<tag::ExplicitSel, tag::Renderbuffer>>
396 
398 
401 typedef Object<RenderbufferOps> Renderbuffer;
402 
403 } // namespace oglplus
404 
405 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
406 #include <oglplus/renderbuffer.ipp>
407 #endif // OGLPLUS_LINK_LIBRARY
408 
409 #endif // include guard
RenderbufferTarget Target
Renderbuffer bind targets.
Definition: renderbuffer.hpp:79
static GLsizei AlphaSize(Target target)
Returns the size in bits of the renderbuffer's alpha component.
Definition: renderbuffer.hpp:300
static void Bind(Target target, RenderbufferName renderbuffer)
Binds the specified renderbuffer to the specified target.
Definition: renderbuffer.hpp:96
PixelDataInternalFormat
OpenGL pixel data internal format enumeration.
Definition: pixel_data.hpp:79
Renderbuffer bind target enumerations.
Declaration of OGLplus object-related error.
Generic OpenGL object wrapper.
static GLsizei StencilSize(Target target)
Returns the size in bits of the renderbuffer's stencil component.
Definition: renderbuffer.hpp:334
Forward declarations of Image-related classes.
Implements operations applicable to named (non-zero) objects.
Definition: wrap_tpl.hpp:45
GLuint GetGLName(ObjectName< ObjTag > named)
Returns the GLuint OpenGL name assigned to named object.
Definition: name.hpp:38
RenderbufferTarget
Renderbuffer bind target.
Definition: renderbuffer_target.hpp:24
static GLsizei RedSize(Target target)
Returns the size in bits of the renderbuffer's red component.
Definition: renderbuffer.hpp:249
Helper macro for optional checking of availability of GL function.
Implements operations applicable to any object including object 0 (zero)
Definition: fwd.hpp:157
static PixelDataInternalFormat InternalFormat(Target target)
Returns the internal format of the renderbuffer.
Definition: renderbuffer.hpp:356
Pixel data-related declarations.
static RenderbufferName Binding(Target target)
Returns the current Renderbuffer bound to specified target.
Definition: renderbuffer.hpp:86
static GLsizei DepthSize(Target target)
Returns the size in bits of the renderbuffer's depth component.
Definition: renderbuffer.hpp:317
static GLsizei GreenSize(Target target)
Returns the size in bits of the renderbuffer's green component.
Definition: renderbuffer.hpp:266
RENDERBUFFER: The default target.
Exception class for GL object-related errors.
Definition: object.hpp:24
static void Storage(Target target, PixelDataInternalFormat internalformat, GLsizei width, GLsizei height)
Set the renderbuffer storage parameters for the rbo bound to target.
Definition: renderbuffer.hpp:156
static GLsizei Width(Target target)
Returns the width of the renderbuffer as it was specified by Storage*.
Definition: renderbuffer.hpp:221
static GLsizei Samples(Target target)
Returns the number of samples of the renderbuffer.
Definition: renderbuffer.hpp:345
ObjectOps< tag::ExplicitSel, tag::Renderbuffer > RenderbufferOps
Renderbuffer operations with explicit selector.
Definition: renderbuffer.hpp:366
void Bind(Target target=Target::Renderbuffer) const
Binds this renderbuffer to the specified target.
Definition: renderbuffer.hpp:133
Implements operations applicable to any object and any operation kind.
Definition: fwd.hpp:151
static void StorageMultisample(Target target, GLsizei samples, PixelDataInternalFormat internalformat, GLsizei width, GLsizei height)
Set the renderbuffer multisample storage parameters.
Definition: renderbuffer.hpp:189
ObjectZero< ObjZeroOps< tag::ExplicitSel, tag::Renderbuffer > > NoRenderbuffer
Class that can be used to unbind the currently bound renderbuffer.
Definition: renderbuffer.hpp:395
Class wrapping renderbuffer functions with explicit target selector.
Definition: renderbuffer.hpp:143
static GLsizei Height(Target target)
Returns the height of the renderbuffer as it was specified by Storage*.
Definition: renderbuffer.hpp:234
static GLsizei BlueSize(Target target)
Returns the size in bits of the renderbuffer's blue component.
Definition: renderbuffer.hpp:283
A common template for "named" objects like textures, buffers, etc.
Definition: fwd.hpp:136
Object< RenderbufferOps > Renderbuffer
An oglplus_object encapsulating the renderbuffer object functionality.
Definition: renderbuffer.hpp:401

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