mirror of
https://gitlab.com/shinovon/re3-symbian.git
synced 2026-05-22 17:47:20 +03:00
Now the TXD.img file is being created correctly, and the textures are reduced to half their size, saving a lot of memory and making the game run more smoothly. The game no longer crashes and it looks very good. That said, I still couldn’t increase the frame rate—it stays between 8 and 15 FPS, but usually runs around 8
This commit is contained in:
parent
39c75bb8c5
commit
6d9929b7ce
4 changed files with 189 additions and 107 deletions
|
|
@ -270,7 +270,7 @@ CStreaming::Init2(void)
|
|||
void
|
||||
CStreaming::Init(void)
|
||||
{
|
||||
/*#ifdef USE_TXD_CDIMAGE
|
||||
#ifdef USE_TXD_CDIMAGE
|
||||
int txdHandle = CFileMgr::OpenFile("MODELS\\TXD.IMG", "r");
|
||||
if (txdHandle)
|
||||
CFileMgr::CloseFile(txdHandle);
|
||||
|
|
@ -285,9 +285,9 @@ CStreaming::Init(void)
|
|||
CStreaming::Init2();
|
||||
}
|
||||
}
|
||||
#else*/
|
||||
#else
|
||||
CStreaming::Init2();
|
||||
//#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -93,36 +93,106 @@ static int clamp(int size, int targetSize)
|
|||
return size;
|
||||
}
|
||||
|
||||
static void downscaleTexture(RwTexture *texture)
|
||||
{
|
||||
RwRaster *oldRaster = RwTextureGetRaster(texture);
|
||||
if (oldRaster == nil)
|
||||
return;
|
||||
void debugRaster(RwRaster *r){
|
||||
if(!r){
|
||||
debug("Raster NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
extern bool moreVram;
|
||||
int targetSize = moreVram ? 64 : 32;
|
||||
|
||||
int oldWidth = RwRasterGetWidth(oldRaster);
|
||||
int oldHeight = RwRasterGetHeight(oldRaster);
|
||||
if (oldWidth <= targetSize && oldHeight <= targetSize) return;
|
||||
debug("Raster: %dx%d | depth: %d | format: 0x%X | stride: %d | platform: %d | pixels: %p",
|
||||
r->width,
|
||||
r->height,
|
||||
r->depth,
|
||||
r->format,
|
||||
r->stride,
|
||||
r->platform,
|
||||
r->pixels);
|
||||
}
|
||||
|
||||
int newWidth = clamp(oldWidth, targetSize);
|
||||
int newHeight = clamp(oldHeight, targetSize);
|
||||
if (newWidth == oldWidth && newHeight == oldHeight) return;
|
||||
static void downscaleTexture(RwTexture *texture){
|
||||
#ifdef RW_GLES1
|
||||
if(texture == nil)
|
||||
return;
|
||||
|
||||
RwImage *image = oldRaster->toImage();
|
||||
if (image == nil) return;
|
||||
RwRaster *oldRaster = RwTextureGetRaster(texture);
|
||||
if(oldRaster == nil)
|
||||
return;
|
||||
|
||||
RwImage *resized = resizeImage(image, newWidth, newHeight);
|
||||
RwImageDestroy(image);
|
||||
if (resized == nil) return;
|
||||
int oldWidth = RwRasterGetWidth(oldRaster);
|
||||
int oldHeight = RwRasterGetHeight(oldRaster);
|
||||
|
||||
RwRaster *newRaster = rw::Raster::createFromImage(resized);
|
||||
RwImageDestroy(resized);
|
||||
if (newRaster == nil) return;
|
||||
// dividir a la mitad, mínimo 16x16
|
||||
int newWidth = oldWidth > 16 ? oldWidth / 2 : oldWidth;
|
||||
int newHeight = oldHeight > 16 ? oldHeight / 2 : oldHeight;
|
||||
|
||||
RwTextureSetRaster(texture, newRaster);
|
||||
RwRasterDestroy(oldRaster);
|
||||
// si ya es suficientemente chica, no hacer nada
|
||||
if(newWidth == oldWidth && newHeight == oldHeight)
|
||||
return;
|
||||
|
||||
// toImage() funciona porque el backingStore está populado
|
||||
RwImage *image = oldRaster->toImage();
|
||||
if(image == nil){
|
||||
debug("downscaleTexture: toImage FAILED for %dx%d", oldWidth, oldHeight);
|
||||
return;
|
||||
}
|
||||
|
||||
RwImage *resized = resizeImage(image, newWidth, newHeight);
|
||||
RwImageDestroy(image);
|
||||
if(resized == nil){
|
||||
debug("downscaleTexture: resizeImage FAILED");
|
||||
return;
|
||||
}
|
||||
|
||||
// crear nuevo raster en formato compatible con GLES1
|
||||
int32 w, h, d, f;
|
||||
rw::Raster::imageFindRasterFormat(resized, rw::Raster::TEXTURE, &w, &h, &d, &f);
|
||||
RwRaster *newRaster = rw::Raster::create(w, h, d, f | rw::Raster::TEXTURE, rw::PLATFORM_GLES1);
|
||||
if(newRaster == nil){
|
||||
debug("downscaleTexture: raster create FAILED");
|
||||
RwImageDestroy(resized);
|
||||
return;
|
||||
}
|
||||
|
||||
if(newRaster->setFromImage(resized) == nil){
|
||||
debug("downscaleTexture: setFromImage FAILED");
|
||||
RwRasterDestroy(newRaster);
|
||||
RwImageDestroy(resized);
|
||||
return;
|
||||
}
|
||||
|
||||
RwImageDestroy(resized);
|
||||
RwTextureSetRaster(texture, newRaster);
|
||||
RwRasterDestroy(oldRaster);
|
||||
#else
|
||||
RwRaster *oldRaster = RwTextureGetRaster(texture);
|
||||
if (oldRaster == nil)
|
||||
return;
|
||||
|
||||
extern bool moreVram;
|
||||
int targetSize = moreVram ? 64 : 32;
|
||||
|
||||
int oldWidth = RwRasterGetWidth(oldRaster);
|
||||
int oldHeight = RwRasterGetHeight(oldRaster);
|
||||
if (oldWidth <= targetSize && oldHeight <= targetSize) return;
|
||||
|
||||
int newWidth = clamp(oldWidth, targetSize);
|
||||
int newHeight = clamp(oldHeight, targetSize);
|
||||
if (newWidth == oldWidth && newHeight == oldHeight) return;
|
||||
|
||||
RwImage *image = oldRaster->toImage();
|
||||
if (image == nil) return;
|
||||
|
||||
RwImage *resized = resizeImage(image, newWidth, newHeight);
|
||||
RwImageDestroy(image);
|
||||
if (resized == nil) return;
|
||||
|
||||
RwRaster *newRaster = rw::Raster::createFromImage(resized);
|
||||
RwImageDestroy(resized);
|
||||
if (newRaster == nil) return;
|
||||
|
||||
RwTextureSetRaster(texture, newRaster);
|
||||
RwRasterDestroy(oldRaster);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue