mirror of
https://github.com/Maschell/SDL2_Playground.git
synced 2024-06-03 07:58:49 +02:00
Fix running on Wii U
This commit is contained in:
parent
4fbb83e4ad
commit
fd38530bc7
|
@ -26,10 +26,8 @@ GuiText::GuiText(const std::string& text, SDL_Color c, FC_Font* gFont) {
|
||||||
this->text = text;
|
this->text = text;
|
||||||
this->color = c;
|
this->color = c;
|
||||||
this->fc_font = gFont;
|
this->fc_font = gFont;
|
||||||
this->updateText = false;
|
|
||||||
|
|
||||||
updateSize();
|
updateSize();
|
||||||
updateTexture();
|
this->doUpdateTexture = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiText::~GuiText(){
|
GuiText::~GuiText(){
|
||||||
|
@ -45,6 +43,8 @@ void GuiText::draw(Renderer *renderer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateTexture(renderer);
|
||||||
|
|
||||||
if(texture){
|
if(texture){
|
||||||
texture->draw(renderer);
|
texture->draw(renderer);
|
||||||
}
|
}
|
||||||
|
@ -52,18 +52,13 @@ void GuiText::draw(Renderer *renderer) {
|
||||||
|
|
||||||
void GuiText::process() {
|
void GuiText::process() {
|
||||||
GuiElement::process();
|
GuiElement::process();
|
||||||
|
|
||||||
if(updateText && fc_font){
|
|
||||||
updateTexture();
|
|
||||||
updateText = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiText::setMaxWidth(float width) {
|
void GuiText::setMaxWidth(float width) {
|
||||||
this->maxWidth = width;
|
this->maxWidth = width;
|
||||||
|
|
||||||
// Rebuild the texture cache.
|
// Rebuild the texture cache.
|
||||||
updateText = true;
|
doUpdateTexture = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiText::updateSize() {
|
void GuiText::updateSize() {
|
||||||
|
@ -73,18 +68,21 @@ void GuiText::updateSize() {
|
||||||
this->setSize(width, height);
|
this->setSize(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiText::updateTexture() {
|
void GuiText::updateTexture(Renderer *renderer) {
|
||||||
updateSize();
|
if(!texture || doUpdateTexture) {
|
||||||
SDL_Texture* temp = FC_CreateTexture(fc_font, SDL_PIXELFORMAT_RGBA8888, width, height);
|
updateSize();
|
||||||
|
|
||||||
if(temp){
|
SDL_Texture *temp = SDL_CreateTexture(renderer->getRenderer(), renderer->getPixelFormat(), SDL_TEXTUREACCESS_TARGET, (int) width, (int) height);
|
||||||
delete texture;
|
if (temp) {
|
||||||
texture = new GuiTexture(temp);
|
delete texture;
|
||||||
texture->setParent(this);
|
texture = new GuiTexture(temp);
|
||||||
texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
texture->setParent(this);
|
||||||
|
texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||||
|
|
||||||
FC_DrawColumnToTexture(fc_font, temp, 0,0, maxWidth, text.c_str());
|
FC_DrawColumnToTexture(fc_font, temp, 0, 0, maxWidth, text.c_str());
|
||||||
}else{
|
doUpdateTexture = false;
|
||||||
DEBUG_FUNCTION_LINE("Failed to create texture");
|
} else {
|
||||||
|
DEBUG_FUNCTION_LINE("Failed to create texture");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,11 +43,11 @@ protected:
|
||||||
std::string text;
|
std::string text;
|
||||||
SDL_Color color;
|
SDL_Color color;
|
||||||
FC_Font *fc_font = nullptr;
|
FC_Font *fc_font = nullptr;
|
||||||
bool updateText = true;
|
bool doUpdateTexture = true;
|
||||||
|
|
||||||
uint16_t maxWidth = 0xFFFF;
|
uint16_t maxWidth = 0xFFFF;
|
||||||
|
|
||||||
void updateSize();
|
void updateSize();
|
||||||
|
|
||||||
void updateTexture();
|
void updateTexture(Renderer *renderer);
|
||||||
};
|
};
|
||||||
|
|
|
@ -174,7 +174,6 @@ int main(int argc, char *args[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete frame;
|
delete frame;
|
||||||
|
|
|
@ -455,10 +455,6 @@ struct FC_Font
|
||||||
|
|
||||||
std::recursive_mutex mutex;
|
std::recursive_mutex mutex;
|
||||||
|
|
||||||
SDL_Texture* FC_CreateTexture(FC_Font *pFont, uint32_t pixelFormat, float width, float height) {
|
|
||||||
return SDL_CreateTexture(pFont->renderer, pixelFormat, SDL_TEXTUREACCESS_TARGET, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Private
|
// Private
|
||||||
static FC_GlyphData* FC_PackGlyphData(FC_Font* font, Uint32 codepoint, Uint16 width, Uint16 maxWidth, Uint16 maxHeight);
|
static FC_GlyphData* FC_PackGlyphData(FC_Font* font, Uint32 codepoint, Uint16 width, Uint16 maxWidth, Uint16 maxHeight);
|
||||||
|
|
||||||
|
|
|
@ -121,8 +121,6 @@ FC_Effect FC_MakeEffect(FC_AlignEnum alignment, FC_Scale scale, SDL_Color color)
|
||||||
|
|
||||||
FC_GlyphData FC_MakeGlyphData(int cache_level, Sint16 x, Sint16 y, Uint16 w, Uint16 h);
|
FC_GlyphData FC_MakeGlyphData(int cache_level, Sint16 x, Sint16 y, Uint16 w, Uint16 h);
|
||||||
|
|
||||||
SDL_Texture* FC_CreateTexture(FC_Font *pFont, uint32_t pixelFormat, float width, float height);
|
|
||||||
|
|
||||||
// Font object
|
// Font object
|
||||||
|
|
||||||
FC_Font* FC_CreateFont(void);
|
FC_Font* FC_CreateFont(void);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user