Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
glTexture.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef GL_TEXTURE_H
34#define GL_TEXTURE_H
35
39
40namespace Divide {
41
42class glTexture final : public Texture {
43
44 public:
45 explicit glTexture( PlatformContext& context, const ResourceDescriptor<Texture>& descriptor );
46
47 ~glTexture() override;
48
49 bool unload() override;
50
51 void clearData( const UColour4& clearColour, SubRange layerRange, U8 mipLevel ) const;
52
53 [[nodiscard]] ImageReadbackData readData(U8 mipLevel, const PixelAlignment& pixelPackAlignment) const override;
54
55 PROPERTY_R_IW( gl46core::GLuint, textureHandle, GL_NULL_HANDLE);
56
57 static void Copy(const glTexture* source, U8 sourceSamples, const glTexture* destination, U8 destinationSamples, const CopyTexParams& params);
58
59 protected:
60 bool postLoad() override;
61 void reserveStorage();
62 void loadDataInternal(const ImageTools::ImageData& imageData, const vec3<U16>& offset, const PixelAlignment& pixelUnpackAlignment ) override;
63 void loadDataInternal( const Byte* data, size_t size, U8 targetMip, const vec3<U16>& offset, const vec3<U16>& dimensions, const PixelAlignment& pixelUnpackAlignment ) override;
64 void prepareTextureData(U16 width, U16 height, U16 depth, bool emptyAllocation) override;
65 void submitTextureData() override;
66
67 private:
68 gl46core::GLenum _type{ gl46core::GL_NONE};
69 gl46core::GLuint _loadingHandle{ GL_NULL_HANDLE };
70 gl46core::GLsync _loadSync{ nullptr };
71 bool _hasStorage{ false };
72};
73
75
76}; // namespace Divide
77
78#endif //GL_TEXTURE_H
#define TYPEDEF_SMART_POINTERS_FOR_TYPE(T)
GFXDevice & context() const noexcept
An API-independent representation of a texture.
Definition: Texture.h:83
void loadDataInternal(const ImageTools::ImageData &imageData, const vec3< U16 > &offset, const PixelAlignment &pixelUnpackAlignment) override
Definition: glTexture.cpp:195
~glTexture() override
Definition: glTexture.cpp:20
PROPERTY_R_IW(gl46core::GLuint, textureHandle, GL_NULL_HANDLE)
bool unload() override
Definition: glTexture.cpp:25
gl46core::GLsync _loadSync
Definition: glTexture.h:70
ImageReadbackData readData(U8 mipLevel, const PixelAlignment &pixelPackAlignment) const override
Definition: glTexture.cpp:410
gl46core::GLenum _type
Definition: glTexture.h:68
void submitTextureData() override
Definition: glTexture.cpp:165
gl46core::GLuint _loadingHandle
Definition: glTexture.h:69
static void Copy(const glTexture *source, U8 sourceSamples, const glTexture *destination, U8 destinationSamples, const CopyTexParams &params)
Definition: glTexture.cpp:366
void reserveStorage()
Definition: glTexture.cpp:54
void clearData(const UColour4 &clearColour, SubRange layerRange, U8 mipLevel) const
Definition: glTexture.cpp:280
void prepareTextureData(U16 width, U16 height, U16 depth, bool emptyAllocation) override
Definition: glTexture.cpp:147
bool postLoad() override
Definition: glTexture.cpp:41
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
std::byte Byte
uint8_t U8
constexpr gl46core::GLuint GL_NULL_HANDLE
Invalid object value. Used to compare handles and determine if they were properly created.
Definition: glResources.h:105
uint16_t U16