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

@@ -1,4 +1,10 @@
#title CastRay2D [RCBasic Doc]
#header function CastRay2D( from_x, from_y, to_x, to_y )
Cast a ray and get the closest hit on the ray
Returns 1 if there is a hit and 0 if not
NOTE: GetRayHit2D is used to read each hit
#ref GetRayHit3D CastRay3D CastRay3D_All CastRay2D_All GetRayHit2D

View File

@@ -1,4 +1,10 @@
#title CastRay2D_All [RCBasic Doc]
#header function CastRay2D_All( from_x, from_y, to_x, to_y )
Cast a ray and gets all hits on the ray
Returns the number of hits from the ray cast
NOTE: GetRayHit2D is used to read each hit
#ref GetRayHit3D CastRay3D CastRay3D_All CastRay2D GetRayHit2D

View File

@@ -1,4 +1,10 @@
#title CastRay3D [RCBasic Doc]
#header function CastRay3D( from_x, from_y, from_z, to_x, to_y, to_z )
Cast a ray and get the closest hit on the ray
Returns 1 if there is a hit and 0 if not
NOTE: GetRayHit3D is used to read each hit
#ref GetRayHit3D CastRay3D_All CastRay2D CastRay2D_All GetRayHit2D

View File

@@ -1,4 +1,10 @@
#title CastRay3D_All [RCBasic Doc]
#header function CastRay3D_All( from_x, from_y, from_z, to_x, to_y, to_z )
Cast a ray and gets all hits on the ray
Returns the number of hits from the ray cast
NOTE: GetRayHit3D is used to read each hit
#ref GetRayHit3D CastRay3D CastRay2D CastRay2D_All GetRayHit2D

View File

@@ -22,10 +22,10 @@
LIGHT_TYPE_POINT
</li>
<li>
LIGHT_TYPE_POINT
LIGHT_TYPE_DIRECTIONAL
</li>
<li>
LIGHT_TYPE_POINT
LIGHT_TYPE_SPOT
<br><p>Related:
<a href="setlighttype.html">SetLightType</a>
</p>

View File

@@ -1,4 +1,12 @@
#title GetRayHit2D [RCBasic Doc]
#header sub GetRayHit2D( index, ByRef spr_id, ByRef x, ByRef y, ByRef normal_x, ByRef normal_y )
This function will get the collision point and the normal of a ray hit.
NOTES:
#list ul
#li CastRay2D or CastRay2D_All must be called prior to calling this function
#li spr_id will return -1 if there was not a hit at the specified index
#/list
#ref GetRayHit3D CastRay3D CastRay3D_All CastRay2D CastRay2D_All

View File

@@ -1,4 +1,12 @@
#title GetRayHit3D [RCBasic Doc]
#header sub GetRayHit3D( index, ByRef actor_id, ByRef x, ByRef y, ByRef z, ByRef normal_x, ByRef normal_y, ByRef normal_z )
This function will get the collision point and the normal of a ray hit.
NOTES:
#list ul
#li CastRay3D or CastRay3D_All must be called prior to calling this function
#li actor_id will return -1 if there was not a hit at the specified index
#/list
#ref CastRay3D CastRay3D_All CastRay2D CastRay2D_All GetRayHit2D

View File

@@ -19,10 +19,10 @@
LIGHT_TYPE_POINT
</li>
<li>
LIGHT_TYPE_POINT
LIGHT_TYPE_DIRECTIONAL
</li>
<li>
LIGHT_TYPE_POINT
LIGHT_TYPE_SPOT
<br><p>Related:
<a href="setlighttype.html">SetLightType</a>
</p>

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>