diff --git a/include/boo/graphicsdev/GL.hpp b/include/boo/graphicsdev/GL.hpp index 5715867..ebf90df 100644 --- a/include/boo/graphicsdev/GL.hpp +++ b/include/boo/graphicsdev/GL.hpp @@ -31,8 +31,8 @@ public: const void* data, size_t sz); ITextureS* newStaticTexture(size_t width, size_t height, size_t mips, TextureFormat fmt, std::unique_ptr&& data, size_t sz); - ITextureS* newStaticArrayTexture(size_t width, size_t height, size_t layers, TextureFormat fmt, - const void* data, size_t sz); + ITextureSA* newStaticArrayTexture(size_t width, size_t height, size_t layers, TextureFormat fmt, + const void* data, size_t sz); ITextureD* newDynamicTexture(size_t width, size_t height, TextureFormat fmt); ITextureR* newRenderTexture(size_t width, size_t height, size_t samples); diff --git a/include/boo/graphicsdev/IGraphicsDataFactory.hpp b/include/boo/graphicsdev/IGraphicsDataFactory.hpp index 32e978d..3ece92e 100644 --- a/include/boo/graphicsdev/IGraphicsDataFactory.hpp +++ b/include/boo/graphicsdev/IGraphicsDataFactory.hpp @@ -46,6 +46,7 @@ enum class BufferUse enum class TextureType { Static, + StaticArray, Dynamic, Render }; @@ -66,6 +67,13 @@ protected: ITextureS() : ITexture(TextureType::Static) {} }; +/** Static-array resource buffer for array textures */ +struct ITextureSA : ITexture +{ +protected: + ITextureSA() : ITexture(TextureType::StaticArray) {} +}; + /** Dynamic resource buffer for textures */ struct ITextureD : ITexture { @@ -192,7 +200,7 @@ struct IGraphicsDataFactory virtual ITextureS* newStaticTexture(size_t width, size_t height, size_t mips, TextureFormat fmt, std::unique_ptr&& data, size_t sz)=0; - virtual ITextureS* + virtual ITextureSA* newStaticArrayTexture(size_t width, size_t height, size_t layers, TextureFormat fmt, const void* data, size_t sz)=0; virtual ITextureD* diff --git a/lib/graphicsdev/GL.cpp b/lib/graphicsdev/GL.cpp index 4f69449..294b83e 100644 --- a/lib/graphicsdev/GL.cpp +++ b/lib/graphicsdev/GL.cpp @@ -19,7 +19,7 @@ struct GLData : IGraphicsData std::vector> m_SBufs; std::vector> m_DBufs; std::vector> m_STexs; - std::vector> m_SATexs; + std::vector> m_SATexs; std::vector> m_DTexs; std::vector> m_RTexs; std::vector> m_VFmts; @@ -137,12 +137,12 @@ public: } }; -class GLArrayTextureS : public ITextureS +class GLTextureSA : public ITextureSA { friend class GLDataFactory; GLuint m_tex; - GLArrayTextureS(size_t width, size_t height, size_t layers, - TextureFormat fmt, const void* data, size_t sz) + GLTextureSA(size_t width, size_t height, size_t layers, + TextureFormat fmt, const void* data, size_t sz) { glGenTextures(1, &m_tex); glBindTexture(GL_TEXTURE_2D_ARRAY, m_tex); @@ -154,7 +154,7 @@ class GLArrayTextureS : public ITextureS glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_R8, width, height, layers, 0, GL_RED, GL_UNSIGNED_BYTE, data); } public: - ~GLArrayTextureS() {glDeleteTextures(1, &m_tex);} + ~GLTextureSA() {glDeleteTextures(1, &m_tex);} void bind(size_t idx) const { @@ -234,11 +234,11 @@ GLDataFactory::newStaticTexture(size_t width, size_t height, size_t mips, Textur return retval; } -ITextureS* +ITextureSA* GLDataFactory::newStaticArrayTexture(size_t width, size_t height, size_t layers, TextureFormat fmt, const void *data, size_t sz) { - GLArrayTextureS* retval = new GLArrayTextureS(width, height, layers, fmt, data, sz); + GLTextureSA* retval = new GLTextureSA(width, height, layers, fmt, data, sz); static_cast(m_deferredData)->m_SATexs.emplace_back(retval); return retval; } @@ -494,10 +494,19 @@ struct GLShaderDataBinding : IShaderDataBinding for (size_t i=0 ; itype() == TextureType::Dynamic) + switch (tex->type()) + { + case TextureType::Dynamic: static_cast(tex)->bind(i); - else if (tex->type() == TextureType::Static) + break; + case TextureType::Static: static_cast(tex)->bind(i); + break; + case TextureType::StaticArray: + static_cast(tex)->bind(i); + break; + default: break; + } } } }; diff --git a/lib/x11/WindowXlib.cpp b/lib/x11/WindowXlib.cpp index 17411e2..e805797 100644 --- a/lib/x11/WindowXlib.cpp +++ b/lib/x11/WindowXlib.cpp @@ -838,7 +838,10 @@ public: case ClientMessage: { if (event->xclient.data.l[0] == S_ATOMS->m_wmDeleteWindow && m_callback) + { m_callback->destroyed(); + m_callback = nullptr; + } return; } case Expose: