This commit is contained in:
Dante Leoncini 2026-05-06 23:23:00 -03:00
commit 2390c67fa1
6 changed files with 73 additions and 64 deletions

View file

@ -2,16 +2,16 @@ Common:
- [x] Make it compile
- [x] Window implementation
- [x] Fix shader compilation
- [x] Basic touch controls
- [x] Downscale textures
- [ ] Simplify geometry
- [ ] Touch controls
- [x] Touch controls
- [x] Keyboard controls
- [ ] Audio?
- [x] Menu
- [x] Config
- [x] Merge S60v3 and ^3 branches
- [ ] Move map to top left corner
- [ ] Do something with sprites, they're still taking too much frame time
GLES 2.0 specific:
- [x] Optimize to always run 10+ fps

View file

@ -1403,14 +1403,10 @@ RenderScene(void)
}
#endif
PUSH_RENDERGROUP("RenderScene");
#ifdef RW_GL3
CClouds::Render();
#endif
// CClouds::Render();
DoRWRenderHorizon();
CRenderer::RenderRoads();
#ifdef RW_GL3
CCoronas::RenderReflections();
#endif
// CCoronas::RenderReflections();
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE);
CRenderer::RenderEverythingBarRoads();
CRenderer::RenderBoats();
@ -1457,10 +1453,8 @@ RenderEffects(void)
// CSkidmarks::Render();
// CAntennas::Render();
// CRubbish::Render();
#ifdef RW_GL3
CCoronas::Render();
#endif
// CParticle::Render();
// CCoronas::Render();
CParticle::Render();
CPacManPickups::Render();
// CWeaponEffects::Render();
// CPointLights::RenderFogEffect();

View file

@ -1327,24 +1327,48 @@ void CHud::DrawAfterFade()
int w = 640;
int y = 0;
{
CFont::SetJustifyOff();
CFont::SetBackgroundOff();
CFont::SetColor(CRGBA(255, 255, 255, 255));
CFont::SetScale(0.75f, 0.75f);
CFont::SetCentreOn();
CFont::SetPropOn();
CFont::SetFontStyle(FONT_BANK);
#define CRECT(X, Y, W, H) CRect(X, (Y) * 480.f / 360.f, (W) + (X), ((H) + (Y)) * 480.f / 360.f)
#define PRINT(S, X, Y, W) CFont::SetCentreSize(W); \
CFont::PrintString((X) + ((W) / 2), (Y) * (480.f / 360.f), (wchar*) L ## S);
// l
CSprite2d::DrawRect(CRECT(40, 6 + y, 90, 20), CRGBA(0, 0, 0, 128));
PRINT("L1", 40, 12 + y, 90);
CSprite2d::DrawRect(CRECT(180, 6 + y, 90, 20), CRGBA(0, 0, 0, 128));
PRINT("L2", 180, 12 + y, 90);
// r
CSprite2d::DrawRect(CRECT(w - 40 - 90, 6 + y, 90, 20), CRGBA(0, 0, 0, 128));
PRINT("R1", w - 40 - 90, 12 + y, 90);
CSprite2d::DrawRect(CRECT(w - 180 - 90, 6 + y, 90, 20), CRGBA(0, 0, 0, 128));
PRINT("R2", w - 180 - 90, 12 + y, 90);
// select, start
CSprite2d::DrawRect(CRECT(320 - 80, 286 + y, 60, 20), CRGBA(0, 0, 0, 128));
PRINT("select", 320 - 80, 290 + y, 60);
CSprite2d::DrawRect(CRECT(320 + 20, 286 + y, 60, 20), CRGBA(0, 0, 0, 128));
PRINT("start", 320 + 20, 290 + y, 60);
// dpad
CSprite2d::DrawRect(CRECT(0, 80 + y, w / 4, 120), CRGBA(0, 0, 0, 128));
PRINT("/\\", w / 8 - 15, 90 + y, 30);
PRINT("v", w / 8 - 15, 160 + y, 30);
PRINT("<", w / 8 - 60, 125 + y, 30);
PRINT(">", w / 8 + 30, 125 + y, 30);
// abxy
CSprite2d::DrawRect(CRECT(w - w / 4, 80 + y, w / 4, 120), CRGBA(0, 0, 0, 128));
PRINT("/\\", w - w / 8 - 15, 90 + y, 30);
PRINT("X", w - w / 8 - 15, 160 + y, 30);
PRINT("[]", w - w / 8 - 60, 125 + y, 30);
PRINT("O", w - w / 8 + 30, 125 + y, 30);
#undef PRINT
#undef CRECT
}
}

View file

@ -93,24 +93,7 @@ static int clamp(int size, int targetSize)
return size;
}
void debugRaster(RwRaster *r){
if(!r){
debug("Raster NULL");
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);
}
static void downscaleTexture(RwTexture *texture){
// #ifdef RW_GLES1
static void halveTexture(RwTexture *texture){
if(texture == nil)
return;
@ -167,36 +150,37 @@ 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
}
static void downscaleTexture(RwTexture *texture) {
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
@ -224,9 +208,9 @@ RwTextureGtaStreamRead(RwStream *stream)
texLoadTime = (texNumLoaded * texLoadTime + (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond() - preloadTime) / (float)(texNumLoaded+1);
texNumLoaded++;
} else if (gGameState != GS_PLAYING_GAME || FrontEndMenuManager.m_bMenuActive) {
if (tex != nil && tex->raster != nil && RwRasterGetWidth(tex->raster) > 128 || RwRasterGetHeight(tex->raster) > 128) {
if (tex != nil && tex->raster != nil && (RwRasterGetWidth(tex->raster) > 128 || RwRasterGetHeight(tex->raster) > 128)) {
// debug("downscaling %s", tex->name);
downscaleTexture(tex);
halveTexture(tex);
}
}
@ -578,7 +562,11 @@ CreateTxdImageForVideoCard()
RwTexDictionary *texDict = CTxdStore::GetSlot(i)->texDict;
FORLIST(lnk, texDict->textures){
rw::Texture *texture = rw::Texture::fromDict(lnk);
#ifdef RW_GL3
downscaleTexture(texture);
#else
halveTexture(texture);
#endif
}
#endif
int32 pos = STREAMTELL(img);

View file

@ -707,11 +707,11 @@ public:
if (y < 125) {
b = JOY_Y;
} else if (y > 155) {
b = JOY_A;
b = JOY_B;
} else if (x < w - w / 8) {
b = JOY_X;
} else {
b = JOY_B;
b = JOY_A;
}
activeZone[i] = b + 1;
virtualButtons[b] = 1;

View file

@ -19,6 +19,8 @@
#include "rwgl3impl.h"
extern bool moreVram;
namespace rw {
namespace gl3 {
@ -340,6 +342,7 @@ skinClose(void *o, int32, int32)
void
initSkin(void)
{
if (moreVram) return; // TODO
u_boneMatrices = registerUniform("u_boneMatrices", UNIFORM_MAT4, MAX_BONES);
Driver::registerPlugin(PLATFORM_GL3, 0, ID_SKIN,