diff --git a/src/dawn/display/RenderPipeline.cpp b/src/dawn/display/RenderPipeline.cpp index 9cce4562..10c0d6ad 100644 --- a/src/dawn/display/RenderPipeline.cpp +++ b/src/dawn/display/RenderPipeline.cpp @@ -19,82 +19,6 @@ RenderPipeline::RenderPipeline(RenderManager *renderManager) { } void RenderPipeline::init() { - // FT_Face face; - // if(FT_New_Face(ft, "C:\\Windows\\Fonts\\Arial.ttf", 0, &face)) { - // std::cout << "ERROR::FREETYPE: Failed to load font" << std::endl; - // assertUnreachable(); - // } - // // TESTING FONT - // // glGenTextures(1, &texture); - // // glBindTexture(GL_TEXTURE_2D, texture); - // // glTexImage2D( - // // GL_TEXTURE_2D, - // // 0, - // // GL_RED, - // // face->glyph->bitmap.width, - // // face->glyph->bitmap.rows, - // // 0, - // // GL_RED, - // // GL_UNSIGNED_BYTE, - // // face->glyph->bitmap.buffer - // // ); - // // // set texture options - // // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - // // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - // // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - // // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - // Mesh glyphMesh; - // FT_Set_Pixel_Sizes(face, 0, 36); - // FT_UInt glyph_index = FT_Get_Char_Index(face, 'B'); - // auto error = FT_Load_Glyph( - // face, /* handle to face object */ - // glyph_index, /* glyph index */ - // FT_LOAD_DEFAULT ); /* load flags, see below */ - // if(error) { - // std::cout << "Error loading glyph" << std::endl; - // assertUnreachable(); - // } - - // /* convert to an anti-aliased bitmap */ - // error = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL ); - // if(error) { - // std::cout << "Error rendering glyph" << std::endl; - // assertUnreachable(); - // } - - // // Shader - // auto shdr = &this->renderManager->simpleTexturedShader->program; - // shdr->bind(); - // shdr->setMatrix(shdr->paramProjection, camera->getProjection()); - // shdr->setMatrix(shdr->paramView, camera->transform->getWorldTransform()); - // shdr->setMatrix(shdr->paramModel, glm::mat4(1.0f)); - // shdr->setColor(shdr->paramColor, COLOR_WHITE); - - // // Texture - // Texture texture; - // texture.setSize( - // face->glyph->bitmap.width, - // face->glyph->bitmap.rows, - // TEXTURE_FORMAT_R - // ); - // texture.wrapModeX = TEXTURE_WRAP_MODE_CLAMP_TO_EDGE; - // texture.wrapModeY = TEXTURE_WRAP_MODE_CLAMP_TO_EDGE; - // texture.buffer((uint8_t*)face->glyph->bitmap.buffer); - - // shdr->setBoolean(shdr->paramHasTexture, true); - // shdr->setTexture(shdr->paramTexture, 0); - // texture.bind(0); - - // this->renderManager->setRenderFlags(RENDER_MANAGER_RENDER_FLAG_DEPTH_TEST | RENDER_MANAGER_RENDER_FLAG_BLEND); - - // auto faceCloneForDebugging = face; - // QuadMesh::initQuadMesh(&glyphMesh, - // glm::vec2(face->glyph->bitmap.width, face->glyph->bitmap.rows), glm::vec2(1, 0), - // glm::vec2(0, 0), glm::vec2(0, 1), - // 0.0f - // ); - // glyphMesh.draw(MESH_DRAW_MODE_TRIANGLES, 0, -1); - this->shaderBuffer.init(); } diff --git a/src/dawnopengl/display/RenderManager.cpp b/src/dawnopengl/display/RenderManager.cpp index b2f5e30e..6a18cf80 100644 --- a/src/dawnopengl/display/RenderManager.cpp +++ b/src/dawnopengl/display/RenderManager.cpp @@ -32,7 +32,7 @@ void RenderManager::init() { // Prepare the initial values glEnable(GL_TEXTURE_2D); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glDepthMask(GL_TRUE); glDepthFunc(GL_LESS); } diff --git a/src/dawnopengl/display/shader/shaders/UIShader.hpp b/src/dawnopengl/display/shader/shaders/UIShader.hpp index bc64e1fe..99aa4e44 100644 --- a/src/dawnopengl/display/shader/shaders/UIShader.hpp +++ b/src/dawnopengl/display/shader/shaders/UIShader.hpp @@ -7,7 +7,7 @@ #include "display/shader/Shader.hpp" #include "display/shader/buffers/RenderPipelineShaderBuffer.hpp" -#define UI_SHADER_PROGRAM_PRIORITY 100 +#define UI_SHADER_PROGRAM_PRIORITY 1000 namespace Dawn { struct UICanvasShaderParameterBufferData { diff --git a/src/dawnopengl/scene/components/display/material/SimpleTexturedMaterial.cpp b/src/dawnopengl/scene/components/display/material/SimpleTexturedMaterial.cpp index f74235bd..de3eb4d9 100644 --- a/src/dawnopengl/scene/components/display/material/SimpleTexturedMaterial.cpp +++ b/src/dawnopengl/scene/components/display/material/SimpleTexturedMaterial.cpp @@ -36,9 +36,17 @@ std::vector SimpleTexturedMaterial::getRenderPasses(IRend onlyPass.matrixValues[shader->paramModel] = this->transform->getWorldTransform(); onlyPass.parameterBuffers[shader->bufferRenderPipeline] = &context.renderPipeline->shaderBuffer; - onlyPass.renderFlags = ( - RENDER_MANAGER_RENDER_FLAG_BLEND - ); + if(this->opaque) { + onlyPass.renderFlags = ( + RENDER_MANAGER_RENDER_FLAG_DEPTH_TEST + ); + } else { + onlyPass.priority = 100; + onlyPass.renderFlags = ( + RENDER_MANAGER_RENDER_FLAG_BLEND + ); + } + if(this->texture != nullptr) { onlyPass.boolValues[shader->paramHasTexture] = true; diff --git a/src/dawnopengl/scene/components/display/material/SimpleTexturedMaterial.hpp b/src/dawnopengl/scene/components/display/material/SimpleTexturedMaterial.hpp index 0a3c60e2..0978a412 100644 --- a/src/dawnopengl/scene/components/display/material/SimpleTexturedMaterial.hpp +++ b/src/dawnopengl/scene/components/display/material/SimpleTexturedMaterial.hpp @@ -17,6 +17,8 @@ namespace Dawn { Texture *texture = nullptr; // @optional struct Color color = COLOR_WHITE; + // @optional + bool_t opaque = true; /** * SimpleTexturedShader scene item component interface. diff --git a/src/dawntools/texturetool/TextureTool.cpp b/src/dawntools/texturetool/TextureTool.cpp index 4e65db9e..24f099d1 100644 --- a/src/dawntools/texturetool/TextureTool.cpp +++ b/src/dawntools/texturetool/TextureTool.cpp @@ -88,7 +88,7 @@ int32_t TextureTool::start() { STBIR_TYPE_UINT8, STBI_rgb_alpha, -1, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, - STBIR_FILTER_BOX, STBIR_FILTER_BOX, + STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, STBIR_COLORSPACE_LINEAR, NULL, s0, t0, s1, t1 ); @@ -108,7 +108,7 @@ int32_t TextureTool::start() { bufferCurrent, currentWidth, currentHeight, 0, bufferTemporary, scaleWidth, scaleHeight, 0, STBI_rgb_alpha, -1, 0, - STBIR_EDGE_CLAMP, STBIR_FILTER_TRIANGLE, STBIR_COLORSPACE_LINEAR, + STBIR_EDGE_CLAMP, STBIR_FILTER_DEFAULT, STBIR_COLORSPACE_LINEAR, NULL ); memcpy(bufferCurrent, bufferTemporary, sizeof(uint8_t) * len);