mirror of
https://github.com/wiiu-env/libgui.git
synced 2024-11-15 04:45:06 +01:00
Introduce Supersampling Anti-Aliasing
This changes GuiText::internatRenderingScale to int32_t as it doesn't make much sense to have floating point SSAA values. Also you might want to check if the entered value is valid instead of lazy setting it Signed-off-by: Thomas Rohloff <v10lator@myway.de>
This commit is contained in:
parent
f3f369029c
commit
fea73ae1d3
@ -29,12 +29,12 @@ public:
|
|||||||
//!\param t Text
|
//!\param t Text
|
||||||
//!\param s Font size
|
//!\param s Font size
|
||||||
//!\param c Font color
|
//!\param c Font color
|
||||||
GuiText(const char * t, int32_t s, const glm::vec4 & c);
|
GuiText(const char * t, int32_t s, const glm::vec4 & c, int32_t SSAA);
|
||||||
//!\overload
|
//!\overload
|
||||||
//!\param t Text
|
//!\param t Text
|
||||||
//!\param s Font size
|
//!\param s Font size
|
||||||
//!\param c Font color
|
//!\param c Font color
|
||||||
GuiText(const wchar_t * t, int32_t s, const glm::vec4 & c);
|
GuiText(const wchar_t * t, int32_t s, const glm::vec4 & c, int32_t SSAA);
|
||||||
//!\overload
|
//!\overload
|
||||||
//!\Assumes SetPresets() has been called to setup preferred text attributes
|
//!\Assumes SetPresets() has been called to setup preferred text attributes
|
||||||
//!\param t Text
|
//!\param t Text
|
||||||
@ -53,8 +53,11 @@ public:
|
|||||||
//!\param w Maximum width of texture image (for text wrapping)
|
//!\param w Maximum width of texture image (for text wrapping)
|
||||||
//!\param wrap Wrapmode when w>0
|
//!\param wrap Wrapmode when w>0
|
||||||
//!\param a Text alignment
|
//!\param a Text alignment
|
||||||
static void setPresets(int32_t sz, const glm::vec4 & c, int32_t w, int32_t a);
|
static void setPresets(int32_t sz, const glm::vec4 & c, int32_t w, int32_t a, int32_t SSAA);
|
||||||
static void setPresetFont(FreeTypeGX *font);
|
static void setPresetFont(FreeTypeGX *font);
|
||||||
|
//!Sets Supersampling Anti-Aliasing
|
||||||
|
//!\param SSAA Valid values are: 1, 2, 4, 8, 16, 32
|
||||||
|
void setSSAA(int32_t SSAA);
|
||||||
//!Sets the font size
|
//!Sets the font size
|
||||||
//!\param s Font size
|
//!\param s Font size
|
||||||
void setFontSize(int32_t s);
|
void setFontSize(int32_t s);
|
||||||
@ -118,7 +121,7 @@ protected:
|
|||||||
static FreeTypeGX * presentFont;
|
static FreeTypeGX * presentFont;
|
||||||
static int32_t presetSize;
|
static int32_t presetSize;
|
||||||
static int32_t presetMaxWidth;
|
static int32_t presetMaxWidth;
|
||||||
static float presetInternalRenderingScale;
|
static int32_t presetInternalRenderingScale;
|
||||||
static int32_t presetAlignment;
|
static int32_t presetAlignment;
|
||||||
static GX2ColorF32 presetColor;
|
static GX2ColorF32 presetColor;
|
||||||
|
|
||||||
@ -149,7 +152,7 @@ protected:
|
|||||||
float blurGlowIntensity;
|
float blurGlowIntensity;
|
||||||
float blurAlpha;
|
float blurAlpha;
|
||||||
glm::vec4 blurGlowColor;
|
glm::vec4 blurGlowColor;
|
||||||
float internalRenderingScale;
|
int32_t internalRenderingScale;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -160,7 +160,7 @@ void GuiSelectBox::Init(std::map<std::string,std::string> values, int32_t valueI
|
|||||||
valueButtons[i].valueButtonHighlightedImg = new GuiImage(valueHighlightedImageData);
|
valueButtons[i].valueButtonHighlightedImg = new GuiImage(valueHighlightedImageData);
|
||||||
|
|
||||||
valueButtons[i].valueButton = new GuiButton(valueButtons[i].valueButtonImg->getWidth() * imgScale, valueButtons[i].valueButtonImg->getHeight() * imgScale);
|
valueButtons[i].valueButton = new GuiButton(valueButtons[i].valueButtonImg->getWidth() * imgScale, valueButtons[i].valueButtonImg->getHeight() * imgScale);
|
||||||
valueButtons[i].valueButtonText = new GuiText(itr->first.c_str(),32,glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
|
valueButtons[i].valueButtonText = new GuiText(itr->first.c_str(),32,glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), 1);
|
||||||
|
|
||||||
valueButtons[i].valueButtonText->setMaxWidth(valueButtons[i].valueButtonImg->getWidth() * imgScale - 20.0f, GuiText::WRAP);
|
valueButtons[i].valueButtonText->setMaxWidth(valueButtons[i].valueButtonImg->getWidth() * imgScale - 20.0f, GuiText::WRAP);
|
||||||
valueButtons[i].valueButtonText->setPosition(0, 0);
|
valueButtons[i].valueButtonText->setPosition(0, 0);
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
FreeTypeGX * GuiText::presentFont = NULL;
|
FreeTypeGX * GuiText::presentFont = NULL;
|
||||||
int32_t GuiText::presetSize = 28;
|
int32_t GuiText::presetSize = 28;
|
||||||
float GuiText::presetInternalRenderingScale = 1.0f;
|
int32_t GuiText::presetInternalRenderingScale = 1;
|
||||||
int32_t GuiText::presetMaxWidth = 0xFFFF;
|
int32_t GuiText::presetMaxWidth = 0xFFFF;
|
||||||
int32_t GuiText::presetAlignment = ALIGN_CENTER | ALIGN_MIDDLE;
|
int32_t GuiText::presetAlignment = ALIGN_CENTER | ALIGN_MIDDLE;
|
||||||
GX2ColorF32 GuiText::presetColor = (GX2ColorF32) {
|
GX2ColorF32 GuiText::presetColor = (GX2ColorF32) {
|
||||||
@ -57,7 +57,7 @@ GuiText::GuiText() {
|
|||||||
internalRenderingScale = presetInternalRenderingScale;
|
internalRenderingScale = presetInternalRenderingScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiText::GuiText(const char * t, int32_t s, const glm::vec4 & c) {
|
GuiText::GuiText(const char * t, int32_t s, const glm::vec4 & c, int32_t SSAA) {
|
||||||
text = NULL;
|
text = NULL;
|
||||||
size = s;
|
size = s;
|
||||||
currentSize = size;
|
currentSize = size;
|
||||||
@ -76,7 +76,7 @@ GuiText::GuiText(const char * t, int32_t s, const glm::vec4 & c) {
|
|||||||
blurGlowIntensity = 0.0f;
|
blurGlowIntensity = 0.0f;
|
||||||
blurAlpha = 0.0f;
|
blurAlpha = 0.0f;
|
||||||
blurGlowColor = glm::vec4(0.0f);
|
blurGlowColor = glm::vec4(0.0f);
|
||||||
internalRenderingScale = presetInternalRenderingScale;
|
internalRenderingScale = SSAA;
|
||||||
|
|
||||||
if(t) {
|
if(t) {
|
||||||
text = FreeTypeGX::charToWideChar(t);
|
text = FreeTypeGX::charToWideChar(t);
|
||||||
@ -87,7 +87,7 @@ GuiText::GuiText(const char * t, int32_t s, const glm::vec4 & c) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiText::GuiText(const wchar_t * t, int32_t s, const glm::vec4 & c) {
|
GuiText::GuiText(const wchar_t * t, int32_t s, const glm::vec4 & c, int32_t SSAA) {
|
||||||
text = NULL;
|
text = NULL;
|
||||||
size = s;
|
size = s;
|
||||||
currentSize = size;
|
currentSize = size;
|
||||||
@ -106,7 +106,7 @@ GuiText::GuiText(const wchar_t * t, int32_t s, const glm::vec4 & c) {
|
|||||||
blurGlowIntensity = 0.0f;
|
blurGlowIntensity = 0.0f;
|
||||||
blurAlpha = 0.0f;
|
blurAlpha = 0.0f;
|
||||||
blurGlowColor = glm::vec4(0.0f);
|
blurGlowColor = glm::vec4(0.0f);
|
||||||
internalRenderingScale = presetInternalRenderingScale;
|
internalRenderingScale = SSAA;
|
||||||
|
|
||||||
if(t) {
|
if(t) {
|
||||||
text = new (std::nothrow) wchar_t[wcslen(t)+1];
|
text = new (std::nothrow) wchar_t[wcslen(t)+1];
|
||||||
@ -233,19 +233,24 @@ void GuiText::clearDynamicText() {
|
|||||||
textDynWidth.clear();
|
textDynWidth.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiText::setPresets(int32_t sz, const glm::vec4 & c, int32_t w, int32_t a) {
|
void GuiText::setPresets(int32_t sz, const glm::vec4 & c, int32_t w, int32_t a, int32_t SSAA) {
|
||||||
presetSize = sz;
|
presetSize = sz;
|
||||||
presetColor = (GX2ColorF32) {
|
presetColor = (GX2ColorF32) {
|
||||||
(float)c.r / 255.0f, (float)c.g / 255.0f, (float)c.b / 255.0f, (float)c.a / 255.0f
|
(float)c.r / 255.0f, (float)c.g / 255.0f, (float)c.b / 255.0f, (float)c.a / 255.0f
|
||||||
};
|
};
|
||||||
presetMaxWidth = w;
|
presetMaxWidth = w;
|
||||||
presetAlignment = a;
|
presetAlignment = a;
|
||||||
|
presetInternalRenderingScale = SSAA;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiText::setPresetFont(FreeTypeGX *f) {
|
void GuiText::setPresetFont(FreeTypeGX *f) {
|
||||||
presentFont = f;
|
presentFont = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GuiText::setSSAA(int32_t SSAA) {
|
||||||
|
internalRenderingScale = SSAA;
|
||||||
|
}
|
||||||
|
|
||||||
void GuiText::setFontSize(int32_t s) {
|
void GuiText::setFontSize(int32_t s) {
|
||||||
size = s;
|
size = s;
|
||||||
}
|
}
|
||||||
@ -491,7 +496,7 @@ void GuiText::draw(CVideo *pVideo) {
|
|||||||
color[3] = getAlpha();
|
color[3] = getAlpha();
|
||||||
blurGlowColor[3] = blurAlpha * getAlpha();
|
blurGlowColor[3] = blurAlpha * getAlpha();
|
||||||
|
|
||||||
float finalRenderingScale = 2.0f * internalRenderingScale;
|
float finalRenderingScale = internalRenderingScale << 1;
|
||||||
|
|
||||||
int32_t newSize = size * getScale() * finalRenderingScale;
|
int32_t newSize = size * getScale() * finalRenderingScale;
|
||||||
int32_t normal_size = size * getScale();
|
int32_t normal_size = size * getScale();
|
||||||
|
Loading…
Reference in New Issue
Block a user