Shaders management functions.
This commit is contained in:
65
API.md
65
API.md
@@ -6854,15 +6854,76 @@ Delete framebuffer from GPU
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
> success = RL.rlLoadShaderCode( string vsCode, string fsCode )
|
> shaderId = RL.rlLoadShaderCode( string vsCode, string fsCode )
|
||||||
|
|
||||||
Load shader from code strings
|
Load shader from code strings
|
||||||
|
|
||||||
- Failure return nil
|
|
||||||
- Success return int
|
- Success return int
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
> shaderId = RL.rlCompileShader( string shaderCode, int type )
|
||||||
|
|
||||||
|
Compile custom shader and return shader id (type: RL_VERTEX_SHADER, RL_FRAGMENT_SHADER, RL_COMPUTE_SHADER)
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> shaderProgramId = RL.rlLoadShaderProgram( int vShaderId, int fShaderId )
|
||||||
|
|
||||||
|
Load custom shader program
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> RL.rlUnloadShaderProgram( int id )
|
||||||
|
|
||||||
|
Unload shader program
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> location = RL.rlGetLocationUniform( int shaderId, string uniformName )
|
||||||
|
|
||||||
|
Get shader location uniform
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> location = RL.rlGetLocationAttrib( int shaderId, string attribName )
|
||||||
|
|
||||||
|
Get shader location attribute
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> RL.rlSetUniform( int locIndex, Buffer value, int uniformType, int count )
|
||||||
|
|
||||||
|
Set shader value uniform
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> RL.rlSetUniformMatrix( int locIndex, Matrix mat )
|
||||||
|
|
||||||
|
Set shader value matrix
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> RL.rlSetUniformSampler( int locIndex, int textureId )
|
||||||
|
|
||||||
|
Set shader value sampler
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> RL.rlSetShader( int id, int{} locs )
|
||||||
|
|
||||||
|
Set shader currently active (id and locations)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## RLGL - Matrix state management
|
## RLGL - Matrix state management
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -5496,13 +5496,71 @@ function RL.rlUnloadFramebuffer( id ) end
|
|||||||
-- RLGL - Shaders management
|
-- RLGL - Shaders management
|
||||||
|
|
||||||
---Load shader from code strings
|
---Load shader from code strings
|
||||||
---- Failure return nil
|
|
||||||
---- Success return int
|
---- Success return int
|
||||||
---@param vsCode string
|
---@param vsCode string
|
||||||
---@param fsCode string
|
---@param fsCode string
|
||||||
---@return any success
|
---@return any shaderId
|
||||||
function RL.rlLoadShaderCode( vsCode, fsCode ) end
|
function RL.rlLoadShaderCode( vsCode, fsCode ) end
|
||||||
|
|
||||||
|
---Compile custom shader and return shader id (type: RL_VERTEX_SHADER, RL_FRAGMENT_SHADER, RL_COMPUTE_SHADER)
|
||||||
|
---- Success return int
|
||||||
|
---@param shaderCode string
|
||||||
|
---@param type integer
|
||||||
|
---@return any shaderId
|
||||||
|
function RL.rlCompileShader( shaderCode, type ) end
|
||||||
|
|
||||||
|
---Load custom shader program
|
||||||
|
---- Success return int
|
||||||
|
---@param vShaderId integer
|
||||||
|
---@param fShaderId integer
|
||||||
|
---@return any shaderProgramId
|
||||||
|
function RL.rlLoadShaderProgram( vShaderId, fShaderId ) end
|
||||||
|
|
||||||
|
---Unload shader program
|
||||||
|
---@param id integer
|
||||||
|
---@return any RL.rlUnloadShaderProgram
|
||||||
|
function RL.rlUnloadShaderProgram( id ) end
|
||||||
|
|
||||||
|
---Get shader location uniform
|
||||||
|
---- Success return int
|
||||||
|
---@param shaderId integer
|
||||||
|
---@param uniformName string
|
||||||
|
---@return any location
|
||||||
|
function RL.rlGetLocationUniform( shaderId, uniformName ) end
|
||||||
|
|
||||||
|
---Get shader location attribute
|
||||||
|
---- Success return int
|
||||||
|
---@param shaderId integer
|
||||||
|
---@param attribName string
|
||||||
|
---@return any location
|
||||||
|
function RL.rlGetLocationAttrib( shaderId, attribName ) end
|
||||||
|
|
||||||
|
---Set shader value uniform
|
||||||
|
---@param locIndex integer
|
||||||
|
---@param value any
|
||||||
|
---@param uniformType integer
|
||||||
|
---@param count integer
|
||||||
|
---@return any RL.rlSetUniform
|
||||||
|
function RL.rlSetUniform( locIndex, value, uniformType, count ) end
|
||||||
|
|
||||||
|
---Set shader value matrix
|
||||||
|
---@param locIndex integer
|
||||||
|
---@param mat table
|
||||||
|
---@return any RL.rlSetUniformMatrix
|
||||||
|
function RL.rlSetUniformMatrix( locIndex, mat ) end
|
||||||
|
|
||||||
|
---Set shader value sampler
|
||||||
|
---@param locIndex integer
|
||||||
|
---@param textureId integer
|
||||||
|
---@return any RL.rlSetUniformSampler
|
||||||
|
function RL.rlSetUniformSampler( locIndex, textureId ) end
|
||||||
|
|
||||||
|
---Set shader currently active (id and locations)
|
||||||
|
---@param id integer
|
||||||
|
---@param locs any
|
||||||
|
---@return any RL.rlSetShader
|
||||||
|
function RL.rlSetShader( id, locs ) end
|
||||||
|
|
||||||
-- RLGL - Matrix state management
|
-- RLGL - Matrix state management
|
||||||
|
|
||||||
---Get internal modelview matrix
|
---Get internal modelview matrix
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ KEY CHANGES:
|
|||||||
- ADDED: Userdata objects can be referenced with lightuserdata.
|
- ADDED: Userdata objects can be referenced with lightuserdata.
|
||||||
- ADDED: GC_UNLOAD build time define for enabling/disabling Lua garbage collection for objects.
|
- ADDED: GC_UNLOAD build time define for enabling/disabling Lua garbage collection for objects.
|
||||||
Can be checked with IsGCUnloadEnabled
|
Can be checked with IsGCUnloadEnabled
|
||||||
|
- ADDED: Shaders management functions.
|
||||||
|
|
||||||
DETAILED CHANGES:
|
DETAILED CHANGES:
|
||||||
- CHANGED: GenImageColor now takes Vector2 as size.
|
- CHANGED: GenImageColor now takes Vector2 as size.
|
||||||
|
|||||||
3
devnotes
3
devnotes
@@ -3,7 +3,6 @@ Current {
|
|||||||
|
|
||||||
Backlog {
|
Backlog {
|
||||||
* rlgl
|
* rlgl
|
||||||
* Shaders management
|
|
||||||
* Compute shader management
|
* Compute shader management
|
||||||
* Text
|
* Text
|
||||||
* Codepoints?
|
* Codepoints?
|
||||||
@@ -38,4 +37,6 @@ Needs Testing {
|
|||||||
* UpdateMesh
|
* UpdateMesh
|
||||||
* LoadModelFromMesh
|
* LoadModelFromMesh
|
||||||
* RLGL - Matrix state management
|
* RLGL - Matrix state management
|
||||||
|
* rlSetUniform
|
||||||
|
* rlSetShader
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,6 +104,17 @@ int lrlglLoadFramebuffer( lua_State *L );
|
|||||||
int lrlglFramebufferAttach( lua_State *L );
|
int lrlglFramebufferAttach( lua_State *L );
|
||||||
int lrlglFramebufferComplete( lua_State *L );
|
int lrlglFramebufferComplete( lua_State *L );
|
||||||
int lrlglUnloadFramebuffer( lua_State *L );
|
int lrlglUnloadFramebuffer( lua_State *L );
|
||||||
|
/* Shaders management */
|
||||||
|
int lrlglLoadShaderCode( lua_State *L );
|
||||||
|
int lrlglCompileShader( lua_State *L );
|
||||||
|
int lrlglLoadShaderProgram( lua_State *L );
|
||||||
|
int lrlglUnloadShaderProgram( lua_State *L );
|
||||||
|
int lrlglGetLocationUniform( lua_State *L );
|
||||||
|
int lrlglGetLocationAttrib( lua_State *L );
|
||||||
|
int lrlglSetUniform( lua_State *L );
|
||||||
|
int lrlglSetUniformMatrix( lua_State *L );
|
||||||
|
int lrlglSetUniformSampler( lua_State *L );
|
||||||
|
int lrlglSetShader( lua_State *L );
|
||||||
/* Matrix state management */
|
/* Matrix state management */
|
||||||
int lrlglGetMatrixModelview( lua_State *L );
|
int lrlglGetMatrixModelview( lua_State *L );
|
||||||
int lrlglGetMatrixProjection( lua_State *L );
|
int lrlglGetMatrixProjection( lua_State *L );
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ typedef struct {
|
|||||||
int logLevelInvalid;
|
int logLevelInvalid;
|
||||||
Font defaultFont;
|
Font defaultFont;
|
||||||
Material defaultMaterial;
|
Material defaultMaterial;
|
||||||
|
int *RLGLcurrentShaderLocs;
|
||||||
/* Raylib GLFW input callback events. */
|
/* Raylib GLFW input callback events. */
|
||||||
/* Window events. */
|
/* Window events. */
|
||||||
GLFWwindowsizefun raylibWindowSizeCallback;
|
GLFWwindowsizefun raylibWindowSizeCallback;
|
||||||
|
|||||||
@@ -553,7 +553,6 @@ int lcoreLoadBuffer( lua_State *L ) {
|
|||||||
int type = luaL_checkinteger( L, 2 );
|
int type = luaL_checkinteger( L, 2 );
|
||||||
|
|
||||||
Buffer buffer = { 0 };
|
Buffer buffer = { 0 };
|
||||||
// Buffer *buffer = lua_newuserdata( L, sizeof( Buffer ) );
|
|
||||||
int len = uluaGetTableLenIndex( L, 1 );
|
int len = uluaGetTableLenIndex( L, 1 );
|
||||||
|
|
||||||
switch ( type ) {
|
switch ( type ) {
|
||||||
|
|||||||
@@ -2285,6 +2285,17 @@ void luaRegister() {
|
|||||||
assingGlobalFunction( "rlFramebufferAttach", lrlglFramebufferAttach );
|
assingGlobalFunction( "rlFramebufferAttach", lrlglFramebufferAttach );
|
||||||
assingGlobalFunction( "rlFramebufferComplete", lrlglFramebufferComplete );
|
assingGlobalFunction( "rlFramebufferComplete", lrlglFramebufferComplete );
|
||||||
assingGlobalFunction( "rlUnloadFramebuffer", lrlglUnloadFramebuffer );
|
assingGlobalFunction( "rlUnloadFramebuffer", lrlglUnloadFramebuffer );
|
||||||
|
/* Shaders management */
|
||||||
|
assingGlobalFunction( "rlLoadShaderCode", lrlglLoadShaderCode );
|
||||||
|
assingGlobalFunction( "rlCompileShader", lrlglCompileShader );
|
||||||
|
assingGlobalFunction( "rlLoadShaderProgram", lrlglLoadShaderProgram );
|
||||||
|
assingGlobalFunction( "rlUnloadShaderProgram", lrlglUnloadShaderProgram );
|
||||||
|
assingGlobalFunction( "rlGetLocationUniform", lrlglGetLocationUniform );
|
||||||
|
assingGlobalFunction( "rlGetLocationAttrib", lrlglGetLocationAttrib );
|
||||||
|
assingGlobalFunction( "rlSetUniform", lrlglSetUniform );
|
||||||
|
assingGlobalFunction( "rlSetUniformMatrix", lrlglSetUniformMatrix );
|
||||||
|
assingGlobalFunction( "rlSetUniformSampler", lrlglSetUniformSampler );
|
||||||
|
assingGlobalFunction( "rlSetShader", lrlglSetShader );
|
||||||
/* Matrix state management. */
|
/* Matrix state management. */
|
||||||
assingGlobalFunction( "rlGetMatrixModelview", lrlglGetMatrixModelview );
|
assingGlobalFunction( "rlGetMatrixModelview", lrlglGetMatrixModelview );
|
||||||
assingGlobalFunction( "rlGetMatrixProjection", lrlglGetMatrixProjection );
|
assingGlobalFunction( "rlGetMatrixProjection", lrlglGetMatrixProjection );
|
||||||
|
|||||||
171
src/rlgl.c
171
src/rlgl.c
@@ -928,7 +928,7 @@ Load a vertex buffer attribute
|
|||||||
- Success return int
|
- Success return int
|
||||||
*/
|
*/
|
||||||
int lrlglLoadVertexBuffer( lua_State *L ) {
|
int lrlglLoadVertexBuffer( lua_State *L ) {
|
||||||
Buffer *buffer = luaL_checkudata( L, 1, "Buffer" );
|
Buffer *buffer = uluaGetBuffer( L, 1 );
|
||||||
bool dynamic = uluaGetBoolean( L, 2 );
|
bool dynamic = uluaGetBoolean( L, 2 );
|
||||||
|
|
||||||
lua_pushinteger( L, rlLoadVertexBuffer( buffer->data, buffer->size, dynamic ) );
|
lua_pushinteger( L, rlLoadVertexBuffer( buffer->data, buffer->size, dynamic ) );
|
||||||
@@ -944,7 +944,7 @@ Load a new attributes element buffer
|
|||||||
- Success return int
|
- Success return int
|
||||||
*/
|
*/
|
||||||
int lrlglLoadVertexBufferElement( lua_State *L ) {
|
int lrlglLoadVertexBufferElement( lua_State *L ) {
|
||||||
Buffer *buffer = luaL_checkudata( L, 1, "Buffer" );
|
Buffer *buffer = uluaGetBuffer( L, 1 );
|
||||||
bool dynamic = uluaGetBoolean( L, 2 );
|
bool dynamic = uluaGetBoolean( L, 2 );
|
||||||
|
|
||||||
lua_pushinteger( L, rlLoadVertexBufferElement( buffer->data, buffer->size, dynamic ) );
|
lua_pushinteger( L, rlLoadVertexBufferElement( buffer->data, buffer->size, dynamic ) );
|
||||||
@@ -959,7 +959,7 @@ Update GPU buffer with new data
|
|||||||
*/
|
*/
|
||||||
int lrlglUpdateVertexBuffer( lua_State *L ) {
|
int lrlglUpdateVertexBuffer( lua_State *L ) {
|
||||||
int bufferId = luaL_checkinteger( L, 1 );
|
int bufferId = luaL_checkinteger( L, 1 );
|
||||||
Buffer *buffer = luaL_checkudata( L, 2, "Buffer" );
|
Buffer *buffer = uluaGetBuffer( L, 2 );
|
||||||
int offset = luaL_checkinteger( L, 3 );
|
int offset = luaL_checkinteger( L, 3 );
|
||||||
|
|
||||||
rlUpdateVertexBuffer( bufferId, buffer->data, buffer->size, offset );
|
rlUpdateVertexBuffer( bufferId, buffer->data, buffer->size, offset );
|
||||||
@@ -974,7 +974,7 @@ Update vertex buffer elements with new data
|
|||||||
*/
|
*/
|
||||||
int lrlglUpdateVertexBufferElements( lua_State *L ) {
|
int lrlglUpdateVertexBufferElements( lua_State *L ) {
|
||||||
int bufferId = luaL_checkinteger( L, 1 );
|
int bufferId = luaL_checkinteger( L, 1 );
|
||||||
Buffer *buffer = luaL_checkudata( L, 2, "Buffer" );
|
Buffer *buffer = uluaGetBuffer( L, 2 );
|
||||||
int offset = luaL_checkinteger( L, 3 );
|
int offset = luaL_checkinteger( L, 3 );
|
||||||
|
|
||||||
rlUpdateVertexBufferElements( bufferId, buffer->data, buffer->size, offset );
|
rlUpdateVertexBufferElements( bufferId, buffer->data, buffer->size, offset );
|
||||||
@@ -1083,7 +1083,7 @@ Draw vertex array elements
|
|||||||
int lrlglDrawVertexArrayElements( lua_State *L ) {
|
int lrlglDrawVertexArrayElements( lua_State *L ) {
|
||||||
int offset = luaL_checkinteger( L, 1 );
|
int offset = luaL_checkinteger( L, 1 );
|
||||||
int count = luaL_checkinteger( L, 2 );
|
int count = luaL_checkinteger( L, 2 );
|
||||||
Buffer *buffer = luaL_checkudata( L, 3, "Buffer" );
|
Buffer *buffer = uluaGetBuffer( L, 3 );
|
||||||
|
|
||||||
rlDrawVertexArrayElements( offset, count, buffer->data );
|
rlDrawVertexArrayElements( offset, count, buffer->data );
|
||||||
|
|
||||||
@@ -1113,7 +1113,7 @@ Draw vertex array elements instanced
|
|||||||
int lrlglDrawVertexArrayElementsInstanced( lua_State *L ) {
|
int lrlglDrawVertexArrayElementsInstanced( lua_State *L ) {
|
||||||
int offset = luaL_checkinteger( L, 1 );
|
int offset = luaL_checkinteger( L, 1 );
|
||||||
int count = luaL_checkinteger( L, 2 );
|
int count = luaL_checkinteger( L, 2 );
|
||||||
Buffer *buffer = luaL_checkudata( L, 3, "Buffer" );
|
Buffer *buffer = uluaGetBuffer( L, 3 );
|
||||||
int instances = luaL_checkinteger( L, 4 );
|
int instances = luaL_checkinteger( L, 4 );
|
||||||
|
|
||||||
rlDrawVertexArrayElementsInstanced( offset, count, buffer->data, instances );
|
rlDrawVertexArrayElementsInstanced( offset, count, buffer->data, instances );
|
||||||
@@ -1238,23 +1238,160 @@ int lrlglUnloadFramebuffer( lua_State *L ) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
> success = RL.rlLoadShaderCode( string vsCode, string fsCode )
|
> shaderId = RL.rlLoadShaderCode( string vsCode, string fsCode )
|
||||||
|
|
||||||
Load shader from code strings
|
Load shader from code strings
|
||||||
|
|
||||||
- Failure return nil
|
|
||||||
- Success return int
|
- Success return int
|
||||||
*/
|
*/
|
||||||
// int lrlglUnloadFramebuffer( lua_State *L ) {
|
int lrlglLoadShaderCode( lua_State *L ) {
|
||||||
// if ( !lua_isstring( L, 1 ) || !lua_isstring( L, 2 ) ) {
|
lua_pushinteger( L, rlLoadShaderCode( luaL_checkstring( L, 1 ), luaL_checkstring( L, 2 ) ) );
|
||||||
// TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlLoadShaderCode( string vsCode, string fsCode )" );
|
|
||||||
// lua_pushnil( L );
|
|
||||||
// return 1;
|
|
||||||
// }
|
|
||||||
// lua_pushinteger( L, rlLoadShaderCode( luaL_checkstring( L, 1 ), luaL_checkstring( L, 2 ) ) );
|
|
||||||
|
|
||||||
// return 1;
|
return 1;
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> shaderId = RL.rlCompileShader( string shaderCode, int type )
|
||||||
|
|
||||||
|
Compile custom shader and return shader id (type: RL_VERTEX_SHADER, RL_FRAGMENT_SHADER, RL_COMPUTE_SHADER)
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
*/
|
||||||
|
int lrlglCompileShader( lua_State *L ) {
|
||||||
|
int type = luaL_checkinteger( L, 2 );
|
||||||
|
|
||||||
|
lua_pushinteger( L, rlCompileShader( luaL_checkstring( L, 1 ), type ) );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> shaderProgramId = RL.rlLoadShaderProgram( int vShaderId, int fShaderId )
|
||||||
|
|
||||||
|
Load custom shader program
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
*/
|
||||||
|
int lrlglLoadShaderProgram( lua_State *L ) {
|
||||||
|
unsigned int vShaderId = (unsigned int)luaL_checkinteger( L, 1 );
|
||||||
|
unsigned int fShaderId = (unsigned int)luaL_checkinteger( L, 2 );
|
||||||
|
|
||||||
|
lua_pushinteger( L, rlLoadShaderProgram( vShaderId, fShaderId ) );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> RL.rlUnloadShaderProgram( int id )
|
||||||
|
|
||||||
|
Unload shader program
|
||||||
|
*/
|
||||||
|
int lrlglUnloadShaderProgram( lua_State *L ) {
|
||||||
|
unsigned int id = (unsigned int)luaL_checkinteger( L, 1 );
|
||||||
|
|
||||||
|
rlUnloadShaderProgram( id );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> location = RL.rlGetLocationUniform( int shaderId, string uniformName )
|
||||||
|
|
||||||
|
Get shader location uniform
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
*/
|
||||||
|
int lrlglGetLocationUniform( lua_State *L ) {
|
||||||
|
unsigned int shaderId = (unsigned int)luaL_checkinteger( L, 1 );
|
||||||
|
|
||||||
|
lua_pushinteger( L, rlGetLocationUniform( shaderId, luaL_checkstring( L, 2 ) ) );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> location = RL.rlGetLocationAttrib( int shaderId, string attribName )
|
||||||
|
|
||||||
|
Get shader location attribute
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
*/
|
||||||
|
int lrlglGetLocationAttrib( lua_State *L ) {
|
||||||
|
unsigned int shaderId = (unsigned int)luaL_checkinteger( L, 1 );
|
||||||
|
|
||||||
|
lua_pushinteger( L, rlGetLocationAttrib( shaderId, luaL_checkstring( L, 2 ) ) );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> RL.rlSetUniform( int locIndex, Buffer value, int uniformType, int count )
|
||||||
|
|
||||||
|
Set shader value uniform
|
||||||
|
*/
|
||||||
|
int lrlglSetUniform( lua_State *L ) {
|
||||||
|
int locIndex = luaL_checkinteger( L, 1 );
|
||||||
|
Buffer *value = uluaGetBuffer( L, 2 );
|
||||||
|
int uniformType = luaL_checkinteger( L, 3 );
|
||||||
|
int count = luaL_checkinteger( L, 4 );
|
||||||
|
|
||||||
|
rlSetUniform( locIndex, value->data, uniformType, count );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> RL.rlSetUniformMatrix( int locIndex, Matrix mat )
|
||||||
|
|
||||||
|
Set shader value matrix
|
||||||
|
*/
|
||||||
|
int lrlglSetUniformMatrix( lua_State *L ) {
|
||||||
|
int locIndex = luaL_checkinteger( L, 1 );
|
||||||
|
Matrix mat = uluaGetMatrixIndex( L, 2 );
|
||||||
|
|
||||||
|
rlSetUniformMatrix( locIndex, mat );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> RL.rlSetUniformSampler( int locIndex, int textureId )
|
||||||
|
|
||||||
|
Set shader value sampler
|
||||||
|
*/
|
||||||
|
int lrlglSetUniformSampler( lua_State *L ) {
|
||||||
|
int locIndex = luaL_checkinteger( L, 1 );
|
||||||
|
unsigned int textureId = (unsigned int)luaL_checkinteger( L, 2 );
|
||||||
|
|
||||||
|
rlSetUniformSampler( locIndex, textureId );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> RL.rlSetShader( int id, int{} locs )
|
||||||
|
|
||||||
|
Set shader currently active (id and locations)
|
||||||
|
*/
|
||||||
|
int lrlglSetShader( lua_State *L ) {
|
||||||
|
unsigned int id = (unsigned int)luaL_checkinteger( L, 1 );
|
||||||
|
|
||||||
|
int t = 2, i = 0;
|
||||||
|
lua_pushnil( L );
|
||||||
|
|
||||||
|
while ( lua_next( L, t ) != 0 ) {
|
||||||
|
if ( lua_isnumber( L, -1 ) ) {
|
||||||
|
if ( i < RL_MAX_SHADER_LOCATIONS ) {
|
||||||
|
state->RLGLcurrentShaderLocs[i] = lua_tointeger( L, -1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
lua_pop( L, 1 );
|
||||||
|
}
|
||||||
|
rlSetShader( id, state->RLGLcurrentShaderLocs );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
## RLGL - Matrix state management
|
## RLGL - Matrix state management
|
||||||
|
|||||||
@@ -36,6 +36,12 @@ bool stateInit( int argn, const char **argc, const char *exePath ) {
|
|||||||
}
|
}
|
||||||
state->defaultFont = GetFontDefault();
|
state->defaultFont = GetFontDefault();
|
||||||
state->defaultMaterial = LoadMaterialDefault();
|
state->defaultMaterial = LoadMaterialDefault();
|
||||||
|
state->RLGLcurrentShaderLocs = malloc( RL_MAX_SHADER_LOCATIONS * sizeof( int ) );
|
||||||
|
int *defaultShaderLocs = rlGetShaderLocsDefault();
|
||||||
|
|
||||||
|
for ( int i = 0; i < RL_MAX_SHADER_LOCATIONS; i++ ) {
|
||||||
|
state->RLGLcurrentShaderLocs[i] = defaultShaderLocs[i];
|
||||||
|
}
|
||||||
|
|
||||||
return state->run;
|
return state->run;
|
||||||
}
|
}
|
||||||
@@ -57,5 +63,6 @@ void stateFree() {
|
|||||||
CloseWindow();
|
CloseWindow();
|
||||||
}
|
}
|
||||||
free( state->exePath );
|
free( state->exePath );
|
||||||
|
free( state->RLGLcurrentShaderLocs );
|
||||||
free( state );
|
free( state );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user