Use floating point pixels for modulate color to allow lightening

This commit is contained in:
Dan Paulat 2024-01-13 01:01:01 -06:00
parent 9c8d851cf3
commit 87d2f84bde
4 changed files with 60 additions and 24 deletions

View file

@ -41,15 +41,15 @@ struct GeoIconDrawItem
std::chrono::sys_time<std::chrono::seconds> startTime_ {};
std::chrono::sys_time<std::chrono::seconds> endTime_ {};
boost::gil::rgba8_pixel_t modulate_ {255, 255, 255, 255};
double latitude_ {};
double longitude_ {};
double x_ {};
double y_ {};
units::degrees<double> angle_ {};
std::string iconSheet_ {};
std::size_t iconIndex_ {};
std::string hoverText_ {};
boost::gil::rgba32f_pixel_t modulate_ {1.0f, 1.0f, 1.0f, 1.0f};
double latitude_ {};
double longitude_ {};
double x_ {};
double y_ {};
units::degrees<double> angle_ {};
std::string iconSheet_ {};
std::size_t iconIndex_ {};
std::string hoverText_ {};
};
class GeoIcons::Impl
@ -419,6 +419,15 @@ void GeoIcons::SetIconAngle(const std::shared_ptr<GeoIconDrawItem>& di,
void GeoIcons::SetIconModulate(const std::shared_ptr<GeoIconDrawItem>& di,
boost::gil::rgba8_pixel_t modulate)
{
di->modulate_ = {modulate[0] / 255.0f,
modulate[1] / 255.0f,
modulate[2] / 255.0f,
modulate[3] / 255.0f};
}
void GeoIcons::SetIconModulate(const std::shared_ptr<GeoIconDrawItem>& di,
boost::gil::rgba32f_pixel_t modulate)
{
di->modulate_ = modulate;
}
@ -527,10 +536,10 @@ void GeoIcons::Impl::UpdateBuffers()
const float a = angle.value();
// Modulate color
const float mc0 = di->modulate_[0] / 255.0f;
const float mc1 = di->modulate_[1] / 255.0f;
const float mc2 = di->modulate_[2] / 255.0f;
const float mc3 = di->modulate_[3] / 255.0f;
const float mc0 = di->modulate_[0];
const float mc1 = di->modulate_[1];
const float mc2 = di->modulate_[2];
const float mc3 = di->modulate_[3];
newIconBuffer_.insert(newIconBuffer_.end(),
{

View file

@ -151,6 +151,15 @@ public:
static void SetIconModulate(const std::shared_ptr<GeoIconDrawItem>& di,
boost::gil::rgba8_pixel_t modulate);
/**
* Sets the modulate color of a geo icon.
*
* @param [in] di Geo icon draw item
* @param [in] modulate Modulate color
*/
static void SetIconModulate(const std::shared_ptr<GeoIconDrawItem>& di,
boost::gil::rgba32f_pixel_t modulate);
/**
* Sets the hover text of a geo icon.
*

View file

@ -34,13 +34,13 @@ static constexpr std::size_t kTextureBufferLength =
struct IconDrawItem
{
boost::gil::rgba8_pixel_t modulate_ {255, 255, 255, 255};
double x_ {};
double y_ {};
units::degrees<double> angle_ {};
std::string iconSheet_ {};
std::size_t iconIndex_ {};
std::string hoverText_ {};
boost::gil::rgba32f_pixel_t modulate_ {1.0f, 1.0f, 1.0f, 1.0f};
double x_ {};
double y_ {};
units::degrees<double> angle_ {};
std::string iconSheet_ {};
std::size_t iconIndex_ {};
std::string hoverText_ {};
};
class Icons::Impl
@ -314,6 +314,15 @@ void Icons::SetIconAngle(const std::shared_ptr<IconDrawItem>& di,
void Icons::SetIconModulate(const std::shared_ptr<IconDrawItem>& di,
boost::gil::rgba8_pixel_t modulate)
{
di->modulate_ = {modulate[0] / 255.0f,
modulate[1] / 255.0f,
modulate[2] / 255.0f,
modulate[3] / 255.0f};
}
void Icons::SetIconModulate(const std::shared_ptr<IconDrawItem>& di,
boost::gil::rgba32f_pixel_t modulate)
{
di->modulate_ = modulate;
}
@ -399,10 +408,10 @@ void Icons::Impl::UpdateBuffers()
const float a = angle.value();
// Modulate color
const float mc0 = di->modulate_[0] / 255.0f;
const float mc1 = di->modulate_[1] / 255.0f;
const float mc2 = di->modulate_[2] / 255.0f;
const float mc3 = di->modulate_[3] / 255.0f;
const float mc0 = di->modulate_[0];
const float mc1 = di->modulate_[1];
const float mc2 = di->modulate_[2];
const float mc3 = di->modulate_[3];
newIconBuffer_.insert(newIconBuffer_.end(),
{

View file

@ -128,6 +128,15 @@ public:
static void SetIconModulate(const std::shared_ptr<IconDrawItem>& di,
boost::gil::rgba8_pixel_t modulate);
/**
* Sets the modulate color of an icon.
*
* @param [in] di Icon draw item
* @param [in] modulate Modulate color
*/
static void SetIconModulate(const std::shared_ptr<IconDrawItem>& di,
boost::gil::rgba32f_pixel_t modulate);
/**
* Sets the hover text of an icon.
*