summaryrefslogtreecommitdiffstats
path: root/src/extras/screendroplets.cpp
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2020-12-26 14:48:47 +0100
committeraap <aap@papnet.eu>2020-12-26 14:48:47 +0100
commitb21ca72c8b8ef02a9af8b60a9aaea67b08c0a5b1 (patch)
tree16bc6baba74b5fcef68d69cb1ffbf119cc419f12 /src/extras/screendroplets.cpp
parentWeapon flags changed from bit fields to bit mask (R* vision) (diff)
downloadre3-b21ca72c8b8ef02a9af8b60a9aaea67b08c0a5b1.tar
re3-b21ca72c8b8ef02a9af8b60a9aaea67b08c0a5b1.tar.gz
re3-b21ca72c8b8ef02a9af8b60a9aaea67b08c0a5b1.tar.bz2
re3-b21ca72c8b8ef02a9af8b60a9aaea67b08c0a5b1.tar.lz
re3-b21ca72c8b8ef02a9af8b60a9aaea67b08c0a5b1.tar.xz
re3-b21ca72c8b8ef02a9af8b60a9aaea67b08c0a5b1.tar.zst
re3-b21ca72c8b8ef02a9af8b60a9aaea67b08c0a5b1.zip
Diffstat (limited to '')
-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);