Material getter and get/set for parameters.
This commit is contained in:
56
API.md
56
API.md
@@ -673,7 +673,7 @@ NPATCH_THREE_PATCH_VERTICAL
|
|||||||
|
|
||||||
NPATCH_THREE_PATCH_HORIZONTAL
|
NPATCH_THREE_PATCH_HORIZONTAL
|
||||||
|
|
||||||
## Globals - TextureModes
|
## Globals - TextureTypes
|
||||||
|
|
||||||
TEXTURE_TYPE_TEXTURE
|
TEXTURE_TYPE_TEXTURE
|
||||||
|
|
||||||
@@ -4379,6 +4379,60 @@ Set shader for material
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
> success = RL.SetMaterialParams( Material material, float{} params )
|
||||||
|
|
||||||
|
Set material generic parameters ( if required )
|
||||||
|
|
||||||
|
- Failure return false
|
||||||
|
- Success return true
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> texture = RL.GetMaterialTexture( Material material, int mapType )
|
||||||
|
|
||||||
|
Get texture from material map type. Returns -1 if no texture.
|
||||||
|
|
||||||
|
- Failure return false
|
||||||
|
- Success return int
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> color = RL.GetMaterialColor( Material material, int mapType )
|
||||||
|
|
||||||
|
Get color from material map type.
|
||||||
|
|
||||||
|
- Failure return false
|
||||||
|
- Success return Color
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> value = RL.GetMaterialValue( Material material, int mapType )
|
||||||
|
|
||||||
|
Get color from material map type.
|
||||||
|
|
||||||
|
- Failure return false
|
||||||
|
- Success return float
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> shader = RL.GetMaterialShader( Material material )
|
||||||
|
|
||||||
|
Get material shader. Returns -1 if no shader.
|
||||||
|
|
||||||
|
- Failure return false
|
||||||
|
- Success return int
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> params = RL.GetMaterialParams( Material material )
|
||||||
|
|
||||||
|
Get material parameters.
|
||||||
|
|
||||||
|
- Failure return false
|
||||||
|
- Success return float{}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Models - Model
|
## Models - Model
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -379,7 +379,7 @@ RL.NPATCH_NINE_PATCH=0
|
|||||||
RL.NPATCH_THREE_PATCH_VERTICAL=1
|
RL.NPATCH_THREE_PATCH_VERTICAL=1
|
||||||
RL.NPATCH_THREE_PATCH_HORIZONTAL=2
|
RL.NPATCH_THREE_PATCH_HORIZONTAL=2
|
||||||
|
|
||||||
-- Globals - TextureModes
|
-- Globals - TextureTypes
|
||||||
|
|
||||||
RL.TEXTURE_TYPE_TEXTURE=0
|
RL.TEXTURE_TYPE_TEXTURE=0
|
||||||
RL.TEXTURE_TYPE_RENDER_TEXTURE=1
|
RL.TEXTURE_TYPE_RENDER_TEXTURE=1
|
||||||
@@ -3408,6 +3408,52 @@ function RL.SetMaterialValue( material, mapType, value ) end
|
|||||||
---@return any success
|
---@return any success
|
||||||
function RL.SetMaterialShader( material, shader ) end
|
function RL.SetMaterialShader( material, shader ) end
|
||||||
|
|
||||||
|
---Set material generic parameters ( if required )
|
||||||
|
---- Failure return false
|
||||||
|
---- Success return true
|
||||||
|
---@param material any
|
||||||
|
---@param params any
|
||||||
|
---@return any success
|
||||||
|
function RL.SetMaterialParams( material, params ) end
|
||||||
|
|
||||||
|
---Get texture from material map type. Returns -1 if no texture.
|
||||||
|
---- Failure return false
|
||||||
|
---- Success return int
|
||||||
|
---@param material any
|
||||||
|
---@param mapType integer
|
||||||
|
---@return any texture
|
||||||
|
function RL.GetMaterialTexture( material, mapType ) end
|
||||||
|
|
||||||
|
---Get color from material map type.
|
||||||
|
---- Failure return false
|
||||||
|
---- Success return Color
|
||||||
|
---@param material any
|
||||||
|
---@param mapType integer
|
||||||
|
---@return any color
|
||||||
|
function RL.GetMaterialColor( material, mapType ) end
|
||||||
|
|
||||||
|
---Get color from material map type.
|
||||||
|
---- Failure return false
|
||||||
|
---- Success return float
|
||||||
|
---@param material any
|
||||||
|
---@param mapType integer
|
||||||
|
---@return any value
|
||||||
|
function RL.GetMaterialValue( material, mapType ) end
|
||||||
|
|
||||||
|
---Get material shader. Returns -1 if no shader.
|
||||||
|
---- Failure return false
|
||||||
|
---- Success return int
|
||||||
|
---@param material any
|
||||||
|
---@return any shader
|
||||||
|
function RL.GetMaterialShader( material ) end
|
||||||
|
|
||||||
|
---Get material parameters.
|
||||||
|
---- Failure return false
|
||||||
|
---- Success return float{}
|
||||||
|
---@param material any
|
||||||
|
---@return any params
|
||||||
|
function RL.GetMaterialParams( material ) end
|
||||||
|
|
||||||
-- Models - Model
|
-- Models - Model
|
||||||
|
|
||||||
---Load model from files ( Meshes and materials )
|
---Load model from files ( Meshes and materials )
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ KEY CHANGES:
|
|||||||
- ADDED: Raygui wrapper lib.
|
- ADDED: Raygui wrapper lib.
|
||||||
- CHANGED: Can now have multiple Music objects like other Raylib objects instead of just one.
|
- CHANGED: Can now have multiple Music objects like other Raylib objects instead of just one.
|
||||||
- CHANGED: Texture now can be either Texture or RenderTexture. No need to change texture source anymore.
|
- CHANGED: Texture now can be either Texture or RenderTexture. No need to change texture source anymore.
|
||||||
|
- ADDED: Material getter functions.
|
||||||
|
|
||||||
Detailed changes:
|
Detailed changes:
|
||||||
- FIXED: uluaGetRay was looking for integers instead of tables.
|
- FIXED: uluaGetRay was looking for integers instead of tables.
|
||||||
@@ -71,6 +72,8 @@ Detailed changes:
|
|||||||
- ADDED: DrawBillboardPro
|
- ADDED: DrawBillboardPro
|
||||||
- ADDED: rlGetVersion
|
- ADDED: rlGetVersion
|
||||||
- ADDED: More rlgl General render state functions.
|
- ADDED: More rlgl General render state functions.
|
||||||
|
- ADDED: GetMaterialTexture, GetMaterialColor, GetMaterialValue and GetMaterialShader
|
||||||
|
- ADDED: SetMaterialParams and GetMaterialParams
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
Release: ReiLua version 0.4.0 Using Raylib 4.2
|
Release: ReiLua version 0.4.0 Using Raylib 4.2
|
||||||
|
|||||||
4
devnotes
4
devnotes
@@ -34,3 +34,7 @@ Backlog {
|
|||||||
* UpdateMesh
|
* UpdateMesh
|
||||||
* LoadModelFromMesh
|
* LoadModelFromMesh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bugs {
|
||||||
|
* CameraLib. Lateral movement is slower if looking down or up.
|
||||||
|
}
|
||||||
@@ -71,7 +71,8 @@ end
|
|||||||
function RL.draw()
|
function RL.draw()
|
||||||
RL.ClearBackground( RL.RAYWHITE )
|
RL.ClearBackground( RL.RAYWHITE )
|
||||||
|
|
||||||
for _, bunny in ipairs( bunnies ) do
|
for i = 1, #bunnies do
|
||||||
|
local bunny = bunnies[i]
|
||||||
-- NOTE: When internal batch buffer limit is reached (MAX_BATCH_ELEMENTS),
|
-- NOTE: When internal batch buffer limit is reached (MAX_BATCH_ELEMENTS),
|
||||||
-- a draw call is launched and buffer starts being filled again;
|
-- a draw call is launched and buffer starts being filled again;
|
||||||
-- before issuing a draw call, updated vertex data from internal CPU buffer is send to GPU...
|
-- before issuing a draw call, updated vertex data from internal CPU buffer is send to GPU...
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ function RL.init()
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
material = RL.CreateMaterial( materialData )
|
material = RL.CreateMaterial( materialData )
|
||||||
|
|
||||||
matrix = RL.MatrixMultiply( RL.MatrixIdentity(), RL.MatrixTranslate( { -4, 0, -4 } ) )
|
matrix = RL.MatrixMultiply( RL.MatrixIdentity(), RL.MatrixTranslate( { -4, 0, -4 } ) )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,12 @@ int lmodelsSetMaterialTexture( lua_State *L );
|
|||||||
int lmodelsSetMaterialColor( lua_State *L );
|
int lmodelsSetMaterialColor( lua_State *L );
|
||||||
int lmodelsSetMaterialValue( lua_State *L );
|
int lmodelsSetMaterialValue( lua_State *L );
|
||||||
int lmodelsSetMaterialShader( lua_State *L );
|
int lmodelsSetMaterialShader( lua_State *L );
|
||||||
|
int lmodelsSetMaterialParams( lua_State *L );
|
||||||
|
int lmodelsGetMaterialTexture( lua_State *L );
|
||||||
|
int lmodelsGetMaterialColor( lua_State *L );
|
||||||
|
int lmodelsGetMaterialValue( lua_State *L );
|
||||||
|
int lmodelsGetMaterialShader( lua_State *L );
|
||||||
|
int lmodelsGetMaterialParams( lua_State *L );
|
||||||
/* Model. */
|
/* Model. */
|
||||||
int lmodelsLoadModel( lua_State *L );
|
int lmodelsLoadModel( lua_State *L );
|
||||||
int lmodelsLoadModelFromMesh( lua_State *L );
|
int lmodelsLoadModelFromMesh( lua_State *L );
|
||||||
|
|||||||
@@ -17,21 +17,18 @@
|
|||||||
static void assignGlobalInt( int value, const char *name ) {
|
static void assignGlobalInt( int value, const char *name ) {
|
||||||
lua_State *L = state->luaState;
|
lua_State *L = state->luaState;
|
||||||
lua_pushinteger( L, value );
|
lua_pushinteger( L, value );
|
||||||
// lua_setglobal( L, name );
|
|
||||||
lua_setfield( L, -2, name );
|
lua_setfield( L, -2, name );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void assignGlobalFloat( float value, const char *name ) {
|
static void assignGlobalFloat( float value, const char *name ) {
|
||||||
lua_State *L = state->luaState;
|
lua_State *L = state->luaState;
|
||||||
lua_pushnumber( L, value );
|
lua_pushnumber( L, value );
|
||||||
// lua_setglobal( L, name );
|
|
||||||
lua_setfield( L, -2, name );
|
lua_setfield( L, -2, name );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void assignGlobalColor( Color color, const char *name ) {
|
static void assignGlobalColor( Color color, const char *name ) {
|
||||||
lua_State *L = state->luaState;
|
lua_State *L = state->luaState;
|
||||||
uluaPushColor( L, color );
|
uluaPushColor( L, color );
|
||||||
// lua_setglobal( L, name );
|
|
||||||
lua_setfield( L, -2, name );
|
lua_setfield( L, -2, name );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,7 +365,7 @@ void defineGlobals() {
|
|||||||
assignGlobalInt( NPATCH_NINE_PATCH, "NPATCH_NINE_PATCH" );
|
assignGlobalInt( NPATCH_NINE_PATCH, "NPATCH_NINE_PATCH" );
|
||||||
assignGlobalInt( NPATCH_THREE_PATCH_VERTICAL, "NPATCH_THREE_PATCH_VERTICAL" );
|
assignGlobalInt( NPATCH_THREE_PATCH_VERTICAL, "NPATCH_THREE_PATCH_VERTICAL" );
|
||||||
assignGlobalInt( NPATCH_THREE_PATCH_HORIZONTAL, "NPATCH_THREE_PATCH_HORIZONTAL" );
|
assignGlobalInt( NPATCH_THREE_PATCH_HORIZONTAL, "NPATCH_THREE_PATCH_HORIZONTAL" );
|
||||||
/* TextureModes */
|
/* TextureTypes */
|
||||||
assignGlobalInt( TEXTURE_TYPE_TEXTURE, "TEXTURE_TYPE_TEXTURE" );
|
assignGlobalInt( TEXTURE_TYPE_TEXTURE, "TEXTURE_TYPE_TEXTURE" );
|
||||||
assignGlobalInt( TEXTURE_TYPE_RENDER_TEXTURE, "TEXTURE_TYPE_RENDER_TEXTURE" );
|
assignGlobalInt( TEXTURE_TYPE_RENDER_TEXTURE, "TEXTURE_TYPE_RENDER_TEXTURE" );
|
||||||
/* Colors */
|
/* Colors */
|
||||||
@@ -1088,6 +1085,12 @@ void luaRegister() {
|
|||||||
assingGlobalFunction( "SetMaterialColor", lmodelsSetMaterialColor );
|
assingGlobalFunction( "SetMaterialColor", lmodelsSetMaterialColor );
|
||||||
assingGlobalFunction( "SetMaterialValue", lmodelsSetMaterialValue );
|
assingGlobalFunction( "SetMaterialValue", lmodelsSetMaterialValue );
|
||||||
assingGlobalFunction( "SetMaterialShader", lmodelsSetMaterialShader );
|
assingGlobalFunction( "SetMaterialShader", lmodelsSetMaterialShader );
|
||||||
|
assingGlobalFunction( "SetMaterialParams", lmodelsSetMaterialParams );
|
||||||
|
assingGlobalFunction( "GetMaterialTexture", lmodelsGetMaterialTexture );
|
||||||
|
assingGlobalFunction( "GetMaterialColor", lmodelsGetMaterialColor );
|
||||||
|
assingGlobalFunction( "GetMaterialValue", lmodelsGetMaterialValue );
|
||||||
|
assingGlobalFunction( "GetMaterialShader", lmodelsGetMaterialShader );
|
||||||
|
assingGlobalFunction( "GetMaterialParams", lmodelsGetMaterialParams );
|
||||||
/* Model. */
|
/* Model. */
|
||||||
assingGlobalFunction( "LoadModel", lmodelsLoadModel );
|
assingGlobalFunction( "LoadModel", lmodelsLoadModel );
|
||||||
assingGlobalFunction( "LoadModelFromMesh", lmodelsLoadModelFromMesh );
|
assingGlobalFunction( "LoadModelFromMesh", lmodelsLoadModelFromMesh );
|
||||||
|
|||||||
200
src/models.c
200
src/models.c
@@ -1768,7 +1768,6 @@ int lmodelsSetMaterialTexture( lua_State *L ) {
|
|||||||
lua_pushboolean( L, false );
|
lua_pushboolean( L, false );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetMaterialTexture( state->materials[ materialId ], mapType, *texturesGetSourceTexture( texId ) );
|
SetMaterialTexture( state->materials[ materialId ], mapType, *texturesGetSourceTexture( texId ) );
|
||||||
lua_pushboolean( L, true );
|
lua_pushboolean( L, true );
|
||||||
|
|
||||||
@@ -1797,7 +1796,6 @@ int lmodelsSetMaterialColor( lua_State *L ) {
|
|||||||
lua_pushboolean( L, false );
|
lua_pushboolean( L, false );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
state->materials[ materialId ]->maps[ mapType ].color = color;
|
state->materials[ materialId ]->maps[ mapType ].color = color;
|
||||||
lua_pushboolean( L, true );
|
lua_pushboolean( L, true );
|
||||||
|
|
||||||
@@ -1826,7 +1824,6 @@ int lmodelsSetMaterialValue( lua_State *L ) {
|
|||||||
lua_pushboolean( L, false );
|
lua_pushboolean( L, false );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
state->materials[ materialId ]->maps[ mapType ].value = value;
|
state->materials[ materialId ]->maps[ mapType ].value = value;
|
||||||
lua_pushboolean( L, true );
|
lua_pushboolean( L, true );
|
||||||
|
|
||||||
@@ -1854,13 +1851,208 @@ int lmodelsSetMaterialShader( lua_State *L ) {
|
|||||||
lua_pushboolean( L, false );
|
lua_pushboolean( L, false );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
state->materials[ materialId ]->shader = *state->shaders[ shaderId ];
|
state->materials[ materialId ]->shader = *state->shaders[ shaderId ];
|
||||||
lua_pushboolean( L, true );
|
lua_pushboolean( L, true );
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> success = RL.SetMaterialParams( Material material, float{} params )
|
||||||
|
|
||||||
|
Set material generic parameters ( if required )
|
||||||
|
|
||||||
|
- Failure return false
|
||||||
|
- Success return true
|
||||||
|
*/
|
||||||
|
int lmodelsSetMaterialParams( lua_State *L ) {
|
||||||
|
if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) ) {
|
||||||
|
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetMaterialParams( Material material, float{} params )" );
|
||||||
|
lua_pushboolean( L, false );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
size_t len = uluaGetTableLen( L );
|
||||||
|
size_t materialId = lua_tointeger( L, 1 );
|
||||||
|
|
||||||
|
if ( !validMaterial( materialId ) ) {
|
||||||
|
lua_pushboolean( L, false );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
float params[ len ];
|
||||||
|
|
||||||
|
int t = lua_gettop( L );
|
||||||
|
int i = 0;
|
||||||
|
lua_pushnil( L );
|
||||||
|
|
||||||
|
while ( lua_next( L, t ) != 0 ) {
|
||||||
|
params[i] = lua_tonumber( L, -1 );
|
||||||
|
i++;
|
||||||
|
lua_pop( L, 1 );
|
||||||
|
}
|
||||||
|
int paramCount = ( len > 4 ) ? 4 : len;
|
||||||
|
|
||||||
|
for ( int i = 0; i < paramCount; i++ ) {
|
||||||
|
state->materials[ materialId ]->params[i] = params[i];
|
||||||
|
}
|
||||||
|
lua_pushboolean( L, true );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> texture = RL.GetMaterialTexture( Material material, int mapType )
|
||||||
|
|
||||||
|
Get texture from material map type. Returns -1 if no texture.
|
||||||
|
|
||||||
|
- Failure return false
|
||||||
|
- Success return int
|
||||||
|
*/
|
||||||
|
int lmodelsGetMaterialTexture( lua_State *L ) {
|
||||||
|
if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) {
|
||||||
|
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GetMaterialTexture( Material material, int mapType )" );
|
||||||
|
lua_pushboolean( L, false );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
size_t materialId = lua_tointeger( L, 1 );
|
||||||
|
int mapType = lua_tointeger( L, 2 );
|
||||||
|
|
||||||
|
if ( !validMaterial( materialId ) ) {
|
||||||
|
lua_pushboolean( L, false );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/* Check what ReiLua texture has same openGL texture and return that. */
|
||||||
|
for ( int i = 0; i < state->textureCount; i++ ) {
|
||||||
|
if ( state->textures[i]->type == TEXTURE_TYPE_TEXTURE
|
||||||
|
&& state->textures[i]->texture.id == state->materials[ materialId ]->maps[ mapType ].texture.id ) {
|
||||||
|
lua_pushinteger( L, i );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if ( state->textures[i]->type == TEXTURE_TYPE_RENDER_TEXTURE
|
||||||
|
&& state->textures[i]->renderTexture.texture.id == state->materials[ materialId ]->maps[ mapType ].texture.id ) {
|
||||||
|
lua_pushinteger( L, i );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lua_pushinteger( L, -1 );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> color = RL.GetMaterialColor( Material material, int mapType )
|
||||||
|
|
||||||
|
Get color from material map type.
|
||||||
|
|
||||||
|
- Failure return false
|
||||||
|
- Success return Color
|
||||||
|
*/
|
||||||
|
int lmodelsGetMaterialColor( lua_State *L ) {
|
||||||
|
if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) {
|
||||||
|
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GetMaterialColor( Material material, int mapType )" );
|
||||||
|
lua_pushboolean( L, false );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
size_t materialId = lua_tointeger( L, 1 );
|
||||||
|
int mapType = lua_tointeger( L, 2 );
|
||||||
|
|
||||||
|
if ( !validMaterial( materialId ) ) {
|
||||||
|
lua_pushboolean( L, false );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
uluaPushColor( L, state->materials[ materialId ]->maps[ mapType ].color );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> value = RL.GetMaterialValue( Material material, int mapType )
|
||||||
|
|
||||||
|
Get color from material map type.
|
||||||
|
|
||||||
|
- Failure return false
|
||||||
|
- Success return float
|
||||||
|
*/
|
||||||
|
int lmodelsGetMaterialValue( lua_State *L ) {
|
||||||
|
if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) {
|
||||||
|
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GetMaterialValue( Material material, int mapType )" );
|
||||||
|
lua_pushboolean( L, false );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
size_t materialId = lua_tointeger( L, 1 );
|
||||||
|
int mapType = lua_tointeger( L, 2 );
|
||||||
|
|
||||||
|
if ( !validMaterial( materialId ) ) {
|
||||||
|
lua_pushboolean( L, false );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
lua_pushnumber( L, state->materials[ materialId ]->maps[ mapType ].value );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> shader = RL.GetMaterialShader( Material material )
|
||||||
|
|
||||||
|
Get material shader. Returns -1 if no shader.
|
||||||
|
|
||||||
|
- Failure return false
|
||||||
|
- Success return int
|
||||||
|
*/
|
||||||
|
int lmodelsGetMaterialShader( lua_State *L ) {
|
||||||
|
if ( !lua_isnumber( L, 1 ) ) {
|
||||||
|
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GetMaterialShader( Material material )" );
|
||||||
|
lua_pushboolean( L, false );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
size_t materialId = lua_tointeger( L, 1 );
|
||||||
|
|
||||||
|
if ( !validMaterial( materialId ) ) {
|
||||||
|
lua_pushboolean( L, false );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/* Look for shader that has same shader program id. */
|
||||||
|
for ( int i = 0; i < state->shaderCount; i++ ) {
|
||||||
|
if ( state->shaders[i]->id == state->materials[ materialId ]->shader.id ) {
|
||||||
|
lua_pushinteger( L, i );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lua_pushinteger( L, -1 );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> params = RL.GetMaterialParams( Material material )
|
||||||
|
|
||||||
|
Get material parameters.
|
||||||
|
|
||||||
|
- Failure return false
|
||||||
|
- Success return float{}
|
||||||
|
*/
|
||||||
|
int lmodelsGetMaterialParams( lua_State *L ) {
|
||||||
|
if ( !lua_isnumber( L, 1 ) ) {
|
||||||
|
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GetMaterialParams( Material material )" );
|
||||||
|
lua_pushboolean( L, false );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
size_t materialId = lua_tointeger( L, 1 );
|
||||||
|
|
||||||
|
if ( !validMaterial( materialId ) ) {
|
||||||
|
lua_pushboolean( L, false );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
Vector4 params = {
|
||||||
|
state->materials[ materialId ]->params[0],
|
||||||
|
state->materials[ materialId ]->params[1],
|
||||||
|
state->materials[ materialId ]->params[2],
|
||||||
|
state->materials[ materialId ]->params[3]
|
||||||
|
};
|
||||||
|
uluaPushVector4( L, params );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
## Models - Model
|
## Models - Model
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user