diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index e5c6dd7..8faa6c2 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -145,6 +145,8 @@ int8 CMenuManager::m_PrefsIslandLoading = ISLAND_LOADING_LOW; #ifdef GAMEPAD_MENU #ifdef __SWITCH__ int8 CMenuManager::m_PrefsControllerType = CONTROLLER_NINTENDO_SWITCH; +#elif defined __SYMBIAN32__ +int8 CMenuManager::m_PrefsControllerType = CONTROLLER_DUALSHOCK2; #else int8 CMenuManager::m_PrefsControllerType = CONTROLLER_XBOXONE; #endif diff --git a/src/core/config.h b/src/core/config.h index 05f9a1a..b7baed8 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -371,7 +371,7 @@ enum Config { # define CUSTOM_FRONTEND_OPTIONS # ifdef CUSTOM_FRONTEND_OPTIONS -# define MENU_MAP // VC-like menu map. Won't appear if you don't have our menu.txd +//# define MENU_MAP // VC-like menu map. Won't appear if you don't have our menu.txd # define GRAPHICS_MENU_OPTIONS // otherwise Display settings will be scrollable //# define NO_ISLAND_LOADING // disable loadscreen between islands via loading all island data at once, consumes more memory and CPU # define CUTSCENE_BORDERS_SWITCH diff --git a/src/rw/TexRead.cpp b/src/rw/TexRead.cpp index ed78919..c962a81 100644 --- a/src/rw/TexRead.cpp +++ b/src/rw/TexRead.cpp @@ -110,7 +110,7 @@ void debugRaster(RwRaster *r){ } static void downscaleTexture(RwTexture *texture){ - #ifdef RW_GLES1 +// #ifdef RW_GLES1 if(texture == nil) return; @@ -146,7 +146,11 @@ static void downscaleTexture(RwTexture *texture){ // crear nuevo raster en formato compatible con GLES1 int32 w, h, d, f; rw::Raster::imageFindRasterFormat(resized, rw::Raster::TEXTURE, &w, &h, &d, &f); +#ifdef RW_GLES1 RwRaster *newRaster = rw::Raster::create(w, h, d, f | rw::Raster::TEXTURE, rw::PLATFORM_GLES1); +#else + RwRaster *newRaster = rw::Raster::create(w, h, d, f | rw::Raster::TEXTURE, rw::PLATFORM_GL3); +#endif if(newRaster == nil){ debug("downscaleTexture: raster create FAILED"); RwImageDestroy(resized); @@ -163,36 +167,36 @@ static void downscaleTexture(RwTexture *texture){ 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 +// #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 @@ -219,6 +223,11 @@ RwTextureGtaStreamRead(RwStream *stream) if (gGameState == GS_INIT_PLAYING_GAME) { texLoadTime = (texNumLoaded * texLoadTime + (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond() - preloadTime) / (float)(texNumLoaded+1); texNumLoaded++; + } else /*if (gGameState != GS_PLAYING_GAME)*/ { + if (tex != nil && tex->raster != nil && RwRasterGetWidth(tex->raster) > 128 || RwRasterGetHeight(tex->raster) > 128) { +// debug("downscaling %s", tex->name); + downscaleTexture(tex); + } } #ifdef ANISOTROPIC_FILTERING diff --git a/vendor/librw/src/gl/gl3raster.cpp b/vendor/librw/src/gl/gl3raster.cpp index 1a1e044..95cc034 100644 --- a/vendor/librw/src/gl/gl3raster.cpp +++ b/vendor/librw/src/gl/gl3raster.cpp @@ -64,6 +64,7 @@ getLevelSize(Raster *raster, int32 level) static Raster* rasterCreateTexture(Raster *raster) { + CHECK_GL_ERROR("-rasterCreateTexture"); if(raster->format & (Raster::PAL4 | Raster::PAL8)){ RWERROR((ERR_NOTEXTURE)); return nil; @@ -138,11 +139,14 @@ rasterCreateTexture(Raster *raster) natras->numLevels = 1; glGenTextures(1, &natras->texid); - uint32 prev = bindTexture(natras->texid); + CHECK_GL_ERROR("glGenTextures"); +// re3_debug("creating texture, format: %d, size: %d x %d", natras->internalFormat, raster->width, raster->height); +// uint32 prev = bindTexture(natras->texid); // glTexImage2D(GL_TEXTURE_2D, 0, natras->internalFormat, -//// raster->width, raster->height, -// 1,1, +// raster->width, raster->height, +//// 1,1, // 0, natras->format, natras->type, nil); +// CHECK_GL_ERROR("glTexImage2D"); // TODO: allocate other levels...probably #ifndef __SYMBIAN32__ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, natras->numLevels-1); @@ -152,7 +156,7 @@ rasterCreateTexture(Raster *raster) natras->addressV = 0; natras->maxAnisotropy = 1; - bindTexture(prev); +// bindTexture(prev); return raster; } @@ -220,6 +224,7 @@ rasterCreateCameraTexture(Raster *raster) // raster->width, raster->height, 1,1, 0, natras->format, natras->type, nil); + CHECK_GL_ERROR("glTexImage2D"); natras->filterMode = 0; natras->addressU = 0; natras->addressV = 0; @@ -488,6 +493,7 @@ uint8* rasterLock(Raster *raster, int32 level, int32 lockMode) { #ifdef RW_OPENGL + CHECK_GL_ERROR("+rasterLock"); Gl3Raster *natras GETGL3RASTEREXT(raster); uint8 *px; uint32 allocSz; @@ -536,8 +542,10 @@ rasterLock(Raster *raster, int32 level, int32 lockMode) glGenFramebuffers(1, &fbo); bindFramebuffer(fbo); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, natras->texid, 0); + CHECK_GL_ERROR("glFramebufferTexture2D"); GLenum e = glCheckFramebufferStatus(GL_FRAMEBUFFER); glReadPixels(0, 0, raster->width, raster->height, natras->format, natras->type, px); + CHECK_GL_ERROR("glReadPixels"); //e = glGetError(); printf("GL err4 %x (%x)\n", e, natras->format); bindFramebuffer(0); glDeleteFramebuffers(1, &fbo); @@ -571,6 +579,7 @@ rasterLock(Raster *raster, int32 level, int32 lockMode) glReadBuffer(GL_BACK); #endif glReadPixels(0, 0, raster->width, raster->height, GL_RGB, GL_UNSIGNED_BYTE, px); + CHECK_GL_ERROR("glReadPixels"); raster->privateFlags = lockMode; break; @@ -580,6 +589,7 @@ rasterLock(Raster *raster, int32 level, int32 lockMode) return nil; } + CHECK_GL_ERROR("-rasterLock"); return px; #else return nil; @@ -590,6 +600,7 @@ void rasterUnlock(Raster *raster, int32 level) { #ifdef RW_OPENGL + CHECK_GL_ERROR("+rasterUnlock"); Gl3Raster *natras = GETGL3RASTEREXT(raster); assert(raster->pixels); @@ -606,6 +617,7 @@ rasterUnlock(Raster *raster, int32 level) raster->width, raster->height, 0, getLevelSize(raster, level), raster->pixels); + CHECK_GL_ERROR("glCompressedTexImage2D"); if(natras->backingStore){ assert(level < natras->backingStore->numlevels); memcpy(natras->backingStore->levels[level].data, raster->pixels, @@ -631,12 +643,14 @@ rasterUnlock(Raster *raster, int32 level) } glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, raster->width, raster->height, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, pixels16); free(pixels16); + CHECK_GL_ERROR("glTexImage2D 1"); } else { // glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, level, natras->internalFormat, raster->width, raster->height, 0, natras->format, natras->type, raster->pixels); + CHECK_GL_ERROR("glTexImage2D 2"); } } // if(level == 0 && natras->autogenMipmap) @@ -652,6 +666,7 @@ rasterUnlock(Raster *raster, int32 level) rwFree(raster->pixels); raster->pixels = nil; + CHECK_GL_ERROR("-rasterUnlock"); #endif raster->width = raster->originalWidth; raster->height = raster->originalHeight; diff --git a/vendor/librw/src/gl/rwgl3.h b/vendor/librw/src/gl/rwgl3.h index 0c33166..f5b966a 100644 --- a/vendor/librw/src/gl/rwgl3.h +++ b/vendor/librw/src/gl/rwgl3.h @@ -18,6 +18,20 @@ #endif #endif +#if 0 +extern void re3_debug(const char *format, ...); +extern void re3_trace(const char *filename, unsigned int lineno, const char *func, const char *format, ...); +#define CHECK_GL_ERROR(trace) do { \ + int glerror = glGetError(); \ + if (glerror != 0) { \ + re3_trace(__FILE__, __LINE__, __FUNCTION__, "GL Error %x on %s", glerror, trace); \ + } \ +} while(0); +#else +#define CHECK_GL_ERROR(a) +#endif + + namespace rw { #ifdef RW_GL3