Cogs.Core
TexturesGLES30.h
1#pragma once
2
3#include "../Base/TexturesCommon.h"
4
5#include "CommonGLES30.h"
6
7namespace Cogs
8{
9 struct ContextGLES30;
10 struct CapabilitiesGLES30;
11
13 {
14 // Resources, needs to be released
15 GLuint textureId;
16 GLuint renderBuffer;
17 GLuint fbo; // Temporary FBO for reading
18
19 // GL_TEXTURE_2D, GL_TEXTURE_2D_ARRAY, GL_TEXTURE_3D or GL_TEXTURE_2D_MULTISAMPLE (which implies renderbuffer and not texture).
20 GLenum target;
21 uint32_t width;
22 uint32_t height;
23 uint32_t depth;
24
25 uint32_t estimatedByteSize; // bytesize
26
27 uint32_t flags;
28 TextureFormat format;
29 uint8_t numSamples;
30
31 struct {
32 unsigned short boundAsView : 1;
33 unsigned short hasMipmaps : 1;
34 unsigned short cubeMap : 1;
35 };
36
37 };
38
40 {
41 GLuint glName = 0;
42 };
43
45 {
46
47 void initialize(ContextGLES30* context, CapabilitiesGLES30* caps) { this->context = context; this->caps = caps; }
48
49 TextureHandle loadTexture(const TextureDescription & desc, const TextureData * data);
50 void uploadTextureData(TextureGLES30& tex, const TextureData& data, uint32_t layer_offset, uint32_t face_offset, uint32_t level_offset);
51 void uploadTextureData(TextureHandle textureHandle, const TextureData& data, uint32_t layer_offset, uint32_t face_offset, uint32_t level_offset) override;
52 void releaseTexture(TextureHandle textureHandle);
53
54 void releaseNativeTexture(TextureNativeHandle nativeHandle) override;
55
58
60 void releaseTextureView(const TextureViewHandle & handle) override;
61 void * getNativeHandle(TextureHandle textureHandle) override;
62
63 void generateMipmaps(TextureHandle texureHandle);
64
65 void releaseResources();
66
67 size_t textureMemoryConsumption = 0;
71
72 protected:
73 friend struct ContextGLES30;
74
75 void defineTextureData(TextureGLES30* tex, GLuint textureLevels);
76
77 private:
78 ContextGLES30* context = nullptr;
79 CapabilitiesGLES30* caps = nullptr;
80 };
81}
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
Encapsulates state for texture sampling in a state object.
Definition: SamplerState.h:12
unsigned short boundAsView
True if last use of texture was as a view.
Describes how to fetch data from a texture in shaders.
Definition: ITextures.h:13
void releaseNativeTexture(TextureNativeHandle nativeHandle) override
Release a native texture handle.
void releaseSamplerState(SamplerStateHandle handle)
Release the sampler state with the given handle.
void releaseTexture(TextureHandle textureHandle)
Release the texture with the given textureHandle.
void generateMipmaps(TextureHandle texureHandle)
Use the graphics device to generate mipmaps for the texture with the given texture handle.
void releaseResources()
Release all allocated texture resources.
TextureViewHandle createTextureView(TextureViewDescription &viewDescription) override
Create a texture view used to bind a limited view of the texture data to the rendering pipeline.
void * getNativeHandle(TextureHandle textureHandle) override
Get the device-specific handle (D3D texture pointer, OpenGL texture ID etc) associated with the given...
TextureHandle loadTexture(const TextureDescription &desc, const TextureData *data)
Load a texture from the given description.
void releaseTextureView(const TextureViewHandle &handle) override
Release the given texture view.
SamplerStateHandle loadSamplerState(const SamplerState &state)
Load a sampler state object.