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->color = c;
|
||||
this->fc_font = gFont;
|
||||
this->updateText = false;
|
||||
|
||||
updateSize();
|
||||
updateTexture();
|
||||
this->doUpdateTexture = true;
|
||||
}
|
||||
|
||||
GuiText::~GuiText(){
|
||||
|
@ -45,6 +43,8 @@ void GuiText::draw(Renderer *renderer) {
|
|||
return;
|
||||
}
|
||||
|
||||
updateTexture(renderer);
|
||||
|
||||
if(texture){
|
||||
texture->draw(renderer);
|
||||
}
|
||||
|
@ -52,18 +52,13 @@ void GuiText::draw(Renderer *renderer) {
|
|||
|
||||
void GuiText::process() {
|
||||
GuiElement::process();
|
||||
|
||||
if(updateText && fc_font){
|
||||
updateTexture();
|
||||
updateText = false;
|
||||
}
|
||||
}
|
||||
|
||||
void GuiText::setMaxWidth(float width) {
|
||||
this->maxWidth = width;
|
||||
|
||||
// Rebuild the texture cache.
|
||||
updateText = true;
|
||||
doUpdateTexture = true;
|
||||
}
|
||||
|
||||
void GuiText::updateSize() {
|
||||
|
@ -73,18 +68,21 @@ void GuiText::updateSize() {
|
|||
this->setSize(width, height);
|
||||
}
|
||||
|
||||
void GuiText::updateTexture() {
|
||||
updateSize();
|
||||
SDL_Texture* temp = FC_CreateTexture(fc_font, SDL_PIXELFORMAT_RGBA8888, width, height);
|
||||
void GuiText::updateTexture(Renderer *renderer) {
|
||||
if(!texture || doUpdateTexture) {
|
||||
updateSize();
|
||||
|
||||
if(temp){
|
||||
delete texture;
|
||||
texture = new GuiTexture(temp);
|
||||
texture->setParent(this);
|
||||
texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||
SDL_Texture *temp = SDL_CreateTexture(renderer->getRenderer(), renderer->getPixelFormat(), SDL_TEXTUREACCESS_TARGET, (int) width, (int) height);
|
||||
if (temp) {
|
||||
delete texture;
|
||||
texture = new GuiTexture(temp);
|
||||
texture->setParent(this);
|
||||
texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||
|
||||
FC_DrawColumnToTexture(fc_font, temp, 0,0, maxWidth, text.c_str());
|
||||
}else{
|
||||
DEBUG_FUNCTION_LINE("Failed to create texture");
|
||||
FC_DrawColumnToTexture(fc_font, temp, 0, 0, maxWidth, text.c_str());
|
||||
doUpdateTexture = false;
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("Failed to create texture");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,11 +43,11 @@ protected:
|
|||
std::string text;
|
||||
SDL_Color color;
|
||||
FC_Font *fc_font = nullptr;
|
||||
bool updateText = true;
|
||||
bool doUpdateTexture = true;
|
||||
|
||||
uint16_t maxWidth = 0xFFFF;
|
||||
|
||||
void updateSize();
|
||||
|
||||
void updateTexture();
|
||||
void updateTexture(Renderer *renderer);
|
||||
};
|
||||
|
|
|
@ -174,7 +174,6 @@ int main(int argc, char *args[]) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
delete frame;
|
||||
|
|
|
@ -455,10 +455,6 @@ struct FC_Font
|
|||
|
||||
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
|
||||
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);
|
||||
|
||||
SDL_Texture* FC_CreateTexture(FC_Font *pFont, uint32_t pixelFormat, float width, float height);
|
||||
|
||||
// Font object
|
||||
|
||||
FC_Font* FC_CreateFont(void);
|
||||
|
|
Loading…
Reference in New Issue