Fixes + Revisions to last commit

This commit is contained in:
J-D-K 2023-06-04 20:15:27 -04:00
parent 85bca2d66e
commit 1ac23d2750
10 changed files with 30 additions and 24 deletions

View File

@ -25,6 +25,7 @@ namespace gfx
SDL_Texture *textureCreate(int _w, int _h);
SDL_Texture *textureLoadFromFile(const char *_path);
SDL_Texture *textureLoadFromMem(imgTypes _type, const void *_dat, size_t _datSize);
void textureResize(SDL_Texture **_tex, int _w, int _h);
private:
std::vector<SDL_Texture *> textures;

View File

@ -14,7 +14,6 @@ namespace ui
{
public:
slideOutPanel(int _w, int _h, int _y, slidePanelOrientation _side, funcPtr _draw);
~slideOutPanel();
void resizePanel(int _w, int _h, int _y);
void update();

View File

@ -360,9 +360,7 @@ void data::init()
void data::exit()
{
for(data::user& u : data::users) u.delIcon();
for(auto& tinfo : titles)
SDL_DestroyTexture(tinfo.second.icon);
/*Still needed for planned future revisions*/
}
void data::setUserIndex(unsigned _sUser)

View File

@ -106,14 +106,20 @@ void gfx::init()
gfx::texMgr = new gfx::textureMgr;
loadSystemFont();
//This is to avoid blank, black glyphs
for(unsigned i = 0x20; i < 0x7E; i++)
gfx::drawTextf(NULL, 18, 32, 32, &ui::txtCont, "%c", i);
}
void gfx::exit()
{
delete gfx::texMgr;
SDL_DestroyRenderer(gfx::render);
SDL_DestroyWindow(wind);
IMG_Quit();
SDL_Quit();
freeSystemFont();
delete gfx::texMgr;
}
void gfx::present()

View File

@ -1,4 +1,5 @@
#include <vector>
#include <algorithm>
#include <SDL2/SDL.h>
#include <SDL_image.h>
@ -18,9 +19,12 @@ void gfx::textureMgr::textureAdd(SDL_Texture *_tex)
SDL_Texture *gfx::textureMgr::textureCreate(int _w, int _h)
{
SDL_Texture *ret = NULL;
ret = SDL_CreateTexture(gfx::render, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STATIC, _w, _h);
ret = SDL_CreateTexture(gfx::render, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET, _w, _h);
if(ret)
{
SDL_SetTextureBlendMode(ret, SDL_BLENDMODE_BLEND);
textures.push_back(ret);
}
return ret;
}
@ -106,3 +110,15 @@ SDL_Texture *gfx::textureMgr::textureLoadFromMem(imgTypes _type, const void *_da
return ret;
}
void gfx::textureMgr::textureResize(SDL_Texture **_tex, int _w, int _h)
{
auto texIt = std::find(textures.begin(), textures.end(), *_tex);
if(texIt != textures.end())
{
SDL_DestroyTexture(*texIt);
*_tex = SDL_CreateTexture(gfx::render, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET, _w, _h);
SDL_SetTextureBlendMode(*_tex, SDL_BLENDMODE_BLEND);
*texIt = *_tex;
}
}

View File

@ -290,7 +290,6 @@ void ui::fldExit()
delete ui::fldPanel;
delete fldMenu;
delete fldList;
SDL_DestroyTexture(fldBuffer);
}
void ui::fldUpdate()

View File

@ -32,8 +32,7 @@ ui::menu::menu(const int& _x, const int& _y, const int& _rW, const int& _fS, con
rH = _fS + 30;
spcWidth = gfx::getTextWidth(" ", _fS) * 3;
optTex = SDL_CreateTexture(gfx::render, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET, rW - 24, rH - 8);
SDL_SetTextureBlendMode(optTex, SDL_BLENDMODE_BLEND);
optTex = gfx::texMgr->textureCreate(rW - 24, rH - 8);
}
void ui::menu::editParam(int _param, int newVal)
@ -110,7 +109,6 @@ int ui::menu::getOptPos(const std::string& txt)
ui::menu::~menu()
{
SDL_DestroyTexture(optTex);
opt.clear();
}

View File

@ -15,13 +15,7 @@ ui::slideOutPanel::slideOutPanel(int _w, int _h, int _y, ui::slidePanelOrientati
x = 1280;
drawFunc = _draw;
panel = SDL_CreateTexture(gfx::render, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET, w, h);
SDL_SetTextureBlendMode(panel, SDL_BLENDMODE_BLEND);
}
ui::slideOutPanel::~slideOutPanel()
{
SDL_DestroyTexture(panel);
panel = gfx::texMgr->textureCreate(w, h);
}
void ui::slideOutPanel::resizePanel(int _w, int _h, int _y)
@ -32,9 +26,7 @@ void ui::slideOutPanel::resizePanel(int _w, int _h, int _y)
if(sldSide == ui::SLD_LEFT)
x = -w;
SDL_DestroyTexture(panel);
panel = SDL_CreateTexture(gfx::render, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET, w, h);
SDL_SetTextureBlendMode(panel, SDL_BLENDMODE_BLEND);
gfx::texMgr->textureResize(&panel, w, h);
}
void ui::slideOutPanel::update()

View File

@ -444,9 +444,6 @@ void ui::usrExit()
delete deviceSaveMenu;
delete bcatSaveMenu;
delete cacheSaveMenu;
SDL_DestroyTexture(sett);
SDL_DestroyTexture(ext);
}
void ui::usrRefresh()

View File

@ -290,7 +290,7 @@ void util::replaceButtonsInString(std::string& rep)
SDL_Texture *util::createIconGeneric(const char *txt, int fontSize, bool clearBack)
{
SDL_Texture *ret = SDL_CreateTexture(gfx::render, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET, 256, 256);
SDL_Texture *ret = gfx::texMgr->textureCreate(256, 256);
SDL_SetRenderTarget(gfx::render, ret);
if(clearBack)
{