summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjussi2022-02-21 19:05:05 +0200
committerjussi2022-02-21 19:05:05 +0200
commit612ede6da40550fc0b14c1370f616fc6e83df550 (patch)
tree788e0d00820ee85209506c78ec76d397a617cd03 /src
parent8182a5f1b6c61bdf95d32a4ad102e1762f0d0924 (diff)
downloadreilua-enhanced-612ede6da40550fc0b14c1370f616fc6e83df550.tar.gz
reilua-enhanced-612ede6da40550fc0b14c1370f616fc6e83df550.tar.bz2
reilua-enhanced-612ede6da40550fc0b14c1370f616fc6e83df550.zip
Documentation. waving_cubes example and RL_DrawFPS and RL_ColorFromHSV.
Diffstat (limited to 'src')
-rw-r--r--src/lua_core.c14
-rw-r--r--src/main.c2
-rw-r--r--src/text.c22
-rw-r--r--src/textures.c23
4 files changed, 57 insertions, 4 deletions
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. */
diff --git a/src/main.c b/src/main.c
index e9d5db2..ad64d24 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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;
}
diff --git a/src/text.c b/src/text.c
index 0637971..bd6dea5 100644
--- a/src/text.c
+++ b/src/text.c
@@ -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;
+}