light/modules/renderer/private/gl/blender.cpp

47 lines
1.4 KiB
C++
Raw Normal View History

#include <glad/gl.h>
2025-07-11 14:05:59 +03:30
#include <renderer/gl/blender.hpp>
2021-07-09 11:56:31 +04:30
2025-07-11 00:05:48 +03:30
namespace lt {
2021-07-09 11:56:31 +04:30
2022-03-08 21:19:19 +03:30
glBlender::glBlender()
: m_factor_map { // constants
2025-07-11 14:05:59 +03:30
{ BlendFactor::ZERO, GL_ZERO },
{ BlendFactor::ONE, GL_ONE },
2022-03-08 21:19:19 +03:30
2025-07-11 14:05:59 +03:30
// source ,
{ BlendFactor::SRC_COLOR, GL_SRC_COLOR },
{ BlendFactor::INVERSE_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR },
2022-03-08 21:19:19 +03:30
2025-07-11 14:05:59 +03:30
{ BlendFactor::SRC_ALPHA, GL_SRC_ALPHA },
{ BlendFactor::INVERSE_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA },
2022-03-08 21:19:19 +03:30
2025-07-11 14:05:59 +03:30
// destination ,
{ BlendFactor::DST_COLOR, GL_DST_COLOR },
{ BlendFactor::INVERSE_DST_COLOR, GL_ONE_MINUS_DST_COLOR },
2022-03-08 21:19:19 +03:30
2025-07-11 14:05:59 +03:30
{ BlendFactor::DST_ALPHA, GL_DST_ALPHA },
{ BlendFactor::INVERSE_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA },
2022-03-08 21:19:19 +03:30
2025-07-11 14:05:59 +03:30
// source1 ,
{ BlendFactor::SRC1_COLOR, GL_SRC1_COLOR },
{ BlendFactor::INVERSE_SRC1_COLOR, GL_ONE_MINUS_SRC1_COLOR },
2022-03-08 21:19:19 +03:30
2025-07-11 14:05:59 +03:30
{ BlendFactor::SRC1_ALPHA, GL_SRC1_ALPHA },
{ BlendFactor::INVERSE_SRC1_ALPHA, GL_ONE_MINUS_SRC_ALPHA }
2022-03-08 21:19:19 +03:30
}
{
}
void glBlender::enable(BlendFactor srcFactor, BlendFactor dstFactor)
2022-03-08 21:19:19 +03:30
{
glEnable(GL_BLEND);
glBlendFunc(m_factor_map.at(srcFactor), m_factor_map.at(dstFactor));
2022-03-08 21:19:19 +03:30
}
void glBlender::disable()
2022-03-08 21:19:19 +03:30
{
glDisable(GL_BLEND);
}
2025-07-11 00:05:48 +03:30
} // namespace lt