From e02d3dbd590810df98b08c17fd81e6ce28711af8 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sat, 20 Nov 2021 16:35:20 +0500 Subject: Fixed some broken graphics features --- src/GalOgl.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/GalOgl.cpp') diff --git a/src/GalOgl.cpp b/src/GalOgl.cpp index 052c68a..29e7fc0 100644 --- a/src/GalOgl.cpp +++ b/src/GalOgl.cpp @@ -1055,6 +1055,10 @@ struct ImplOgl : public Impl { glCheckError(); } + virtual void SetWireframe(bool enabled) override { + glPolygonMode(GL_FRONT_AND_BACK, enabled ? GL_LINE : GL_FILL); + } + virtual std::shared_ptr CreateBuffer() override { auto buff = std::make_shared(); -- cgit v1.2.3 From aafc423a7298b0fc595c0209480474dc50c277f0 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 21 Nov 2021 13:56:28 +0500 Subject: Added Gbuffer --- src/GalOgl.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/GalOgl.cpp') diff --git a/src/GalOgl.cpp b/src/GalOgl.cpp index 29e7fc0..c250539 100644 --- a/src/GalOgl.cpp +++ b/src/GalOgl.cpp @@ -137,6 +137,7 @@ public: if (activeTexture[textureUnit] != texture) { SetTextureUnit(textureUnit); glBindTexture(type, texture); + activeTexture[textureUnit] = texture; } glCheckError(); } @@ -690,6 +691,7 @@ struct FramebufferOgl : public Framebuffer { size_t vpX = 0, vpY = 0, vpW = 1, vpH = 1; std::shared_ptr depthStencil; std::vector> colors; + std::vector attachments; GlResource fbo; @@ -853,6 +855,8 @@ struct PipelineOgl : public Pipeline { oglState.UseProgram(program); oglState.BindFbo(target->fbo); oglState.SetViewport(target->vpX, target->vpY, target->vpW, target->vpH); + if (target->fbo) + glDrawBuffers(target->attachments.size(), target->attachments.data()); for (size_t i = 0; i < staticTextures.size(); i++) { oglState.BindTexture(staticTextures[i]->type, staticTextures[i]->texture, i); @@ -1226,6 +1230,7 @@ struct ImplOgl : public Impl { glUniform1i(location, usedTextureBlocks); pipeline->staticTextures.push_back(texture); + usedTextureBlocks++; } glCheckError(); @@ -1299,6 +1304,7 @@ struct ImplOgl : public Impl { for (auto&& [location, texture] : conf->colors) { glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + location, texture->type, texture->texture, 0); fb->colors.emplace_back(std::move(texture)); + fb->attachments.push_back(GL_COLOR_ATTACHMENT0 + location); } if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { @@ -1315,6 +1321,7 @@ struct ImplOgl : public Impl { if (!fbDefault) fbDefault = std::make_shared(); fbDefault->fbo = GlResource(0, GlResourceType::None); + fbDefault->attachments.push_back(GL_COLOR_ATTACHMENT0); return std::static_pointer_cast(fbDefault); } -- cgit v1.2.3 From 0ca11f9bee1cd918acf6ce8247a495442009fec9 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 21 Nov 2021 17:49:23 +0500 Subject: Moved face lighting to lighting pass --- src/GalOgl.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/GalOgl.cpp') diff --git a/src/GalOgl.cpp b/src/GalOgl.cpp index c250539..75369ab 100644 --- a/src/GalOgl.cpp +++ b/src/GalOgl.cpp @@ -1256,6 +1256,11 @@ struct ImplOgl : public Impl { size_t attribSize = GalTypeGetSize(type); for (size_t i = 0; i < count; i++) { + if (location < 0) { + vertexSize += attribSize; + continue; + } + pipeline->vertexBindCmds.push_back({ bufferId, static_cast(location + i), -- cgit v1.2.3 From 7f3ed11618df0cce5c3d799e0b3f4c009714f2c3 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sat, 27 Nov 2021 19:03:36 +0500 Subject: Added ShaderParametersBuffer to GalOgl --- src/GalOgl.cpp | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 9 deletions(-) (limited to 'src/GalOgl.cpp') diff --git a/src/GalOgl.cpp b/src/GalOgl.cpp index 75369ab..854ab40 100644 --- a/src/GalOgl.cpp +++ b/src/GalOgl.cpp @@ -74,9 +74,10 @@ public: using namespace Gal; -class ImplOgl; -class ShaderOgl; -class FramebufferOgl; +struct ImplOgl; +struct ShaderOgl; +struct FramebufferOgl; +struct ShaderParametersBufferOgl; class OglState { GLuint activeFbo = 0; @@ -165,6 +166,7 @@ public: std::unique_ptr impl; std::shared_ptr fbDefault; +std::shared_ptr spbDefault; size_t GalTypeGetComponents(Gal::Type type) { switch (type) { @@ -731,6 +733,22 @@ struct FramebufferConfigOgl : public FramebufferConfig { } }; +struct ShaderParametersBufferOgl : public ShaderParametersBuffer { + std::shared_ptr buffer; + bool dirty = true; + std::vector data; + + virtual std::byte* GetDataPtr() override { + dirty = true; + return data.data(); + } + + virtual void Resize(size_t newSize) override { + dirty = true; + data.resize(newSize); + } +}; + struct PipelineConfigOgl : public PipelineConfig { std::shared_ptr vertexShader, pixelShader; @@ -834,7 +852,7 @@ struct PipelineInstanceOgl : public PipelineInstance { }; struct PipelineOgl : public Pipeline { - + std::vector> spbs; std::map shaderParameters; std::vector> staticTextures; GlResource program; @@ -861,6 +879,13 @@ struct PipelineOgl : public Pipeline { for (size_t i = 0; i < staticTextures.size(); i++) { oglState.BindTexture(staticTextures[i]->type, staticTextures[i]->texture, i); } + + for (auto& spb : spbs) { + if (spb->dirty) { + spb->buffer->SetData(std::vector(spb->data)); + spb->dirty = false; + } + } } virtual void SetDynamicTexture(std::string_view name, std::shared_ptr texture) override { @@ -1205,6 +1230,23 @@ struct ImplOgl : public Impl { glCheckError(); + /* + * Shader parameters buffers + */ + constexpr auto spbGlobalsName = "Globals"; + size_t spbGlobalsBind = 0; + size_t spbIndex = glGetUniformBlockIndex(program, spbGlobalsName); + if (spbIndex != GL_INVALID_VALUE) { + glUniformBlockBinding(program, spbIndex, spbGlobalsBind); + auto spbGlobals = std::static_pointer_cast(GetGlobalShaderParameters()); + glBindBufferBase(GL_UNIFORM_BUFFER, spbGlobalsBind, spbGlobals->buffer->vbo); + pipeline->spbs.emplace_back(spbGlobals); + } + else + LOG(ERROR) << "Cannot bind Globals UBO to shader. Maybe uniform block Globals missing?"; + glCheckError(); + + /* * Shader parameters */ @@ -1323,16 +1365,21 @@ struct ImplOgl : public Impl { } virtual std::shared_ptr GetDefaultFramebuffer() override { - if (!fbDefault) + if (!fbDefault) { fbDefault = std::make_shared(); - fbDefault->fbo = GlResource(0, GlResourceType::None); - fbDefault->attachments.push_back(GL_COLOR_ATTACHMENT0); + fbDefault->fbo = GlResource(0, GlResourceType::None); + fbDefault->attachments.push_back(GL_COLOR_ATTACHMENT0); + } return std::static_pointer_cast(fbDefault); } - virtual std::shared_ptr GetGlobalShaderParameters() override { - return nullptr; + virtual std::shared_ptr GetGlobalShaderParameters() override { + if (!spbDefault) { + spbDefault = std::make_shared(); + spbDefault->buffer = std::static_pointer_cast(GetImplementation()->CreateBuffer()); + } + return spbDefault; } virtual std::shared_ptr LoadVertexShader(std::string_view code) override { -- cgit v1.2.3 From c905ede556c892d39fd69d3945026ba244567ce9 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sat, 27 Nov 2021 21:08:58 +0500 Subject: Changed shaders to use SPB --- src/GalOgl.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/GalOgl.cpp') diff --git a/src/GalOgl.cpp b/src/GalOgl.cpp index 854ab40..961c6ef 100644 --- a/src/GalOgl.cpp +++ b/src/GalOgl.cpp @@ -1049,6 +1049,8 @@ struct ImplOgl : public Impl { throw std::runtime_error("GLEW initialization failed with unknown reason"); } + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + GLint flags; glGetIntegerv(GL_CONTEXT_FLAGS, &flags); if (flags & GL_CONTEXT_FLAG_DEBUG_BIT) -- cgit v1.2.3 From 8286ddda96a5f2925d342d0ce115aa00ae5d94ec Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 28 Nov 2021 16:16:29 +0500 Subject: Added gamma correction --- src/GalOgl.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'src/GalOgl.cpp') diff --git a/src/GalOgl.cpp b/src/GalOgl.cpp index 961c6ef..ff43ed8 100644 --- a/src/GalOgl.cpp +++ b/src/GalOgl.cpp @@ -321,7 +321,7 @@ size_t GalFormatGetSize(Format format) { return 0; } -GLenum GalFormatGetGlInternalFormat(Format format) { +GLenum GalFormatGetGlLinearInternalFormat(Format format) { switch (format) { case Format::D24S8: return GL_DEPTH24_STENCIL8; @@ -335,6 +335,20 @@ GLenum GalFormatGetGlInternalFormat(Format format) { return 0; } +GLenum GalFormatGetGlInternalFormat(Format format) { + switch (format) { + case Format::D24S8: + return GL_DEPTH24_STENCIL8; + case Format::R8G8B8: + return GL_SRGB; + case Format::R8G8B8A8: + return GL_SRGB_ALPHA; + default: + return 0; + } + return 0; +} + GLenum GalFormatGetGlFormat(Format format) { switch (format) { case Format::D24S8: @@ -580,6 +594,7 @@ struct TextureConfigOgl : public TextureConfig { Format format; size_t width = 1, height = 1, depth = 1; bool interpolateLayers = false; + bool linear = true; GLenum type; Filtering min = Filtering::Nearest, max = Filtering::Nearest; @@ -597,6 +612,10 @@ struct TextureConfigOgl : public TextureConfig { wrap = wrapping; } + virtual void SetLinear(bool isLinear) override { + linear = isLinear; + } + }; struct TextureOgl : public Texture { @@ -605,12 +624,15 @@ struct TextureOgl : public Texture { GlResource texture; Format format; size_t width, height, depth; + bool linear; virtual void SetData(std::vector&& data, size_t mipLevel = 0) override { size_t expectedSize = width * height * depth * GalFormatGetSize(format); if (data.size() != expectedSize && !data.empty()) throw std::logic_error("Size of data is not valid for this texture"); + GLenum internalFormat = linear ? GalFormatGetGlLinearInternalFormat(format) : GalFormatGetGlInternalFormat(format); + oglState.BindTexture(type, texture); switch (type) { @@ -630,13 +652,13 @@ struct TextureOgl : public Texture { case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: case GL_PROXY_TEXTURE_CUBE_MAP: - glTexImage2D(type, mipLevel, GalFormatGetGlInternalFormat(format), width, height, 0, GalFormatGetGlFormat(format), GalFormatGetGlType(format), data.empty() ? nullptr : data.data()); + glTexImage2D(type, mipLevel, internalFormat, width, height, 0, GalFormatGetGlFormat(format), GalFormatGetGlType(format), data.empty() ? nullptr : data.data()); break; case GL_TEXTURE_3D: case GL_PROXY_TEXTURE_3D: case GL_TEXTURE_2D_ARRAY: case GL_PROXY_TEXTURE_2D_ARRAY: - glTexImage3D(type, mipLevel, GalFormatGetGlInternalFormat(format), width, height, depth, 0, GalFormatGetGlFormat(format), GalFormatGetGlType(format), data.empty() ? nullptr : data.data()); + glTexImage3D(type, mipLevel, internalFormat, width, height, depth, 0, GalFormatGetGlFormat(format), GalFormatGetGlType(format), data.empty() ? nullptr : data.data()); break; default: throw std::runtime_error("Unknown texture type"); @@ -1136,6 +1158,7 @@ struct ImplOgl : public Impl { texture->width = texConfig->width; texture->height = texConfig->height; texture->depth = texConfig->depth; + texture->linear = texConfig->linear; GLuint newTex; glGenTextures(1, &newTex); -- cgit v1.2.3 From 3f122e57f118db1229a4bad2c54be624f2f8f19c Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 5 Dec 2021 00:51:39 +0500 Subject: Added SSAO --- src/GalOgl.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/GalOgl.cpp') diff --git a/src/GalOgl.cpp b/src/GalOgl.cpp index ff43ed8..c7344fe 100644 --- a/src/GalOgl.cpp +++ b/src/GalOgl.cpp @@ -311,10 +311,14 @@ GLenum GalTypeGetComponentGlType(Gal::Type type) { size_t GalFormatGetSize(Format format) { switch (format) { + case Format::D24S8: + return 4; case Format::R8G8B8: return 3; case Format::R8G8B8A8: return 4; + case Format::R32G32B32A32F: + return 16; default: return 0; } @@ -329,6 +333,8 @@ GLenum GalFormatGetGlLinearInternalFormat(Format format) { return GL_RGB8; case Format::R8G8B8A8: return GL_RGBA8; + case Format::R32G32B32A32F: + return GL_RGBA32F; default: return 0; } @@ -338,11 +344,13 @@ GLenum GalFormatGetGlLinearInternalFormat(Format format) { GLenum GalFormatGetGlInternalFormat(Format format) { switch (format) { case Format::D24S8: - return GL_DEPTH24_STENCIL8; + return 0; case Format::R8G8B8: return GL_SRGB; case Format::R8G8B8A8: return GL_SRGB_ALPHA; + case Format::R32G32B32A32F: + return 0; default: return 0; } @@ -357,6 +365,8 @@ GLenum GalFormatGetGlFormat(Format format) { return GL_RGB; case Format::R8G8B8A8: return GL_RGBA; + case Format::R32G32B32A32F: + return GL_RGBA; default: return 0; } @@ -371,6 +381,8 @@ GLenum GalFormatGetGlType(Format format) { return GL_UNSIGNED_BYTE; case Format::R8G8B8A8: return GL_UNSIGNED_BYTE; + case Format::R32G32B32A32F: + return GL_FLOAT; default: return 0; } -- cgit v1.2.3 From da66c30a110233f7c8b71b5e6aa8dd804879c1b6 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 5 Dec 2021 05:42:15 +0500 Subject: Added blending --- src/GalOgl.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/GalOgl.cpp') diff --git a/src/GalOgl.cpp b/src/GalOgl.cpp index c7344fe..4ac6c84 100644 --- a/src/GalOgl.cpp +++ b/src/GalOgl.cpp @@ -89,6 +89,7 @@ class OglState { GLuint activeTextureUnit = 0; GLint vpX = 0, vpY = 0; GLsizei vpW = 0, vpH = 0; + bool blending = false; public: @@ -162,6 +163,16 @@ public: glCheckError(); } + void EnableBlending(bool enable) { + if (enable != blending) { + blending = enable; + if (blending) + glEnable(GL_BLEND); + else + glDisable(GL_BLEND); + } + } + } oglState; std::unique_ptr impl; @@ -791,6 +802,7 @@ struct PipelineConfigOgl : public PipelineConfig { std::shared_ptr targetFb; std::vector> vertexBuffers; Primitive vertexPrimitive = Primitive::Triangle; + Blending blending = Blending::Opaque; virtual void SetVertexShader(std::shared_ptr shader) override { vertexShader = std::static_pointer_cast(shader); @@ -818,6 +830,10 @@ struct PipelineConfigOgl : public PipelineConfig { vertexPrimitive = primitive; } + virtual void SetBlending(Blending blendingMode) override { + blending = blendingMode; + } + virtual std::shared_ptr BindVertexBuffer(std::vector &&bufferLayout) override { auto binding = std::make_shared(vertexBuffers.size()); vertexBuffers.push_back(bufferLayout); @@ -901,12 +917,14 @@ struct PipelineOgl : public Pipeline { }; std::vector vertexBindCmds; Primitive primitive; + Blending blending; std::shared_ptr target; virtual void Activate() override { oglState.UseProgram(program); oglState.BindFbo(target->fbo); oglState.SetViewport(target->vpX, target->vpY, target->vpW, target->vpH); + oglState.EnableBlending(blending == Blending::Additive); if (target->fbo) glDrawBuffers(target->attachments.size(), target->attachments.data()); @@ -1076,7 +1094,7 @@ struct ImplOgl : public Impl { glCullFace(GL_BACK); glFrontFace(GL_CCW); - glEnable(GL_BLEND); + oglState.EnableBlending(true); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glCheckError(); if (glActiveTexture == nullptr) { @@ -1201,6 +1219,7 @@ struct ImplOgl : public Impl { auto config = std::static_pointer_cast(pipelineConfig); pipeline->primitive = config->vertexPrimitive; + pipeline->blending = config->blending; pipeline->target = config->targetFb; if (!pipeline->target) -- cgit v1.2.3 From a27bfe76545822eb4ef2798c8200096ec9b6963c Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Tue, 7 Dec 2021 16:38:36 +0500 Subject: Fixed GalOgl OglState dangling resource --- src/GalOgl.cpp | 162 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 98 insertions(+), 64 deletions(-) (limited to 'src/GalOgl.cpp') diff --git a/src/GalOgl.cpp b/src/GalOgl.cpp index 4ac6c84..6452a44 100644 --- a/src/GalOgl.cpp +++ b/src/GalOgl.cpp @@ -7,70 +7,6 @@ #include "Utility.hpp" -enum class GlResourceType { - Vbo, - Vao, - Texture, - Fbo, - Program, - None, -}; - -class GlResource { - GlResourceType type = GlResourceType::None; - GLuint res = 0; -public: - GlResource() = default; - - GlResource(GLuint resource, GlResourceType resType) noexcept : res(resource), type(resType) {} - - GlResource(const GlResource&) = delete; - - GlResource(GlResource&& rhs) noexcept { - std::swap(this->res, rhs.res); - std::swap(this->type, rhs.type); - } - - GlResource& operator=(const GlResource&) = delete; - - GlResource& operator=(GlResource&& rhs) noexcept { - std::swap(this->res, rhs.res); - std::swap(this->type, rhs.type); - return *this; - } - - ~GlResource() { - switch (type) { - case GlResourceType::Vbo: - glDeleteBuffers(1, &res); - break; - case GlResourceType::Vao: - glDeleteVertexArrays(1, &res); - break; - case GlResourceType::Texture: - glDeleteTextures(1, &res); - break; - case GlResourceType::Fbo: - glDeleteFramebuffers(1, &res); - break; - case GlResourceType::Program: - glDeleteProgram(res); - break; - case GlResourceType::None: - default: - break; - } - } - - operator GLuint() const noexcept { - return res; - } - - GLuint Get() const noexcept { - return res; - } -}; - using namespace Gal; @@ -173,8 +109,106 @@ public: } } + void ReleaseFbo(GLuint vao) { + if (activeVao == vao) + activeVao = 0; + } + + void ReleaseVao(GLuint fbo) { + if (activeFbo == fbo) + activeEbo = 0; + } + + void ReleaseVbo(GLuint vbo) { + if (activeVbo == vbo) + activeVbo = 0; + if (activeEbo == vbo) + activeEbo = 0; + } + + void ReleaseProgram(GLuint program) { + if (activeProgram == program) + activeProgram = 0; + } + + void ReleaseTexture(GLuint texture) { + for (auto& activeTex : activeTexture) { + if (activeTex == texture) + activeTex = 0; + } + } + } oglState; +enum class GlResourceType { + Vbo, + Vao, + Texture, + Fbo, + Program, + None, +}; + +class GlResource { + GlResourceType type = GlResourceType::None; + GLuint res = 0; +public: + GlResource() = default; + + GlResource(GLuint resource, GlResourceType resType) noexcept : res(resource), type(resType) {} + + GlResource(const GlResource&) = delete; + + GlResource(GlResource&& rhs) noexcept { + std::swap(this->res, rhs.res); + std::swap(this->type, rhs.type); + } + + GlResource& operator=(const GlResource&) = delete; + + GlResource& operator=(GlResource&& rhs) noexcept { + std::swap(this->res, rhs.res); + std::swap(this->type, rhs.type); + return *this; + } + + ~GlResource() { + switch (type) { + case GlResourceType::Vbo: + oglState.ReleaseVbo(res); + glDeleteBuffers(1, &res); + break; + case GlResourceType::Vao: + oglState.ReleaseVao(res); + glDeleteVertexArrays(1, &res); + break; + case GlResourceType::Texture: + oglState.ReleaseTexture(res); + glDeleteTextures(1, &res); + break; + case GlResourceType::Fbo: + oglState.ReleaseFbo(res); + glDeleteFramebuffers(1, &res); + break; + case GlResourceType::Program: + oglState.ReleaseProgram(res); + glDeleteProgram(res); + break; + case GlResourceType::None: + default: + break; + } + } + + operator GLuint() const noexcept { + return res; + } + + GLuint Get() const noexcept { + return res; + } +}; + std::unique_ptr impl; std::shared_ptr fbDefault; std::shared_ptr spbDefault; -- cgit v1.2.3 From a12779bc153425407b131bce541c0bb97cccca39 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Wed, 8 Dec 2021 20:33:09 +0500 Subject: Removed unnecessary framebuffers copying --- src/GalOgl.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/GalOgl.cpp') diff --git a/src/GalOgl.cpp b/src/GalOgl.cpp index 6452a44..94c2146 100644 --- a/src/GalOgl.cpp +++ b/src/GalOgl.cpp @@ -683,6 +683,10 @@ struct TextureOgl : public Texture { size_t width, height, depth; bool linear; + virtual std::tuple GetSize() override { + return { width, height, depth }; + } + virtual void SetData(std::vector&& data, size_t mipLevel = 0) override { size_t expectedSize = width * height * depth * GalFormatGetSize(format); if (data.size() != expectedSize && !data.empty()) -- cgit v1.2.3 From 9202a3cab793a239a084414e4dddc7759f479fc2 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sat, 11 Dec 2021 22:11:31 +0500 Subject: Even more optimization to GBuffer size --- src/GalOgl.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/GalOgl.cpp') diff --git a/src/GalOgl.cpp b/src/GalOgl.cpp index 94c2146..b046d4b 100644 --- a/src/GalOgl.cpp +++ b/src/GalOgl.cpp @@ -358,8 +358,14 @@ size_t GalFormatGetSize(Format format) { switch (format) { case Format::D24S8: return 4; + case Format::R8: + return 1; + case Format::R8G8: + return 2; case Format::R8G8B8: return 3; + case Format::R8G8B8SN: + return 3; case Format::R8G8B8A8: return 4; case Format::R32G32B32A32F: @@ -374,8 +380,14 @@ GLenum GalFormatGetGlLinearInternalFormat(Format format) { switch (format) { case Format::D24S8: return GL_DEPTH24_STENCIL8; + case Format::R8: + return GL_R8; + case Format::R8G8: + return GL_RG8; case Format::R8G8B8: return GL_RGB8; + case Format::R8G8B8SN: + return GL_RGB8_SNORM; case Format::R8G8B8A8: return GL_RGBA8; case Format::R32G32B32A32F: @@ -390,8 +402,14 @@ GLenum GalFormatGetGlInternalFormat(Format format) { switch (format) { case Format::D24S8: return 0; + case Format::R8: + return 0; + case Format::R8G8: + return 0; case Format::R8G8B8: return GL_SRGB; + case Format::R8G8B8SN: + return 0; case Format::R8G8B8A8: return GL_SRGB_ALPHA; case Format::R32G32B32A32F: @@ -406,8 +424,14 @@ GLenum GalFormatGetGlFormat(Format format) { switch (format) { case Format::D24S8: return GL_DEPTH_STENCIL; + case Format::R8: + return GL_RED; + case Format::R8G8: + return GL_RG; case Format::R8G8B8: return GL_RGB; + case Format::R8G8B8SN: + return GL_RGB; case Format::R8G8B8A8: return GL_RGBA; case Format::R32G32B32A32F: @@ -422,8 +446,14 @@ GLenum GalFormatGetGlType(Format format) { switch (format) { case Format::D24S8: return GL_UNSIGNED_INT_24_8; + case Format::R8: + return GL_UNSIGNED_BYTE; + case Format::R8G8: + return GL_UNSIGNED_BYTE; case Format::R8G8B8: return GL_UNSIGNED_BYTE; + case Format::R8G8B8SN: + return GL_BYTE; case Format::R8G8B8A8: return GL_UNSIGNED_BYTE; case Format::R32G32B32A32F: -- cgit v1.2.3