ColorKey now uses upper left corner when a value of -1 is used

This commit is contained in:
n00b
2024-12-15 11:37:44 -05:00
parent 0e2253ad02
commit 39c5e4a9f2
11 changed files with 68 additions and 8 deletions

View File

@@ -4448,7 +4448,7 @@ int main(int argc, char * argv[])
if(debug_opt.compare("a")==0)
{
//rc_intern_dirChange("/home/n00b/Music/rcbasic_v400_linux64/examples/tile_demo");
rc_intern_dirChange("/home/n00b/Music/Simple 3D Platformer/");
rc_intern_dirChange("/home/n00b/Music/RCBasic_v400_Linux64/examples/RC3/gfx/beast_demo/");
rc_filename = "main.cbc";
}
else

View File

@@ -2316,6 +2316,13 @@ int rc_loadImageEx(std::string img_file, Uint32 color_key = 0, bool use_color_ke
if(img.image == NULL)
return -1;
if(color_key == -1)
{
Uint32* img_pixels = (Uint32*)img.image->lock();
color_key = img_pixels[0];
img.image->unlock();
}
if(use_color_key)
VideoDriver->makeColorKeyTexture(img.image, irr::video::SColor(color_key), false);
@@ -2371,6 +2378,13 @@ int rc_createImageEx(int w, int h, double * pdata, Uint32 colorkey, bool use_col
return -1;
Uint32 * img_pixels = (Uint32*)image->getData();
if( ((w*h) >= 1) && colorkey == -1)
{
colorkey = img_pixels[0];
}
for(int i = 0; i < (w*h); i++)
{
img_pixels[i] = (Uint32)pdata[i];
@@ -2941,6 +2955,12 @@ void rc_setColorKey(int img_id, Uint32 colorkey)
if(!rc_imageExists(img_id))
return;
if(colorkey == -1)
{
Uint32* img_pixels = (Uint32*)rc_image[img_id].image->lock();
colorkey = img_pixels[0];
rc_image[img_id].image->unlock();
}
VideoDriver->makeColorKeyTexture(rc_image[img_id].image, irr::video::SColor(colorkey));
}

View File

@@ -1,5 +1,5 @@
# depslib dependency file v1.0
1734119283 source:/home/n00b/Projects/RCBASIC4/rcbasic_runtime/main.cpp
1734280140 source:/home/n00b/Projects/RCBASIC4/rcbasic_runtime/main.cpp
"rc_os_defines.h"
<emscripten.h>
<sys/param.h>
@@ -33,7 +33,7 @@
<irrtheora.h>
"rc_func130_cases.h"
1734207123 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_os_defines.h
1734280140 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_os_defines.h
<TargetConditionals.h>
1734207007 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_defines.h
@@ -1248,7 +1248,7 @@
1727545973 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/RealisticWater.h
<irrlicht.h>
1733959687 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_gfx.h
1734280525 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_gfx.h
"SDL.h"
<SDL2/SDL.h>
<irrlicht.h>