11#ifndef GAMP_WT_CAPABILITIES_HPP_
12#define GAMP_WT_CAPABILITIES_HPP_
35 constexpr static std::string_view
na_str =
"----";
45 bool m_backgroundOpaque =
true;
47 int m_xparentValueRed = 0;
48 int m_xparentValueGreen = 0;
49 int m_xparentValueBlue = 0;
50 int m_xparentValueAlpha = 0;
53 bool m_onscreen =
true;
56 bool m_isBitmap =
false;
75 size_t hash = 31U + m_redBits;
76 hash = ((hash << 5) - hash) + (m_onscreen ? 1U : 0U);
77 hash = ((hash << 5) - hash) + (m_isBitmap ? 1U : 0U);
78 hash = ((hash << 5) - hash) + m_greenBits;
79 hash = ((hash << 5) - hash) + m_blueBits;
80 hash = ((hash << 5) - hash) + m_alphaBits;
81 hash = ((hash << 5) - hash) + (m_backgroundOpaque ? 1U : 0U);
82 hash = ((hash << 5) - hash) + m_xparentValueRed;
83 hash = ((hash << 5) - hash) + m_xparentValueGreen;
84 hash = ((hash << 5) - hash) + m_xparentValueBlue;
85 hash = ((hash << 5) - hash) + m_xparentValueAlpha;
99 const int id_o = rhs.visualID();
104 bool res = rhs.redBits() == m_redBits &&
105 rhs.greenBits() == m_greenBits &&
106 rhs.blueBits() == m_blueBits &&
107 rhs.alphaBits() == m_alphaBits &&
108 rhs.isBackgroundOpaque() == m_backgroundOpaque &&
109 rhs.isOnscreen() == m_onscreen &&
110 rhs.isBitmap() == m_isBitmap;
111 if( res && !m_backgroundOpaque ) {
112 res = rhs.transparentRedValue() == m_xparentValueRed &&
113 rhs.transparentGreenValue() == m_xparentValueGreen &&
114 rhs.transparentBlueValue() == m_xparentValueBlue &&
115 rhs.transparentAlphaValue() == m_xparentValueAlpha;
136 const int rgba = m_redBits * m_greenBits * m_blueBits * (m_alphaBits + 1);
137 const int xrgba = rhs.redBits() * rhs.greenBits() * rhs.blueBits() * (rhs.alphaBits() + 1);
140 }
else if( rgba < xrgba ) {
148 return 0 == r ? std::strong_ordering::equal : (0 > r ? std::strong_ordering::less : std::strong_ordering::greater);
151 constexpr int visualID() const noexcept {
return m_vid; }
157 constexpr int redBits() const noexcept {
return m_redBits; }
163 constexpr int greenBits() const noexcept {
return m_greenBits; }
169 constexpr int blueBits() const noexcept {
return m_blueBits; }
175 constexpr int alphaBits() const noexcept {
return m_alphaBits; }
177 constexpr int&
visualID() noexcept {
return m_vid; }
182 constexpr int&
redBits() noexcept {
return m_redBits; }
187 constexpr int&
greenBits() noexcept {
return m_greenBits; }
192 constexpr int&
blueBits() noexcept {
return m_blueBits; }
206 constexpr int&
alphaBits() noexcept {
return m_alphaBits; }
224 m_backgroundOpaque = opaque;
263 constexpr bool isOnscreen() const noexcept {
return m_onscreen; }
293 constexpr bool isBitmap() const noexcept {
return m_isBitmap; }
347 std::string msg(
"Caps[");
349 return msg.append(
"]");
354 constexpr static std::string_view
ESEP =
"/";
356 constexpr static std::string_view
CSEP =
", ";
358 void toString(std::string& sink,
bool withOnOffScreen)
const {
359 sink.append(
"rgba ").append(std::to_string(m_redBits)).append(
ESEP).append(std::to_string(m_greenBits)).append(
ESEP).append(std::to_string(m_blueBits)).append(
ESEP).append(std::to_string(m_alphaBits));
360 if( m_backgroundOpaque ) {
361 sink.append(
", opaque");
365 if( withOnOffScreen ) {
368 sink.append(
"on-scr");
370 sink.append(
"offscr[");
373 sink.append(
"bitmap");
374 }
else if( m_onscreen ) {
377 sink.append(
"auto-cfg");
395 struct hash<
gamp::wt::Capabilities> {
397 return a.hash_code();
Specifies a set of capabilities that a window's rendering context must support, such as color depth p...
constexpr void setBitmap(bool enable) noexcept
Requesting offscreen bitmap mode.
constexpr int & transparentGreenValue() noexcept
Allows setting the transparent green value for the frame buffer configuration, ranging from 0 to the ...
constexpr int transparentBlueValue() const noexcept
Gets the transparent blue value for the frame buffer configuration.
constexpr int redBits() const noexcept
Returns the number of bits for the color buffer's red component.
constexpr int & transparentRedValue() noexcept
Allows setting the transparent red value for the frame buffer configuration, ranging from 0 to the ma...
static constexpr std::string_view ESEP
Element separator.
constexpr bool isOnscreen() const noexcept
Returns whether an on- or offscreen surface is requested, available or chosen.
constexpr int & blueBits() noexcept
Allows setting the number of bits requested for the color buffer's blue component.
constexpr int & visualID() noexcept
constexpr int & transparentAlphaValue() noexcept
Allows setting the transparent alpha value for the frame buffer configuration, ranging from 0 to the ...
constexpr int greenBits() const noexcept
Returns the number of bits for the color buffer's green component.
constexpr int visualID() const noexcept
constexpr int transparentRedValue() const noexcept
Gets the transparent red value for the frame buffer configuration.
constexpr int transparentAlphaValue() const noexcept
Gets the transparent alpha value for the frame buffer configuration.
std::strong_ordering operator<=>(const Capabilities &rhs) const noexcept
constexpr bool isBitmap() const noexcept
Returns whether bitmap offscreen mode is requested, available or chosen.
virtual int compare(const Capabilities &rhs) const noexcept
Comparing RGBA values only.
constexpr int & greenBits() noexcept
Allows setting the number of bits requested for the color buffer's green component.
void toString(std::string &sink, bool withOnOffScreen) const
static constexpr std::string_view CSEP
Component separator.
constexpr int blueBits() const noexcept
Returns the number of bits for the color buffer's blue component.
virtual std::size_t hash_code() const noexcept
constexpr void setBackgroundOpaque(bool opaque) noexcept
Sets whether the surface shall be opaque or translucent.
constexpr int & redBits() noexcept
Allows setting the number of bits requested for the color buffer's red component.
static constexpr std::string_view na_str
constexpr void setOnscreen(bool v) noexcept
Sets whether the surface shall be on- or offscreen.
constexpr int & alphaBits() noexcept
Allows setting the number of bits requested for the color buffer's alpha component.
virtual std::string toString() const
Returns a textual representation of this Capabilities object.
virtual CapabilitiesPtr clone() const noexcept
constexpr int & transparentBlueValue() noexcept
Allows setting the transparent blue value for the frame buffer configuration, ranging from 0 to the m...
constexpr int alphaBits() const noexcept
Returns the number of bits for the color buffer's alpha component.
virtual const jau::type_info & signature() const noexcept
virtual bool operator==(const Capabilities &rhs) const noexcept
constexpr bool isBackgroundOpaque() const noexcept
Returns whether an opaque or translucent surface is requested, supported or chosen.
constexpr Capabilities() noexcept=default
Creates a Capabilities object.
constexpr int transparentGreenValue() const noexcept
Gets the transparent green value for the frame buffer configuration.
const jau::type_info & static_ctti() noexcept
Returns a static global reference of make_ctti<T>(true) w/ identity instance.
std::unique_ptr< Capabilities > CapabilitiesPtr
std::string to_hexstring(value_type const &v, const bool skipLeading0x=false) noexcept
Produce a lower-case hexadecimal string representation with leading 0x in MSB of the given pointer.
Gamp: Graphics, Audio, Multimedia and Processing Framework (Native C++, WebAssembly,...
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
std::size_t operator()(gamp::wt::Capabilities const &a) const noexcept