Merge remote-tracking branch 'origin/feature/hires-textures' into atys

ryzom/ui/improvements Live-834
Nuno 4 years ago
commit cc7793202b

@ -444,9 +444,13 @@ namespace NLGUI
SGlobalTexture () SGlobalTexture ()
{ {
FromGlobaleTexture = true; FromGlobaleTexture = true;
Scale = 1.f;
} }
uint32 Width, Height; uint32 Width, Height;
uint32 DefaultWidth, DefaultHeight; uint32 DefaultWidth, DefaultHeight;
// used by texture atlas to unscale individual texture
// getTextureSizeFromId() calls to return 1x size for GUI.
float Scale;
NL3D::UTexture *Texture; NL3D::UTexture *Texture;
std::string Name; std::string Name;
bool FromGlobaleTexture; bool FromGlobaleTexture;

@ -621,9 +621,7 @@ namespace NLGUI
return; return;
sint32 txw, txh; sint32 txw, txh;
SImage &rImage = *getSImage(nTxId); getTextureSizeFromId(nTxId, txw, txh);
txw = (sint32)((rImage.UVMax.U - rImage.UVMin.U)*rImage.GlobalTexturePtr->Width+0.5f);
txh = (sint32)((rImage.UVMax.V - rImage.UVMin.V)*rImage.GlobalTexturePtr->Height+0.5f);
drawRotFlipBitmap (layerId, x, y, txw, txh, rot, flipv, nTxId, col); drawRotFlipBitmap (layerId, x, y, txw, txh, rot, flipv, nTxId, col);
} }
@ -859,6 +857,14 @@ namespace NLGUI
CIFile ifTmp; CIFile ifTmp;
if (ifTmp.open(filename)) if (ifTmp.open(filename))
CBitmap::loadSize (ifTmp, gt.Width, gt.Height); CBitmap::loadSize (ifTmp, gt.Width, gt.Height);
// extract textures scale from filename
// texture_interface_v3_2x.tga / texture_interface_v3_4x.tga
if (textureFileName.find("_2x.") != std::string::npos)
gt.Scale = 2.f;
else if (textureFileName.find("_4x.") != std::string::npos)
gt.Scale = 4.f;
gt.Texture = driver->createTextureFile (filename); gt.Texture = driver->createTextureFile (filename);
// Force to generate the texture now. This way we can extract the mouse bitmaps from it now without having to load it again. // Force to generate the texture now. This way we can extract the mouse bitmaps from it now without having to load it again.
// Its why we don't release it at the end, because it is likely to be uploaded soon) // Its why we don't release it at the end, because it is likely to be uploaded soon)
@ -932,6 +938,10 @@ namespace NLGUI
CBitmap curs; CBitmap curs;
curs.resize(x1 - x0, y1 - y0); curs.resize(x1 - x0, y1 - y0);
curs.blit(*texDatas, x0, y0, (x1 - x0), (y1 - y0), 0, 0); curs.blit(*texDatas, x0, y0, (x1 - x0), (y1 - y0), 0, 0);
// TODO: scaled cursors not supported
if (gt.Scale > 1.f) {
curs.resample((sint)(curs.getWidth() / gt.Scale), (sint)(curs.getHeight() / gt.Scale));
}
driver->addCursor(image.Name, curs); driver->addCursor(image.Name, curs);
} }
} }
@ -1357,8 +1367,8 @@ namespace NLGUI
else else
{ {
SImage &rImage = *getSImage(id); SImage &rImage = *getSImage(id);
width = (sint32)((rImage.UVMax.U - rImage.UVMin.U)*rImage.GlobalTexturePtr->Width+0.5f); width = (sint32)(((rImage.UVMax.U - rImage.UVMin.U)*rImage.GlobalTexturePtr->Width / rImage.GlobalTexturePtr->Scale)+0.5f);
height = (sint32)((rImage.UVMax.V - rImage.UVMin.V)*rImage.GlobalTexturePtr->Height+0.5f); height = (sint32)(((rImage.UVMax.V - rImage.UVMin.V)*rImage.GlobalTexturePtr->Height / rImage.GlobalTexturePtr->Scale)+0.5f);
} }
} }
/* /*
@ -1373,9 +1383,11 @@ namespace NLGUI
SImage &rImage = *getSImage(id); SImage &rImage = *getSImage(id);
SGlobalTexture &rGT = *rImage.GlobalTexturePtr; SGlobalTexture &rGT = *rImage.GlobalTexturePtr;
// get (possibly) scaled width/height
sint32 width, height; sint32 width, height;
width = (sint32)((rImage.UVMax.U - rImage.UVMin.U)*rGT.Width+0.5f); getTextureSizeFromId(id, width, height);
height = (sint32)((rImage.UVMax.V - rImage.UVMin.V)*rGT.Height+0.5f); if (width == 0 || height == 0)
return CRGBA(255,255,255);
float xRatio = ((float)x) / ((float)(width)); float xRatio = ((float)x) / ((float)(width));
float yRatio = ((float)y) / ((float)(height)); float yRatio = ((float)y) / ((float)(height));
UTexture *pTF = rGT.Texture; UTexture *pTF = rGT.Texture;

Loading…
Cancel
Save