summaryrefslogtreecommitdiff
path: root/src/extras
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2020-12-26 14:48:55 +0100
committeraap <aap@papnet.eu>2020-12-26 14:48:55 +0100
commit7613528e7e05a4f8b2a0210ddc90fd9023a2f065 (patch)
treedf4c81cd7683a3454ea6164843ef77237272031b /src/extras
parentb41f93fcd67bb76d095c600312cf88201b667f05 (diff)
make screendrops independent of neo.txd; enable new rendering by default
Diffstat (limited to 'src/extras')
-rw-r--r--src/extras/screendroplets.cpp38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/extras/screendroplets.cpp b/src/extras/screendroplets.cpp
index 54866bea..59c597f7 100644
--- a/src/extras/screendroplets.cpp
+++ b/src/extras/screendroplets.cpp
@@ -76,13 +76,36 @@ ScreenDroplets::Initialise(void)
ms_splashObject = nil;
}
+// Create white circle mask for rain drops
+static RwTexture*
+CreateDropMask(int32 size)
+{
+ RwImage *img = RwImageCreate(size, size, 32);
+ RwImageAllocatePixels(img);
+
+ uint8 *pixels = RwImageGetPixels(img);
+ int32 stride = RwImageGetStride(img);
+
+ for(int y = 0; y < size; y++){
+ float yf = ((y + 0.5f)/size - 0.5f)*2.0f;
+ for(int x = 0; x < size; x++){
+ float xf = ((x + 0.5f)/size - 0.5f)*2.0f;
+ memset(&pixels[y*stride + x*4], xf*xf + yf*yf < 1.0f ? 0xFF : 0x00, 4);
+ }
+ }
+
+ int32 width, height, depth, format;
+ RwImageFindRasterFormat(img, rwRASTERTYPETEXTURE, &width, &height, &depth, &format);
+ RwRaster *ras = RwRasterCreate(width, height, depth, format);
+ RwRasterSetFromImage(ras, img);
+ RwImageDestroy(img);
+ return RwTextureCreate(ras);
+}
+
void
ScreenDroplets::InitDraw(void)
{
- if(CustomPipes::neoTxd == nil)
- return;
-
- ms_maskTex = CustomPipes::neoTxd->find("dropmask");
+ ms_maskTex = CreateDropMask(64);
ms_screenTex = RwTextureCreate(nil);
RwTextureSetFilterMode(ms_screenTex, rwFILTERLINEAR);
@@ -138,10 +161,6 @@ ScreenDroplets::Shutdown(void)
void
ScreenDroplets::Process(void)
{
- // no need to do anything if we can't render
- if(CustomPipes::neoTxd == nil)
- return;
-
ProcessCameraMovement();
SprayDrops();
ProcessMoving();
@@ -179,9 +198,6 @@ ScreenDroplets::Render(void)
{
ScreenDrop *drop;
- if(CustomPipes::neoTxd == nil)
- return;
-
DefinedState();
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(ms_maskTex));
RwRenderStateSet(rwRENDERSTATEFOGENABLE, FALSE);