diff options
| -rw-r--r-- | API.md | 30 | ||||
| -rw-r--r-- | CMakeLists.txt | 3 | ||||
| -rw-r--r-- | README.md | 19 | ||||
| -rw-r--r-- | devnotes | 3 | ||||
| -rw-r--r-- | doc_parser.lua | 2 | ||||
| -rw-r--r-- | examples/dungeon_crawler/main.lua | 37 | ||||
| -rw-r--r-- | examples/waving_cubes/main.lua | 67 | ||||
| -rw-r--r-- | examples/window/main.lua | 4 | ||||
| -rw-r--r-- | include/main.h | 26 | ||||
| -rw-r--r-- | include/text.h | 1 | ||||
| -rw-r--r-- | include/textures.h | 2 | ||||
| -rw-r--r-- | src/lua_core.c | 14 | ||||
| -rw-r--r-- | src/main.c | 2 | ||||
| -rw-r--r-- | src/text.c | 22 | ||||
| -rw-r--r-- | src/textures.c | 23 |
15 files changed, 184 insertions, 71 deletions
@@ -2,7 +2,7 @@ ## Usage -Application needs 'main.lua' file as entry point. ReiLua executable will first look it from same directory. Alternatively, path to the folder where "main.lua" is located can be given as argument. There are three global Lua functions that the engine will call, 'init', 'process' and 'draw'. +Application needs 'main.lua' or 'main' file as entry point. ReiLua executable will first look it from same directory. Alternatively, path to the folder where "main.lua" is located can be given as argument. There are three global Lua functions that the engine will call, 'init', 'process' and 'draw'. --- > function init() @@ -192,7 +192,7 @@ NPATCH_THREE_PATCH_VERTICAL NPATCH_THREE_PATCH_HORIZONTAL -## Globals - Shader +## Globals - ShaderLocationIndex SHADER_LOC_VERTEX_POSITION @@ -246,7 +246,7 @@ SHADER_LOC_MAP_PREFILTER SHADER_LOC_MAP_BRDF -## Globals - Shader +## Globals - ShaderUniformDataType SHADER_UNIFORM_FLOAT @@ -266,7 +266,7 @@ SHADER_UNIFORM_IVEC4 SHADER_UNIFORM_SAMPLER2D -## Globals - Shader +## Globals - ShaderAttributeDataTypes SHADER_ATTRIB_FLOAT @@ -1676,6 +1676,19 @@ Get texture size --- +## Textures - Color/pixel + +--- + +> color = RL_ColorFromHSV( float hue, float saturation, float value ) + +Returns a Color from HSV values, hue [0..360], saturation/value [0..1] + +- Failure return false +- Success return Color + +--- + ## Text - Loading --- @@ -1693,6 +1706,15 @@ Load font from file into GPU memory ( VRAM ) --- +> success = RL_DrawFPS( Vector2 pos ) + +Draw current FPS + +- Failure return false +- Success return true + +--- + > success = RL_DrawText( Font font, string text, Vector2 position, float fontSize, float spacing, Color tint ) Draw text using font and additional parameters diff --git a/CMakeLists.txt b/CMakeLists.txt index 32c1737..c0645bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required( VERSION 3.15 ) +cmake_minimum_required( VERSION 3.9 ) project( ReiLua ) set( CMAKE_C_STANDARD 99 ) # Requires C99 standard @@ -27,6 +27,7 @@ else() message( Static ) target_link_libraries( ${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/lib/libraylib.a ) target_link_libraries( ${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/lib/liblua.a ) + # target_link_libraries( ${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/lib/libluajit.a ) endif() if( UNIX ) @@ -1,16 +1,20 @@ ## About -Idea of this project was to bring the power and simplicity of raylib to easy beginner friendly language like Lua in a very straight forward manner. It is not a straight binding to Raylib, some functions are not included and some are added. The idea of pointing "main.lua" file and access functions "init", "process" and "draw" are borrowed from Löve game engine. +Idea of this project was to bring the power and simplicity of raylib to easy beginner friendly language like Lua in a very straight forward manner. It is not a straight binding to Raylib, some functions will not be included and some are added. The idea of pointing "main.lua" file and access functions "init", "process" and "draw" are borrowed from Löve game engine. -Need for boilerplate code is minimal and in true Lua fashion (in better and worse) you don't need to worry about types and typecasts since all Raylib types are just lua tables and object id's. Also what Lua cannot handle, the engine is simple enough to be fairly easily extended with new functionality or by using Lua C-libraries. +Need for boilerplate code is minimal and in true Lua fashion (in better and worse) you don't need to worry about types since all Raylib types are just lua tables and object id's. Also what Lua cannot handle, the engine is simple enough to be fairly easily extended with new functionality or by using Lua C-libraries. + +ReiLua is not planned to be a one-to-one binding to raylib. If you want more direct bindings, there are other projects like https://github.com/TSnake41/raylib-lua. + +Reilua means fair in finnish. ## Status -Engine is currently in arbitrary version 0.1 and some functionality is still missing. Also the build system is still lacking of Web build and Mac is not tested. +ReiLua is currently in arbitrary version 0.1 and some planned raylib functionality is still missing. Also the build system is still lacking of Web build and Mac is not tested. ## Usage -Application needs 'main.lua' file as entry point. ReiLua executable will first look it from same directory. Alternatively, path to the folder where "main.lua" is located can be given as argument. There are three global Lua functions that the engine will call, 'init', 'process' and 'draw'. +Application needs 'main.lua' or 'main' file as entry point. ReiLua executable will first look it from same directory. Alternatively, path to the folder where "main.lua" is located can be given as argument. There are three global Lua functions that the engine will call, 'init', 'process' and 'draw'. Example of basic "main.lua" file that will show basic windows with text. @@ -35,8 +39,8 @@ function process( delta ) end function draw() - RL_ClearBackground( RAYWHITE ); - RL_DrawText( 0, "Congrats! You created your first window!", textPos, 20, 2, textColor ); + RL_ClearBackground( RAYWHITE ) + RL_DrawText( 0, "Congrats! You created your first window!", textPos, 20, 2, textColor ) end ``` @@ -57,6 +61,7 @@ I think the simplest way would be to statically link Raylib and Lua to the same //TODO In future these instructions should be set on fixed release versions of Raylib. https://github.com/raysan5/raylib + https://github.com/lua/lua ### Linux @@ -103,7 +108,7 @@ mingw32-make * I haven't got Lua to compile on Windows so we will download it's binarys from http://luabinaries.sourceforge.net/download.html. Take the one with "Windows x64 DLL and Includes (MingW-w64 6 Built)". * Copy "liblua54.a" to "ReiLua/lib" folder. * Change it's name to "liblua.a" or change the part in "CMakeLists.txt" where it links to "/lib/liblua.a" to "/lib/liblua54.a". -* Navigate to "ReiLua/build" folder with "w64devkit" and run... +* Navigate to "ReiLua/build" folder on "w64devkit" and run... ``` cmake -G "MinGW Makefiles" .. @@ -1,9 +1,6 @@ Backlog { * Compilation - * Windows - Mingw cross compilation causes name clashes with raylib https://github.com/raysan5/raylib/issues/1217 * Web - * Better CMakeList * More and better examples * Raygui diff --git a/doc_parser.lua b/doc_parser.lua index 6c74b02..848577c 100644 --- a/doc_parser.lua +++ b/doc_parser.lua @@ -22,7 +22,7 @@ apiFile:write( "# ReiLua API\n" ) -- Usage. apiFile:write( "\n## Usage\n" ) -apiFile:write( "\nApplication needs 'main.lua' file as entry point. ReiLua executable will first look it from same directory. Alternatively, path to the folder where \"main.lua\" is located can be given as argument. There are three global Lua functions that the engine will call, 'init', 'process' and 'draw'.\n" ) +apiFile:write( "\nApplication needs 'main.lua' or 'main' file as entry point. ReiLua executable will first look it from same directory. Alternatively, path to the folder where \"main.lua\" is located can be given as argument. There are three global Lua functions that the engine will call, 'init', 'process' and 'draw'.\n" ) apiFile:write( "\n---\n> function init()\n\ This function will be called first when 'main.lua' is found\n\n---\n" ) diff --git a/examples/dungeon_crawler/main.lua b/examples/dungeon_crawler/main.lua index 979b553..3df65ca 100644 --- a/examples/dungeon_crawler/main.lua +++ b/examples/dungeon_crawler/main.lua @@ -10,7 +10,6 @@ local winScale = 5 local framebuffer = -1 local TILE_SIZE = 32 -local COLOR_WHITE = { 255, 255, 255 } local FLOOR = 1 local CEILING = 2 @@ -61,7 +60,7 @@ function drawSprites() for _, sprite in ipairs( sprites ) do RL_DrawBillboardRec( camera, texture, { sprite.tile[1] * TILE_SIZE, sprite.tile[2] * TILE_SIZE, TILE_SIZE, TILE_SIZE }, - { sprite.pos[1], 0.5 * sprite.size, sprite.pos[2] }, { sprite.size, sprite.size }, COLOR_WHITE ) + { sprite.pos[1], 0.5 * sprite.size, sprite.pos[2] }, { sprite.size, sprite.size }, WHITE ) end end @@ -69,9 +68,8 @@ function init() local monitor = 0 local mPos = RL_GetMonitorPosition( monitor ) local mSize = RL_GetMonitorSize( monitor ) - -- RL_SetWindowSize( { 1920, 1080 } ) + winSize = { res[1] * winScale, res[2] * winScale } - -- winSize = { 1920, 1080 } RL_SetWindowSize( winSize ) RL_SetExitKey( KEY_ESCAPE ) -- framebuffer = RL_LoadRenderTexture( res ) @@ -85,7 +83,6 @@ function init() RL_SetCamera3DTarget( camera, { 0, 0, 0 } ) RL_SetCamera3DUp( camera, { 0, 1, 0 } ) RL_SetCamera3DMode( camera, CAMERA_FIRST_PERSON ) - -- RL_SetCamera3DMode( camera, CAMERA_ORBITAL ) -- for x = 0, 3 do -- for y = 0, 9 do @@ -93,20 +90,10 @@ function init() -- end -- end table.insert( sprites, { pos = { 2.5, 2.5 }, tile = { 1, 1 }, dis = 0, size = 0.8 } ) - - -- for x = 0, 1 do - -- for y = 0, 1 do - -- table.insert( sprites, { pos = { 1.25 + x * 0.5, 2.25 + y * 0.5 }, tile = { 3, 0 }, dis = 0, size = 0.6 } ) - -- end - -- end table.insert( sprites, { pos = { 1.5, 3.5 }, tile = { 3, 1 }, dis = 0, size = 0.5 } ) table.insert( sprites, { pos = { 0.5, 3.5 }, tile = { 3, 0 }, dis = 0, size = 0.7 } ) end -function process( delta ) - -- RL_SetCamera3DPosition( camera, pos ) -end - function draw() RL_UpdateCamera3D( camera ) pos = RL_GetCamera3DPosition( camera ) @@ -119,22 +106,22 @@ function draw() -- Floor and ceiling. for x = 0, 3 do for y = 0, 10 do - RL_DrawQuad3DTexture( texture, getTileVer( x, y, FLOOR ), getTexCoords( 1, 0 ), COLOR_WHITE ) - RL_DrawQuad3DTexture( texture, getTileVer( x, y, CEILING ), getTexCoords( 2, 0 ), COLOR_WHITE ) + RL_DrawQuad3DTexture( texture, getTileVer( x, y, FLOOR ), getTexCoords( 1, 0 ), WHITE ) + RL_DrawQuad3DTexture( texture, getTileVer( x, y, CEILING ), getTexCoords( 2, 0 ), WHITE ) end end -- Walls. - RL_DrawQuad3DTexture( texture, getTileVer( 0, 0, WALL_N ), getTexCoords( 0, 0 ), COLOR_WHITE ) - RL_DrawQuad3DTexture( texture, getTileVer( 1, 0, WALL_N ), getTexCoords( 0, 2 ), COLOR_WHITE ) - RL_DrawQuad3DTexture( texture, getTileVer( 2, 0, WALL_N ), getTexCoords( 2, 2 ), COLOR_WHITE ) - RL_DrawQuad3DTexture( texture, getTileVer( 3, 0, WALL_N ), getTexCoords( 0, 0 ), COLOR_WHITE ) + RL_DrawQuad3DTexture( texture, getTileVer( 0, 0, WALL_N ), getTexCoords( 0, 0 ), WHITE ) + RL_DrawQuad3DTexture( texture, getTileVer( 1, 0, WALL_N ), getTexCoords( 0, 2 ), WHITE ) + RL_DrawQuad3DTexture( texture, getTileVer( 2, 0, WALL_N ), getTexCoords( 2, 2 ), WHITE ) + RL_DrawQuad3DTexture( texture, getTileVer( 3, 0, WALL_N ), getTexCoords( 0, 0 ), WHITE ) for x = 0, 3 do - RL_DrawQuad3DTexture( texture, getTileVer( x, 10, WALL_S ), getTexCoords( 0, 0 ), COLOR_WHITE ) + RL_DrawQuad3DTexture( texture, getTileVer( x, 10, WALL_S ), getTexCoords( 0, 0 ), WHITE ) end for y = 0, 10 do - RL_DrawQuad3DTexture( texture, getTileVer( 0, y, WALL_W ), getTexCoords( 0, 0 ), COLOR_WHITE ) - RL_DrawQuad3DTexture( texture, getTileVer( 3, y, WALL_E ), getTexCoords( 0, 0 ), COLOR_WHITE ) + RL_DrawQuad3DTexture( texture, getTileVer( 0, y, WALL_W ), getTexCoords( 0, 0 ), WHITE ) + RL_DrawQuad3DTexture( texture, getTileVer( 3, y, WALL_E ), getTexCoords( 0, 0 ), WHITE ) end drawSprites() @@ -142,6 +129,6 @@ function draw() -- RL_EndTextureMode() -- RL_SetTextureSource( TEXTURE_SOURCE_RENDER_TEXTURE ) - -- RL_DrawTexturePro( framebuffer, { 0, 0, res[1], -res[2] }, { 0, 0, winSize[1], winSize[2] }, { 0, 0 }, 0.0, COLOR_WHITE ) + -- RL_DrawTexturePro( framebuffer, { 0, 0, res[1], -res[2] }, { 0, 0, winSize[1], winSize[2] }, { 0, 0 }, 0.0, WHITE ) -- RL_SetTextureSource( TEXTURE_SOURCE_TEXTURE ) end diff --git a/examples/waving_cubes/main.lua b/examples/waving_cubes/main.lua new file mode 100644 index 0000000..8023f67 --- /dev/null +++ b/examples/waving_cubes/main.lua @@ -0,0 +1,67 @@ +--[[ + Contributed by Codecat (@codecat) + Reviewed by Ramon Santamaria (@raysan5) + + Modified by Teddy Astie (@TSnake41) for Lua binding. + Modified by Jussi Viitala (@nullstare) for ReiLua style. +]] + +local winSize = RL_GetWindowSize() +local camera = -1 + +local num_blocks = 15 + +function init() + local monitor = 0 + local mPos = RL_GetMonitorPosition( monitor ) + local mSize = RL_GetMonitorSize( monitor ) + local winSize = RL_GetWindowSize() + + RL_SetWindowTitle( "Waving cubes" ) + RL_SetWindowState( FLAG_WINDOW_RESIZABLE ) + RL_SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } ) + + camera = RL_CreateCamera3D() + RL_SetCamera3DPosition( camera, { 30, 20, 30 } ) + RL_SetCamera3DTarget( camera, { 0, 0, 0 } ) + RL_SetCamera3DUp( camera, { 0, 1, 0 } ) +end + +function draw() + local t = RL_GetTime() + + local scale = (2.0 + math.sin(t)) * 0.7 + local camera_time = t * 0.3 + local camera_pos = RL_GetCamera3DPosition( camera ) + + camera_pos[1] = math.cos(camera_time) * 40.0 + camera_pos[3] = math.sin(camera_time) * 40.0 + + RL_SetCamera3DPosition( camera, camera_pos ) + RL_ClearBackground( RAYWHITE ) + + RL_BeginMode3D( camera ) + RL_DrawGrid( 10, 5.0 ) + + for x = 0,num_blocks - 1 do + for y = 0,num_blocks - 1 do + for z = 0,num_blocks - 1 do + local block_scale = (x + y + z) / 30 + local scatter = math.sin(block_scale * 20.0 + t * 4.0) + + local cube_pos = { + (x - num_blocks / 2) * (scale * 3.0) + scatter, + (y - num_blocks / 2) * (scale * 2.0) + scatter, + (z - num_blocks / 2) * (scale * 3.0) + scatter + } + local cube_color = RL_ColorFromHSV( (((x + y + z) * 18) % 360), 0.75, 0.9 ) + local cube_size = (2.4 - scale) * block_scale + + RL_DrawCube( cube_pos, { cube_size, cube_size, cube_size }, cube_color ) + end + end + end + RL_EndMode3D() + + RL_DrawFPS( { 10, 10 } ) +end diff --git a/examples/window/main.lua b/examples/window/main.lua index d49d96a..ec25dd3 100644 --- a/examples/window/main.lua +++ b/examples/window/main.lua @@ -18,6 +18,6 @@ function process( delta ) end function draw() - RL_ClearBackground( RAYWHITE ); - RL_DrawText( 0, "Congrats! You created your first window!", textPos, 20, 2, textColor ); + RL_ClearBackground( RAYWHITE ) + RL_DrawText( 0, "Congrats! You created your first window!", textPos, 20, 2, textColor ) end diff --git a/include/main.h b/include/main.h index 64b2578..def4e15 100644 --- a/include/main.h +++ b/include/main.h @@ -4,21 +4,7 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 1 - -// #define WIN32_LEAN_AND_MEAN -// #if defined(_WIN32) -// #define WIN32 -// #endif -// #if defined(_WIN64) -// #define WIN64 -// #define _AMD64_ -// #undef _X86_ -// #else -// #undef _AMD64_ -// #define _X86_ -// #endif - -// #include <minwindef.h> +#define VERSION_PATCH 0 #include <stdio.h> #include <stdlib.h> @@ -33,12 +19,4 @@ #include <lualib.h> #include <lauxlib.h> -#include <stdint.h> - -// #ifdef _WIN32 -// // #include <windows.h> -// #include <windef.h> -// #include <mmsystem.h> -// // #include <winbase.h> -// // #define APIENTRY WINAPI -// #endif +// #include <stdint.h> diff --git a/include/text.h b/include/text.h index 6e53c70..e9cced8 100644 --- a/include/text.h +++ b/include/text.h @@ -5,4 +5,5 @@ bool validFont( size_t id ); /* Loading. */ int lmodelsLoadFont( lua_State *L ); /* Drawing. */ +int ltextDrawFPS( lua_State *L ); int ltextDrawText( lua_State *L ); diff --git a/include/textures.h b/include/textures.h index 1a56614..c759904 100644 --- a/include/textures.h +++ b/include/textures.h @@ -42,3 +42,5 @@ int ltexturesGenTextureMipmaps( lua_State *L ); int ltexturesSetTextureFilter( lua_State *L ); int ltexturesSetTextureWrap( lua_State *L ); int ltexturesGetTextureSize( lua_State *L ); +/* Color/pixel */ +int ltexturesColorFromHSV( lua_State *L ); diff --git a/src/lua_core.c b/src/lua_core.c index ab59c1d..1ee21de 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -114,7 +114,7 @@ void defineGlobals() { assignGlobalInt( NPATCH_NINE_PATCH, "NPATCH_NINE_PATCH" ); assignGlobalInt( NPATCH_THREE_PATCH_VERTICAL, "NPATCH_THREE_PATCH_VERTICAL" ); assignGlobalInt( NPATCH_THREE_PATCH_HORIZONTAL, "NPATCH_THREE_PATCH_HORIZONTAL" ); - /* Shader location index */ + /* ShaderLocationIndex */ assignGlobalInt( SHADER_LOC_VERTEX_POSITION, "SHADER_LOC_VERTEX_POSITION" ); assignGlobalInt( SHADER_LOC_VERTEX_TEXCOORD01, "SHADER_LOC_VERTEX_TEXCOORD01" ); assignGlobalInt( SHADER_LOC_VERTEX_TEXCOORD02, "SHADER_LOC_VERTEX_TEXCOORD02" ); @@ -141,7 +141,7 @@ void defineGlobals() { assignGlobalInt( SHADER_LOC_MAP_IRRADIANCE, "SHADER_LOC_MAP_IRRADIANCE" ); assignGlobalInt( SHADER_LOC_MAP_PREFILTER, "SHADER_LOC_MAP_PREFILTER" ); assignGlobalInt( SHADER_LOC_MAP_BRDF, "SHADER_LOC_MAP_BRDF" ); - /* Shader uniform data type */ + /* ShaderUniformDataType */ assignGlobalInt( SHADER_UNIFORM_FLOAT, "SHADER_UNIFORM_FLOAT" ); assignGlobalInt( SHADER_UNIFORM_VEC2, "SHADER_UNIFORM_VEC2" ); assignGlobalInt( SHADER_UNIFORM_VEC3, "SHADER_UNIFORM_VEC3" ); @@ -151,7 +151,7 @@ void defineGlobals() { assignGlobalInt( SHADER_UNIFORM_IVEC3, "SHADER_UNIFORM_IVEC3" ); assignGlobalInt( SHADER_UNIFORM_IVEC4, "SHADER_UNIFORM_IVEC4" ); assignGlobalInt( SHADER_UNIFORM_SAMPLER2D, "SHADER_UNIFORM_SAMPLER2D" ); - /* Shader attribute data types */ + /* ShaderAttributeDataTypes */ assignGlobalInt( SHADER_ATTRIB_FLOAT, "SHADER_ATTRIB_FLOAT" ); assignGlobalInt( SHADER_ATTRIB_VEC2, "SHADER_ATTRIB_VEC2" ); assignGlobalInt( SHADER_ATTRIB_VEC3, "SHADER_ATTRIB_VEC3" ); @@ -215,6 +215,11 @@ bool luaCallMain() { sprintf( path, "%smain.lua", state->exePath ); + /* Alternatively look for main. Could be precompiled binary file. */ + if ( !FileExists( path ) ) { + sprintf( path, "%smain", state->exePath ); + } + luaL_dofile( L, path ); /* Check errors in main.lua */ @@ -451,6 +456,8 @@ void luaRegister() { lua_register( L, "RL_SetTextureWrap", ltexturesSetTextureWrap ); lua_register( L, "RL_GetTextureSize", ltexturesGetTextureSize ); + lua_register( L, "RL_ColorFromHSV", ltexturesColorFromHSV ); + /* Models. */ /* Basic. */ lua_register( L, "RL_DrawLine3D", lmodelsDrawLine3D ); @@ -523,6 +530,7 @@ void luaRegister() { /* Loading. */ lua_register( L, "RL_LoadFont", lmodelsLoadFont ); /* Drawing. */ + lua_register( L, "RL_DrawFPS", ltextDrawFPS ); lua_register( L, "RL_DrawText", ltextDrawText ); /* Audio. */ @@ -7,7 +7,7 @@ int main( int argn, const char **argc ) { if ( 1 < argn ) { if ( strcmp( argc[1], "--version" ) == 0 || strcmp( argc[1], "-v" ) == 0 ) { - printf( "ReiLua %d.%d\n", VERSION_MAJOR, VERSION_MINOR ); + printf( "ReiLua %d.%d.%d\n", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH ); return 1; } @@ -66,6 +66,28 @@ int lmodelsLoadFont( lua_State *L ) { */ /* +> success = RL_DrawFPS( Vector2 pos ) + +Draw current FPS + +- Failure return false +- Success return true +*/ +int ltextDrawFPS( lua_State *L ) { + if ( !lua_istable( L, -1 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_DrawFPS( Vector2 pos )" ); + lua_pushboolean( L, false ); + return 1; + } + Vector2 pos = uluaGetVector2( L ); + + DrawFPS( pos.x, pos.y ); + lua_pushboolean( L, true ); + + return 1; +} + +/* > success = RL_DrawText( Font font, string text, Vector2 position, float fontSize, float spacing, Color tint ) Draw text using font and additional parameters diff --git a/src/textures.c b/src/textures.c index b147fff..f28bd0f 100644 --- a/src/textures.c +++ b/src/textures.c @@ -1055,3 +1055,26 @@ int ltexturesGetTextureSize( lua_State *L ) { return 1; } + +/* +## Textures - Color/pixel +*/ + +/* +> color = RL_ColorFromHSV( float hue, float saturation, float value ) + +Returns a Color from HSV values, hue [0..360], saturation/value [0..1] + +- Failure return false +- Success return Color +*/ +int ltexturesColorFromHSV( lua_State *L ) { + if ( !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_ColorFromHSV( float hue, float saturation, float value )" ); + lua_pushboolean( L, false ); + return 1; + } + uluaPushColor( L, ColorFromHSV( lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) ); + + return 1; +} |
