| globjects 1.0.0.000000000000 Strict OpenGL objects wrapper.

Texture.h
Go to the documentation of this file.
1
2 #pragma once
3
4 #include <glbinding/gl/types.h>
5
6 #include <vector>
7
8 #include <glm/fwd.hpp>
9
10 #include <globjects/globjects_api.h>
11 #include <globjects/Object.h>
12
13
14 namespace globjects
15 {
16
17
18 class Buffer;
19 class TextureHandle;
20 class Sampler;
21
30 class GLOBJECTS_API Texture : public Object
31 {
32 public:
33 enum class BindlessImplementation
34 {
35 DirectStateAccessARB
36 , DirectStateAccessEXT
37 , Legacy
38 };
39
40 enum class StorageImplementation
41 {
42 DirectStateAccessARB
43 , DirectStateAccessEXT
44 , Legacy
45 , Fallback
46 };
47
48 static void hintBindlessImplementation(BindlessImplementation impl);
49 static void hintStorageImplementation(StorageImplementation impl);
50
51 Texture();
52 Texture(gl::GLenum target);
53 static Texture * fromId(gl::GLuint id, gl::GLenum target);
54
55 static Texture * createDefault();
56 static Texture * createDefault(gl::GLenum target);
57
58 virtual void accept(ObjectVisitor & visitor) override;
59
60 void bind() const;
61 void unbind() const;
62 static void unbind(gl::GLenum target);
63
64 void bindActive(gl::GLenum texture) const;
65 void bindActive(unsigned int index) const;
66 void unbindActive(gl::GLenum texture) const;
67 void unbindActive(unsigned int index) const;
68
69 void setParameter(gl::GLenum name, gl::GLenum value);
70 void setParameter(gl::GLenum name, gl::GLint value);
71 void setParameter(gl::GLenum name, gl::GLfloat value);
72 void setParameter(gl::GLenum name, const glm::vec4 & value);
73
74 gl::GLint getParameter(gl::GLenum pname) const;
75 gl::GLint getLevelParameter(gl::GLint level, gl::GLenum pname) const;
76
77 void getImage(gl::GLint level, gl::GLenum format, gl::GLenum type, gl::GLvoid * image) const;
78 std::vector<unsigned char> getImage(gl::GLint level, gl::GLenum format, gl::GLenum type) const;
79
80 void getCompressedImage(gl::GLint lod, gl::GLvoid * image) const;
81 std::vector<unsigned char> getCompressedImage(gl::GLint lod = 0) const;
82
83 gl::GLenum target() const;
84
85 void image1D(gl::GLint level, gl::GLenum internalFormat, gl::GLsizei width, gl::GLint border, gl::GLenum format, gl::GLenum type, const gl::GLvoid * data);
86 void compressedImage1D(gl::GLint level, gl::GLenum internalFormat, gl::GLsizei width, gl::GLint border, gl::GLsizei imageSize, const gl::GLvoid * data);
87 void subImage1D(gl::GLint level, gl::GLint xOffset, gl::GLsizei width, gl::GLenum format, gl::GLenum type, const gl::GLvoid * data);
88
89 void image2D(gl::GLint level, gl::GLenum internalFormat, gl::GLsizei width, gl::GLsizei height, gl::GLint border, gl::GLenum format, gl::GLenum type, const gl::GLvoid * data);
90 void image2D(gl::GLint level, gl::GLenum internalFormat, const glm::ivec2 & size, gl::GLint border, gl::GLenum format, gl::GLenum type, const gl::GLvoid * data);
91 void compressedImage2D(gl::GLint level, gl::GLenum internalFormat, gl::GLsizei width, gl::GLsizei height, gl::GLint border, gl::GLsizei imageSize, const gl::GLvoid * data);
92 void compressedImage2D(gl::GLint level, gl::GLenum internalFormat, const glm::ivec2 & size, gl::GLint border, gl::GLsizei imageSize, const gl::GLvoid * data);
93 void subImage2D(gl::GLint level, gl::GLint xOffset, gl::GLint yOffset, gl::GLsizei width, gl::GLsizei height, gl::GLenum format, gl::GLenum type, const gl::GLvoid * data);
94 void subImage2D(gl::GLint level, const glm::ivec2& offset, const glm::ivec2& size, gl::GLenum format, gl::GLenum type, const gl::GLvoid * data);
95
96 void image3D(gl::GLint level, gl::GLenum internalFormat, gl::GLsizei width, gl::GLsizei height, gl::GLsizei depth, gl::GLint border, gl::GLenum format, gl::GLenum type, const gl::GLvoid * data);
97 void image3D(gl::GLint level, gl::GLenum internalFormat, const glm::ivec3 & size, gl::GLint border, gl::GLenum format, gl::GLenum type, const gl::GLvoid * data);
98 void compressedImage3D(gl::GLint level, gl::GLenum internalFormat, gl::GLsizei width, gl::GLsizei height, gl::GLsizei depth, gl::GLint border, gl::GLsizei imageSize, const gl::GLvoid * data);
99 void compressedImage3D(gl::GLint level, gl::GLenum internalFormat, const glm::ivec3 & size, gl::GLint border, gl::GLsizei imageSize, const gl::GLvoid * data);
100 void subImage3D(gl::GLint level, gl::GLint xOffset, gl::GLint yOffset, gl::GLint zOffset, gl::GLsizei width, gl::GLsizei height, gl::GLsizei depth, gl::GLenum format, gl::GLenum type, const gl::GLvoid * data);
101 void subImage3D(gl::GLint level, const glm::ivec3& offset, const glm::ivec3& size, gl::GLenum format, gl::GLenum type, const gl::GLvoid * data);
102
103 void image2DMultisample(gl::GLsizei samples, gl::GLenum internalFormat, gl::GLsizei width, gl::GLsizei height, gl::GLboolean fixedSamplesLocations);
104 void image2DMultisample(gl::GLsizei samples, gl::GLenum internalFormat, const glm::ivec2 & size, gl::GLboolean fixedSamplesLocations);
105 void image3DMultisample(gl::GLsizei samples, gl::GLenum internalFormat, gl::GLsizei width, gl::GLsizei height, gl::GLsizei depth, gl::GLboolean fixedSamplesLocations);
106 void image3DMultisample(gl::GLsizei samples, gl::GLenum internalFormat, const glm::ivec3 & size, gl::GLboolean fixedSamplesLocations);
107
108 void storage1D(gl::GLsizei levels, gl::GLenum internalFormat, gl::GLsizei width);
109 void storage2D(gl::GLsizei levels, gl::GLenum internalFormat, gl::GLsizei width, gl::GLsizei height);
110 void storage2D(gl::GLsizei levels, gl::GLenum internalFormat, const glm::ivec2 & size);
111 void storage3D(gl::GLsizei levels, gl::GLenum internalFormat, gl::GLsizei width, gl::GLsizei height, gl::GLsizei depth);
112 void storage3D(gl::GLsizei levels, gl::GLenum internalFormat, const glm::ivec3 & size);
113
114 void textureView(gl::GLuint originalTexture, gl::GLenum internalFormat, gl::GLuint minLevel, gl::GLuint numLevels, gl::GLuint minLayer, gl::GLuint numLayers);
115
116 void texBuffer(gl::GLenum internalFormat, Buffer * buffer);
117 void texBufferRange(gl::GLenum internalFormat, Buffer * buffer, gl::GLintptr offset, gl::GLsizeiptr size);
118
119 void clearImage(gl::GLint level, gl::GLenum format, gl::GLenum type, const void * data);
120 void clearImage(gl::GLint level, gl::GLenum format, gl::GLenum type, const glm::vec4 & value);
121 void clearImage(gl::GLint level, gl::GLenum format, gl::GLenum type, const glm::ivec4 & value);
122 void clearImage(gl::GLint level, gl::GLenum format, gl::GLenum type, const glm::uvec4 & value);
123
124 void clearSubImage(gl::GLint level, gl::GLint xOffset, gl::GLint yOffset, gl::GLint zOffset, gl::GLsizei width, gl::GLsizei height, gl::GLsizei depth, gl::GLenum format, gl::GLenum type, const void * data);
125 void clearSubImage(gl::GLint level, const glm::ivec3 & offset, const glm::ivec3 & size, gl::GLenum format, gl::GLenum type, const void * data);
126 void clearSubImage(gl::GLint level, const glm::ivec3 & offset, const glm::ivec3 & size, gl::GLenum format, gl::GLenum type, const glm::vec4 & value);
127 void clearSubImage(gl::GLint level, const glm::ivec3 & offset, const glm::ivec3 & size, gl::GLenum format, gl::GLenum type, const glm::ivec4 & value);
128 void clearSubImage(gl::GLint level, const glm::ivec3 & offset, const glm::ivec3 & size, gl::GLenum format, gl::GLenum type, const glm::uvec4 & value);
129
130 void invalidateImage(gl::GLint level) const;
131 void invalidateSubImage(gl::GLint level, gl::GLint xoffset, gl::GLint yoffset, gl::GLint zoffset, gl::GLsizei width, gl::GLsizei height, gl::GLsizei depth);
132 void invalidateSubImage(gl::GLint level, const glm::ivec3& offset, const glm::ivec3 size);
133
134 void bindImageTexture(gl::GLuint unit, gl::GLint level, gl::GLboolean layered, gl::GLint layer, gl::GLenum access, gl::GLenum format) const;
135 static void unbindImageTexture(gl::GLuint unit);
136
137 void generateMipmap();
138
139 void cubeMapImage(gl::GLint level, gl::GLenum internalFormat, gl::GLsizei width, gl::GLsizei height, gl::GLint border, gl::GLenum format, gl::GLenum type, const gl::GLvoid * data);
140 void cubeMapImage(gl::GLint level, gl::GLenum internalFormat, const glm::ivec2 & size, gl::GLint border, gl::GLenum format, gl::GLenum type, const gl::GLvoid * data);
141
142 TextureHandle textureHandle() const;
143 TextureHandle textureHandle(Sampler * sampler) const;
144
145 void pageCommitment(gl::GLint level, gl::GLint xOffset, gl::GLint yOffset, gl::GLint zOffset, gl::GLsizei width, gl::GLsizei height, gl::GLsizei depth, gl::GLboolean commit) const;
146 void pageCommitment(gl::GLint level, const glm::ivec3& offset, const glm::ivec3& size, gl::GLboolean commit) const;
147
148 virtual gl::GLenum objectType() const override;
149
150 protected:
151 Texture(IDResource * resource, gl::GLenum target);
152 virtual ~Texture();
153
154 protected:
155 gl::GLenum m_target;
156 };
157
158
159 } // namespace globjects
globjects::Texture::m_target
gl::GLenum m_target
Definition: Texture.h:155
globjects
Contains all the classes that wrap OpenGL functionality.
globjects::Object
Superclass of all wrapped OpenGL objects.
Definition: Object.h:26
globjects::TextureHandle
Definition: TextureHandle.h:18
globjects::Buffer
Wrapper for OpenGL buffer objects.
Definition: Buffer.h:35
globjects::Sampler
Wraps OpenGL sampler objects.
Definition: Sampler.h:18
globjects::Texture::BindlessImplementation
BindlessImplementation
Definition: Texture.h:33
globjects::ObjectVisitor
Implements a Visitor Pattern to iterate over all tracked globjects objects.
Definition: ObjectVisitor.h:29
Object.h
globjects::Texture
Wraps OpenGL texture objects. A Texture provides both interfaces to bind them for the OpenGL pipeline...
Definition: Texture.h:30
globjects::Texture::StorageImplementation
StorageImplementation
Definition: Texture.h:40