OGLplus (0.52.0) a C++ wrapper for OpenGL

texture_handle.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_TEXTURE_HANDLE_1309262134_HPP
14 #define OGLPLUS_TEXTURE_HANDLE_1309262134_HPP
15 
16 #include <oglplus/fwd.hpp>
17 #include <oglplus/glfunc.hpp>
18 #include <oglplus/object/tags.hpp>
19 #include <oglplus/object/name.hpp>
21 #include <oglplus/pixel_data.hpp>
23 
24 namespace oglplus {
25 
26 #if OGLPLUS_DOCUMENTATION_ONLY || GL_ARB_bindless_texture
27 
30 {
31 private:
32  friend GLuint64 GetGLHandle(TextureHandle);
33  GLuint64 _handle;
34 public:
37  : _handle(OGLPLUS_GLFUNC(GetTextureHandleARB)(GetGLName(texture)))
38  {
39  OGLPLUS_CHECK_SIMPLE(GetTextureHandleARB);
40  }
41 
44  : _handle(OGLPLUS_GLFUNC(GetTextureSamplerHandleARB)(
45  GetGLName(texture),
46  GetGLName(sampler)
47  ))
48  {
49  OGLPLUS_CHECK_SIMPLE(GetTextureSamplerHandleARB);
50  }
51 
53  void MakeResident(void)
54  {
55  OGLPLUS_GLFUNC(MakeTextureHandleResidentARB)(_handle);
56  OGLPLUS_CHECK_SIMPLE(MakeTextureHandleResidentARB);
57  }
58 
60  void MakeNonResident(void)
61  {
62  OGLPLUS_GLFUNC(MakeTextureHandleNonResidentARB)(_handle);
63  OGLPLUS_CHECK_SIMPLE(MakeTextureHandleNonResidentARB);
64  }
65 
67  bool IsResident(void) const
68  {
69  GLboolean result =
70  OGLPLUS_GLFUNC(IsTextureHandleResidentARB)(_handle);
71  OGLPLUS_VERIFY_SIMPLE(IsTextureHandleResidentARB);
72  return result == GL_TRUE;
73  }
74 };
75 
77 inline GLuint64 GetGLHandle(TextureHandle th)
78 {
79  return th._handle;
80 }
81 
82 template <>
83 struct AdjustProgVar<TextureHandle>
84 {
85  typedef GLuint64 BaseType;
86  typedef TextureHandle ValueType;
87 
88  inline static BaseType Adjust(ValueType value)
89  {
90  return GetGLHandle(value);
91  }
92 };
93 
96 {
97 private:
98  friend GLuint64 GetGLHandle(ImageHandle);
99  GLuint64 _handle;
100 public:
103  TextureName texture,
104  GLint level,
105  bool layered,
106  GLint layer,
107  ImageUnitFormat format
108  ): _handle(OGLPLUS_GLFUNC(GetImageHandleARB)(
109  GetGLName(texture),
110  level,
111  layered?GL_TRUE:GL_FALSE,
112  layer,
113  GLenum(format)
114  ))
115  {
116  OGLPLUS_CHECK_SIMPLE(GetImageHandleARB);
117  }
118 
121  {
122  OGLPLUS_GLFUNC(MakeImageHandleResidentARB)(
123  _handle,
124  GLenum(access)
125  );
126  OGLPLUS_CHECK_SIMPLE(MakeImageHandleResidentARB);
127  }
128 
130  void MakeNonResident(void)
131  {
132  OGLPLUS_GLFUNC(MakeImageHandleNonResidentARB)(_handle);
133  OGLPLUS_CHECK_SIMPLE(MakeImageHandleNonResidentARB);
134  }
135 
137  bool IsResident(void) const
138  {
139  GLboolean result =
140  OGLPLUS_GLFUNC(IsImageHandleResidentARB)(_handle);
141  OGLPLUS_VERIFY_SIMPLE(IsImageHandleResidentARB);
142  return result == GL_TRUE;
143  }
144 };
145 
147 inline GLuint64 GetGLHandle(ImageHandle ih)
148 {
149  return ih._handle;
150 }
151 
152 template <>
153 struct AdjustProgVar<ImageHandle>
154 {
155  typedef GLuint64 BaseType;
156  typedef ImageHandle ValueType;
157 
158  inline static BaseType Adjust(ValueType value)
159  {
160  return GetGLHandle(value);
161  }
162 };
163 
164 #endif // GL_ARB_bindless_texture
165 
166 } // namespace oglplus
167 
168 #endif // include guard
void MakeResident(AccessSpecifier access)
Make the image resident.
Definition: texture_handle.hpp:120
void MakeResident(void)
Make the texture resident.
Definition: texture_handle.hpp:53
Access type specifier enumeration.
Forward declarations.
TextureHandle(TextureName texture, SamplerName sampler)
Construction from a texture and a sampler.
Definition: texture_handle.hpp:43
bool IsResident(void) const
Make the image non-resident.
Definition: texture_handle.hpp:137
GLuint GetGLName(ObjectName< ObjTag > named)
Returns the GLuint OpenGL name assigned to named object.
Definition: name.hpp:38
AccessSpecifier
Enumeration of access type specifiers.
Definition: access_specifier.hpp:27
friend GLuint64 GetGLHandle(TextureHandle)
Returns the GL handle value from TextureHandle.
Definition: texture_handle.hpp:77
GL Object tag types.
bool IsResident(void) const
Make the texture non-resident.
Definition: texture_handle.hpp:67
Helper macro for optional checking of availability of GL function.
Program variable type operations.
void MakeNonResident(void)
Make the image non-resident.
Definition: texture_handle.hpp:130
Pixel data-related declarations.
ImageHandle(TextureName texture, GLint level, bool layered, GLint layer, ImageUnitFormat format)
Construction from a texture and additional parameters.
Definition: texture_handle.hpp:102
void MakeNonResident(void)
Make the texture non-resident.
Definition: texture_handle.hpp:60
A handle for a bindless texture.
Definition: texture_handle.hpp:29
ImageUnitFormat
OpenGL image unit format enumeration.
Definition: pixel_data.hpp:104
Base class for OpenGL "named" objects.
TextureHandle(TextureName texture)
Construction from a texture.
Definition: texture_handle.hpp:36
GLuint64 GetGLHandle(TextureHandle th)
Returns the GL handle value from TextureHandle.
Definition: texture_handle.hpp:77
A common template for "named" objects like textures, buffers, etc.
Definition: fwd.hpp:136
A handle for a bindless texture image.
Definition: texture_handle.hpp:95
friend GLuint64 GetGLHandle(ImageHandle)
Returns the GL handle value from ImageHandle.
Definition: texture_handle.hpp:147

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