Shader buffer storage object management (ssbo) and rest of rlgl texture management functions.
This commit is contained in:
110
API.md
110
API.md
@@ -4930,7 +4930,7 @@ Update camera movement, movement/rotation values should be provided by user
|
|||||||
|
|
||||||
> buffer = RL.LoadBuffer( data{} buffer, int type )
|
> buffer = RL.LoadBuffer( data{} buffer, int type )
|
||||||
|
|
||||||
Load Buffer. Type should be one of the Buffer types
|
Load Buffer. Type should be one of the Buffer types. Empty buffer will set data to NULL.
|
||||||
|
|
||||||
- Success return Buffer
|
- Success return Buffer
|
||||||
|
|
||||||
@@ -9119,7 +9119,7 @@ Draw vertex array elements instanced
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
> id = RL.rlLoadTexture( Vector2 size, int format, int mipmapCount )
|
> id = RL.rlLoadTexture( Buffer data, Vector2 size, int format, int mipmapCount )
|
||||||
|
|
||||||
Load texture in GPU
|
Load texture in GPU
|
||||||
|
|
||||||
@@ -9135,12 +9135,66 @@ Load depth texture/renderbuffer (to be attached to fbo)
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
> id = RL.rlLoadTextureCubemap( Buffer data, int size, int format )
|
||||||
|
|
||||||
|
Load texture cubemap
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> RL.rlUpdateTexture( int id, Vector2 offset, Vector2 size, int format, Buffer data )
|
||||||
|
|
||||||
|
Update GPU texture with new data
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> glInternalFormat, glFormat, glType = RL.rlGetGlTextureFormats( int format )
|
||||||
|
|
||||||
|
Get OpenGL internal formats
|
||||||
|
|
||||||
|
- Success return int, int, int
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> name = RL.rlGetPixelFormatName( int format )
|
||||||
|
|
||||||
|
Get name string for pixel format
|
||||||
|
|
||||||
|
- Success return string
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
> RL.rlUnloadTexture( int id )
|
> RL.rlUnloadTexture( int id )
|
||||||
|
|
||||||
Unload texture from GPU memory
|
Unload texture from GPU memory
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
> mipmapCount = RL.rlGenTextureMipmaps( int id, Vector2 size, int format )
|
||||||
|
|
||||||
|
Generate mipmap data for selected texture
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> data = RL.rlReadTexturePixels( int id, Vector2 size, int format )
|
||||||
|
|
||||||
|
Read texture pixel data
|
||||||
|
|
||||||
|
- Success return Buffer
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> data = RL.rlReadScreenPixels( Vector2 size )
|
||||||
|
|
||||||
|
Read screen pixel data (color buffer)
|
||||||
|
|
||||||
|
- Success return Buffer
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## RLGL - Framebuffer management (fbo)
|
## RLGL - Framebuffer management (fbo)
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -9265,6 +9319,58 @@ Dispatch compute shader (equivalent to *draw* for graphics pipeline)
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## RLGL - Shader buffer storage object management (ssbo)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> buffer = RL.rlLoadShaderBuffer( int size, Buffer data, int usageHint )
|
||||||
|
|
||||||
|
Load shader storage buffer object (SSBO)
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> RL.rlUnloadShaderBuffer( int ssboId )
|
||||||
|
|
||||||
|
Unload shader storage buffer object (SSBO)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> RL.rlUpdateShaderBuffer( int id, Buffer data, int offset )
|
||||||
|
|
||||||
|
Update SSBO buffer data
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> RL.rlBindShaderBuffer( int id, int index )
|
||||||
|
|
||||||
|
Bind SSBO buffer
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> data = RL.rlReadShaderBuffer( int id, int count, int offset )
|
||||||
|
|
||||||
|
Read SSBO buffer data (GPU->CPU)
|
||||||
|
|
||||||
|
- Success return Buffer
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> RL.rlCopyShaderBuffer( int destId, int srcId, int destOffset, int srcOffset, int count )
|
||||||
|
|
||||||
|
Copy SSBO data between buffers
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> size = RL.rlGetShaderBufferSize( int id )
|
||||||
|
|
||||||
|
Get SSBO buffer size
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## RLGL - Buffer management
|
## RLGL - Buffer management
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
111
ReiLua_API.lua
111
ReiLua_API.lua
@@ -20,8 +20,6 @@ function RL.event( event ) end
|
|||||||
function RL.log( logLevel, message ) end
|
function RL.log( logLevel, message ) end
|
||||||
---This function will be called on program close. Cleanup could be done here.
|
---This function will be called on program close. Cleanup could be done here.
|
||||||
function RL.exit() end
|
function RL.exit() end
|
||||||
---This function will be called on program close. Cleanup could be done here.
|
|
||||||
function RL.exit() end
|
|
||||||
|
|
||||||
-- Globals - ConfigFlags
|
-- Globals - ConfigFlags
|
||||||
|
|
||||||
@@ -2290,7 +2288,7 @@ function RL.UpdateCamera3DPro( camera, movement, rotation, zoom ) end
|
|||||||
|
|
||||||
-- Core - Buffer management functions
|
-- Core - Buffer management functions
|
||||||
|
|
||||||
---Load Buffer. Type should be one of the Buffer types
|
---Load Buffer. Type should be one of the Buffer types. Empty buffer will set data to NULL.
|
||||||
---- Success return Buffer
|
---- Success return Buffer
|
||||||
---@param buffer table
|
---@param buffer table
|
||||||
---@param type integer
|
---@param type integer
|
||||||
@@ -6178,11 +6176,12 @@ function RL.rlDrawVertexArrayElementsInstanced( offset, count, buffer, instance
|
|||||||
|
|
||||||
---Load texture in GPU
|
---Load texture in GPU
|
||||||
---- Success return int
|
---- Success return int
|
||||||
|
---@param data any
|
||||||
---@param size table
|
---@param size table
|
||||||
---@param format integer
|
---@param format integer
|
||||||
---@param mipmapCount integer
|
---@param mipmapCount integer
|
||||||
---@return any id
|
---@return any id
|
||||||
function RL.rlLoadTexture( size, format, mipmapCount ) end
|
function RL.rlLoadTexture( data, size, format, mipmapCount ) end
|
||||||
|
|
||||||
---Load depth texture/renderbuffer (to be attached to fbo)
|
---Load depth texture/renderbuffer (to be attached to fbo)
|
||||||
---- Success return int
|
---- Success return int
|
||||||
@@ -6191,11 +6190,64 @@ function RL.rlLoadTexture( size, format, mipmapCount ) end
|
|||||||
---@return any id
|
---@return any id
|
||||||
function RL.rlLoadTextureDepth( size, useRenderBuffer ) end
|
function RL.rlLoadTextureDepth( size, useRenderBuffer ) end
|
||||||
|
|
||||||
|
---Load texture cubemap
|
||||||
|
---- Success return int
|
||||||
|
---@param data any
|
||||||
|
---@param size integer
|
||||||
|
---@param format integer
|
||||||
|
---@return any id
|
||||||
|
function RL.rlLoadTextureCubemap( data, size, format ) end
|
||||||
|
|
||||||
|
---Update GPU texture with new data
|
||||||
|
---@param id integer
|
||||||
|
---@param offset table
|
||||||
|
---@param size table
|
||||||
|
---@param format integer
|
||||||
|
---@param data any
|
||||||
|
---@return any RL.rlUpdateTexture
|
||||||
|
function RL.rlUpdateTexture( id, offset, size, format, data ) end
|
||||||
|
|
||||||
|
---Get OpenGL internal formats
|
||||||
|
---- Success return int, int, int
|
||||||
|
---@param format integer
|
||||||
|
---@return any glInternalFormat
|
||||||
|
---@return any glFormat
|
||||||
|
---@return any glType
|
||||||
|
function RL.rlGetGlTextureFormats( format ) end
|
||||||
|
|
||||||
|
---Get name string for pixel format
|
||||||
|
---- Success return string
|
||||||
|
---@param format integer
|
||||||
|
---@return any name
|
||||||
|
function RL.rlGetPixelFormatName( format ) end
|
||||||
|
|
||||||
---Unload texture from GPU memory
|
---Unload texture from GPU memory
|
||||||
---@param id integer
|
---@param id integer
|
||||||
---@return any RL.rlUnloadTexture
|
---@return any RL.rlUnloadTexture
|
||||||
function RL.rlUnloadTexture( id ) end
|
function RL.rlUnloadTexture( id ) end
|
||||||
|
|
||||||
|
---Generate mipmap data for selected texture
|
||||||
|
---- Success return int
|
||||||
|
---@param id integer
|
||||||
|
---@param size table
|
||||||
|
---@param format integer
|
||||||
|
---@return any mipmapCount
|
||||||
|
function RL.rlGenTextureMipmaps( id, size, format ) end
|
||||||
|
|
||||||
|
---Read texture pixel data
|
||||||
|
---- Success return Buffer
|
||||||
|
---@param id integer
|
||||||
|
---@param size table
|
||||||
|
---@param format integer
|
||||||
|
---@return any data
|
||||||
|
function RL.rlReadTexturePixels( id, size, format ) end
|
||||||
|
|
||||||
|
---Read screen pixel data (color buffer)
|
||||||
|
---- Success return Buffer
|
||||||
|
---@param size table
|
||||||
|
---@return any data
|
||||||
|
function RL.rlReadScreenPixels( size ) end
|
||||||
|
|
||||||
-- RLGL - Framebuffer management (fbo)
|
-- RLGL - Framebuffer management (fbo)
|
||||||
|
|
||||||
---Load an empty framebuffer
|
---Load an empty framebuffer
|
||||||
@@ -6307,6 +6359,57 @@ function RL.rlLoadComputeShaderProgram( shaderId ) end
|
|||||||
---@return any RL.rlComputeShaderDispatch
|
---@return any RL.rlComputeShaderDispatch
|
||||||
function RL.rlComputeShaderDispatch( groupX, groupY, groupZ ) end
|
function RL.rlComputeShaderDispatch( groupX, groupY, groupZ ) end
|
||||||
|
|
||||||
|
-- RLGL - Shader buffer storage object management (ssbo)
|
||||||
|
|
||||||
|
---Load shader storage buffer object (SSBO)
|
||||||
|
---- Success return int
|
||||||
|
---@param size integer
|
||||||
|
---@param data any
|
||||||
|
---@param usageHint integer
|
||||||
|
---@return any buffer
|
||||||
|
function RL.rlLoadShaderBuffer( size, data, usageHint ) end
|
||||||
|
|
||||||
|
---Unload shader storage buffer object (SSBO)
|
||||||
|
---@param ssboId integer
|
||||||
|
---@return any RL.rlUnloadShaderBuffer
|
||||||
|
function RL.rlUnloadShaderBuffer( ssboId ) end
|
||||||
|
|
||||||
|
---Update SSBO buffer data
|
||||||
|
---@param id integer
|
||||||
|
---@param data any
|
||||||
|
---@param offset integer
|
||||||
|
---@return any RL.rlUpdateShaderBuffer
|
||||||
|
function RL.rlUpdateShaderBuffer( id, data, offset ) end
|
||||||
|
|
||||||
|
---Bind SSBO buffer
|
||||||
|
---@param id integer
|
||||||
|
---@param index integer
|
||||||
|
---@return any RL.rlBindShaderBuffer
|
||||||
|
function RL.rlBindShaderBuffer( id, index ) end
|
||||||
|
|
||||||
|
---Read SSBO buffer data (GPU->CPU)
|
||||||
|
---- Success return Buffer
|
||||||
|
---@param id integer
|
||||||
|
---@param count integer
|
||||||
|
---@param offset integer
|
||||||
|
---@return any data
|
||||||
|
function RL.rlReadShaderBuffer( id, count, offset ) end
|
||||||
|
|
||||||
|
---Copy SSBO data between buffers
|
||||||
|
---@param destId integer
|
||||||
|
---@param srcId integer
|
||||||
|
---@param destOffset integer
|
||||||
|
---@param srcOffset integer
|
||||||
|
---@param count integer
|
||||||
|
---@return any RL.rlCopyShaderBuffer
|
||||||
|
function RL.rlCopyShaderBuffer( destId, srcId, destOffset, srcOffset, count ) end
|
||||||
|
|
||||||
|
---Get SSBO buffer size
|
||||||
|
---- Success return int
|
||||||
|
---@param id integer
|
||||||
|
---@return any size
|
||||||
|
function RL.rlGetShaderBufferSize( id ) end
|
||||||
|
|
||||||
-- RLGL - Buffer management
|
-- RLGL - Buffer management
|
||||||
|
|
||||||
---Bind image texture
|
---Bind image texture
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ KEY CHANGES:
|
|||||||
- ADDED: Matrix library.
|
- ADDED: Matrix library.
|
||||||
- Removed: GC_UNLOAD build time define and replaced with flag to change it at runtime.
|
- Removed: GC_UNLOAD build time define and replaced with flag to change it at runtime.
|
||||||
- ADDED: Quaternion library.
|
- ADDED: Quaternion library.
|
||||||
|
- ADDED: Shader buffer storage object management (ssbo).
|
||||||
|
- ADDED: Rest of rlgl texture management functions.
|
||||||
|
|
||||||
DETAILED CHANGES:
|
DETAILED CHANGES:
|
||||||
- CHANGED: GenImageColor now takes Vector2 as size.
|
- CHANGED: GenImageColor now takes Vector2 as size.
|
||||||
@@ -54,6 +56,7 @@ DETAILED CHANGES:
|
|||||||
- CHANGED: Organized core functions.
|
- CHANGED: Organized core functions.
|
||||||
- CHANGED: Organized shapes, textures, audio, text, lights and gui functions.
|
- CHANGED: Organized shapes, textures, audio, text, lights and gui functions.
|
||||||
- ADDED: More color and rectangle lib functionality.
|
- ADDED: More color and rectangle lib functionality.
|
||||||
|
- CHANGED: rlLoadTexture to take Buffer data.
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
Release: ReiLua version 0.5.0 Using Raylib 4.5
|
Release: ReiLua version 0.5.0 Using Raylib 4.5
|
||||||
|
|||||||
9
devnotes
9
devnotes
@@ -1,4 +1,5 @@
|
|||||||
Current {
|
Current {
|
||||||
|
* Review image functions if sould use Buffer instead of color arrays.
|
||||||
}
|
}
|
||||||
|
|
||||||
Backlog {
|
Backlog {
|
||||||
@@ -11,13 +12,11 @@ Backlog {
|
|||||||
* More Model management functions. Get mesh and material etc.
|
* More Model management functions. Get mesh and material etc.
|
||||||
* BoneInfo.
|
* BoneInfo.
|
||||||
* LoadMaterialsFromModel (Could then for example edit and set back to model).
|
* LoadMaterialsFromModel (Could then for example edit and set back to model).
|
||||||
* rlgl
|
|
||||||
* More Textures management functions.
|
|
||||||
* Shader buffer storage object management (ssbo).
|
|
||||||
|
|
||||||
* Examples
|
* Examples
|
||||||
* Improve Dungeon crawler example by generating custom mesh instead of drawing 3D quads.
|
* Improve Dungeon crawler example by generating custom mesh instead of drawing 3D quads.
|
||||||
* Platformer example physics process for true framerate independence.
|
* Platformer example physics process for true framerate independence.
|
||||||
|
* Android support
|
||||||
}
|
}
|
||||||
|
|
||||||
Bugs {
|
Bugs {
|
||||||
@@ -27,4 +26,8 @@ Bugs {
|
|||||||
Needs Testing {
|
Needs Testing {
|
||||||
* rlSetUniform
|
* rlSetUniform
|
||||||
* rlSetShader
|
* rlSetShader
|
||||||
|
* rlReadShaderBuffer
|
||||||
|
* rlUpdateTexture
|
||||||
|
* rlReadTexturePixels
|
||||||
|
* rlReadScreenPixels
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,8 +119,6 @@ luaApiFile:write(
|
|||||||
"---"..FUNC_DESC.log.."\n---@param logLevel integer\n---@param message string\nfunction RL.log( logLevel, message ) end\n" )
|
"---"..FUNC_DESC.log.."\n---@param logLevel integer\n---@param message string\nfunction RL.log( logLevel, message ) end\n" )
|
||||||
luaApiFile:write(
|
luaApiFile:write(
|
||||||
"---"..FUNC_DESC.exit.."\nfunction RL.exit() end\n" )
|
"---"..FUNC_DESC.exit.."\nfunction RL.exit() end\n" )
|
||||||
luaApiFile:write(
|
|
||||||
"---"..FUNC_DESC.exit.."\nfunction RL.exit() end\n" )
|
|
||||||
|
|
||||||
-- Object unloading.
|
-- Object unloading.
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,14 @@ int lrlglDrawVertexArrayElementsInstanced( lua_State *L );
|
|||||||
/* Textures management */
|
/* Textures management */
|
||||||
int lrlglLoadTexture( lua_State *L );
|
int lrlglLoadTexture( lua_State *L );
|
||||||
int lrlglLoadTextureDepth( lua_State *L );
|
int lrlglLoadTextureDepth( lua_State *L );
|
||||||
|
int lrlglLoadTextureCubemap( lua_State *L );
|
||||||
|
int lrlglUpdateTexture( lua_State *L );
|
||||||
|
int lrlglGetGlTextureFormats( lua_State *L );
|
||||||
|
int lrlglGetPixelFormatName( lua_State *L );
|
||||||
int lrlglUnloadTexture( lua_State *L );
|
int lrlglUnloadTexture( lua_State *L );
|
||||||
|
int lrlglGenTextureMipmaps( lua_State *L );
|
||||||
|
int lrlglReadTexturePixels( lua_State *L );
|
||||||
|
int lrlglReadScreenPixels( lua_State *L );
|
||||||
/* Framebuffer management (fbo) */
|
/* Framebuffer management (fbo) */
|
||||||
int lrlglLoadFramebuffer( lua_State *L );
|
int lrlglLoadFramebuffer( lua_State *L );
|
||||||
int lrlglFramebufferAttach( lua_State *L );
|
int lrlglFramebufferAttach( lua_State *L );
|
||||||
@@ -125,6 +132,14 @@ int lrlglSetShader( lua_State *L );
|
|||||||
/* Compute shader management */
|
/* Compute shader management */
|
||||||
int lrlglLoadComputeShaderProgram( lua_State *L );
|
int lrlglLoadComputeShaderProgram( lua_State *L );
|
||||||
int lrlglComputeShaderDispatch( lua_State *L );
|
int lrlglComputeShaderDispatch( lua_State *L );
|
||||||
|
/* Shader buffer storage object management (ssbo) */
|
||||||
|
int lrlglLoadShaderBuffer( lua_State *L );
|
||||||
|
int lrlglUnloadShaderBuffer( lua_State *L );
|
||||||
|
int lrlglUpdateShaderBuffer( lua_State *L );
|
||||||
|
int lrlglBindShaderBuffer( lua_State *L );
|
||||||
|
int lrlglReadShaderBuffer( lua_State *L );
|
||||||
|
int lrlglCopyShaderBuffer( lua_State *L );
|
||||||
|
int lrlglGetShaderBufferSize( lua_State *L );
|
||||||
/* Buffer management */
|
/* Buffer management */
|
||||||
int lrlglBindImageTexture( lua_State *L );
|
int lrlglBindImageTexture( lua_State *L );
|
||||||
/* Matrix state management */
|
/* Matrix state management */
|
||||||
|
|||||||
@@ -2733,7 +2733,7 @@ int lcoreUpdateCamera3DPro( lua_State *L ) {
|
|||||||
/*
|
/*
|
||||||
> buffer = RL.LoadBuffer( data{} buffer, int type )
|
> buffer = RL.LoadBuffer( data{} buffer, int type )
|
||||||
|
|
||||||
Load Buffer. Type should be one of the Buffer types
|
Load Buffer. Type should be one of the Buffer types. Empty buffer will set data to NULL.
|
||||||
|
|
||||||
- Success return Buffer
|
- Success return Buffer
|
||||||
*/
|
*/
|
||||||
@@ -2746,6 +2746,13 @@ int lcoreLoadBuffer( lua_State *L ) {
|
|||||||
};
|
};
|
||||||
int len = uluaGetTableLen( L, 1 );
|
int len = uluaGetTableLen( L, 1 );
|
||||||
|
|
||||||
|
if ( len == 0 ) {
|
||||||
|
buffer.size = 0;
|
||||||
|
buffer.data = NULL;
|
||||||
|
|
||||||
|
uluaPushBuffer( L, buffer );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
buffer.size = len * getBufferElementSize( &buffer );
|
buffer.size = len * getBufferElementSize( &buffer );
|
||||||
buffer.data = malloc( buffer.size );
|
buffer.data = malloc( buffer.size );
|
||||||
|
|
||||||
|
|||||||
@@ -2344,7 +2344,14 @@ void luaRegister() {
|
|||||||
/* Textures management. */
|
/* Textures management. */
|
||||||
assingGlobalFunction( "rlLoadTexture", lrlglLoadTexture );
|
assingGlobalFunction( "rlLoadTexture", lrlglLoadTexture );
|
||||||
assingGlobalFunction( "rlLoadTextureDepth", lrlglLoadTextureDepth );
|
assingGlobalFunction( "rlLoadTextureDepth", lrlglLoadTextureDepth );
|
||||||
|
assingGlobalFunction( "rlLoadTextureCubemap", lrlglLoadTextureCubemap );
|
||||||
|
assingGlobalFunction( "rlUpdateTexture", lrlglUpdateTexture );
|
||||||
|
assingGlobalFunction( "rlGetGlTextureFormats", lrlglGetGlTextureFormats );
|
||||||
|
assingGlobalFunction( "rlGetPixelFormatName", lrlglGetPixelFormatName );
|
||||||
assingGlobalFunction( "rlUnloadTexture", lrlglUnloadTexture );
|
assingGlobalFunction( "rlUnloadTexture", lrlglUnloadTexture );
|
||||||
|
assingGlobalFunction( "rlGenTextureMipmaps", lrlglGenTextureMipmaps );
|
||||||
|
assingGlobalFunction( "rlReadTexturePixels", lrlglReadTexturePixels );
|
||||||
|
assingGlobalFunction( "rlReadScreenPixels", lrlglReadScreenPixels );
|
||||||
/* Framebuffer management (fbo). */
|
/* Framebuffer management (fbo). */
|
||||||
assingGlobalFunction( "rlLoadFramebuffer", lrlglLoadFramebuffer );
|
assingGlobalFunction( "rlLoadFramebuffer", lrlglLoadFramebuffer );
|
||||||
assingGlobalFunction( "rlFramebufferAttach", lrlglFramebufferAttach );
|
assingGlobalFunction( "rlFramebufferAttach", lrlglFramebufferAttach );
|
||||||
@@ -2364,6 +2371,14 @@ void luaRegister() {
|
|||||||
/* Compute shader management */
|
/* Compute shader management */
|
||||||
assingGlobalFunction( "rlLoadComputeShaderProgram", lrlglLoadComputeShaderProgram );
|
assingGlobalFunction( "rlLoadComputeShaderProgram", lrlglLoadComputeShaderProgram );
|
||||||
assingGlobalFunction( "rlComputeShaderDispatch", lrlglComputeShaderDispatch );
|
assingGlobalFunction( "rlComputeShaderDispatch", lrlglComputeShaderDispatch );
|
||||||
|
/* Shader buffer storage object management (ssbo) */
|
||||||
|
assingGlobalFunction( "rlLoadShaderBuffer", lrlglLoadShaderBuffer );
|
||||||
|
assingGlobalFunction( "rlUnloadShaderBuffer", lrlglUnloadShaderBuffer );
|
||||||
|
assingGlobalFunction( "rlUpdateShaderBuffer", lrlglUpdateShaderBuffer );
|
||||||
|
assingGlobalFunction( "rlBindShaderBuffer", lrlglBindShaderBuffer );
|
||||||
|
assingGlobalFunction( "rlReadShaderBuffer", lrlglReadShaderBuffer );
|
||||||
|
assingGlobalFunction( "rlCopyShaderBuffer", lrlglCopyShaderBuffer );
|
||||||
|
assingGlobalFunction( "rlGetShaderBufferSize", lrlglGetShaderBufferSize );
|
||||||
/* Buffer management */
|
/* Buffer management */
|
||||||
assingGlobalFunction( "rlBindImageTexture", lrlglBindImageTexture );
|
assingGlobalFunction( "rlBindImageTexture", lrlglBindImageTexture );
|
||||||
/* Matrix state management. */
|
/* Matrix state management. */
|
||||||
@@ -3175,6 +3190,9 @@ void uluaPushGlyphInfo( lua_State *L, GlyphInfo glyphInfo, Image *image ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void uluaPushBuffer( lua_State *L, Buffer buffer ) {
|
void uluaPushBuffer( lua_State *L, Buffer buffer ) {
|
||||||
|
if ( buffer.size == 0 ) {
|
||||||
|
buffer.data = NULL;
|
||||||
|
}
|
||||||
Buffer *bufferP = lua_newuserdata( L, sizeof( Buffer ) );
|
Buffer *bufferP = lua_newuserdata( L, sizeof( Buffer ) );
|
||||||
*bufferP = buffer;
|
*bufferP = buffer;
|
||||||
luaL_setmetatable( L, "Buffer" );
|
luaL_setmetatable( L, "Buffer" );
|
||||||
|
|||||||
268
src/rlgl.c
268
src/rlgl.c
@@ -1224,18 +1224,19 @@ int lrlglDrawVertexArrayElementsInstanced( lua_State *L ) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
> id = RL.rlLoadTexture( Vector2 size, int format, int mipmapCount )
|
> id = RL.rlLoadTexture( Buffer data, Vector2 size, int format, int mipmapCount )
|
||||||
|
|
||||||
Load texture in GPU
|
Load texture in GPU
|
||||||
|
|
||||||
- Success return int
|
- Success return int
|
||||||
*/
|
*/
|
||||||
int lrlglLoadTexture( lua_State *L ) {
|
int lrlglLoadTexture( lua_State *L ) {
|
||||||
Vector2 size = uluaGetVector2( L, 1 );
|
Buffer *data = uluaGetBuffer( L, 1 );
|
||||||
int format = luaL_checkinteger( L, 2 );
|
Vector2 size = uluaGetVector2( L, 2 );
|
||||||
int mipmapCount = luaL_checkinteger( L, 3 );
|
int format = luaL_checkinteger( L, 3 );
|
||||||
|
int mipmapCount = luaL_checkinteger( L, 4 );
|
||||||
|
|
||||||
lua_pushinteger( L, rlLoadTexture( NULL, size.x, size.y, format, mipmapCount ) );
|
lua_pushinteger( L, rlLoadTexture( data->data, size.x, size.y, format, mipmapCount ) );
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -1256,17 +1257,154 @@ int lrlglLoadTextureDepth( lua_State *L ) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> id = RL.rlLoadTextureCubemap( Buffer data, int size, int format )
|
||||||
|
|
||||||
|
Load texture cubemap
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
*/
|
||||||
|
int lrlglLoadTextureCubemap( lua_State *L ) {
|
||||||
|
Buffer *data = uluaGetBuffer( L, 1 );
|
||||||
|
int size = luaL_checkinteger( L, 2 );
|
||||||
|
int format = luaL_checkinteger( L, 3 );
|
||||||
|
|
||||||
|
lua_pushinteger( L, rlLoadTextureCubemap( data->data, size, format ) );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> RL.rlUpdateTexture( int id, Vector2 offset, Vector2 size, int format, Buffer data )
|
||||||
|
|
||||||
|
Update GPU texture with new data
|
||||||
|
*/
|
||||||
|
int lrlglUpdateTexture( lua_State *L ) {
|
||||||
|
unsigned int id = (unsigned int)luaL_checkinteger( L, 1 );
|
||||||
|
Vector2 offset = uluaGetVector2( L, 2 );
|
||||||
|
Vector2 size = uluaGetVector2( L, 3 );
|
||||||
|
int format = luaL_checkinteger( L, 4 );
|
||||||
|
Buffer *data = uluaGetBuffer( L, 5 );
|
||||||
|
|
||||||
|
rlUpdateTexture( id, (int)offset.x, (int)offset.y, (int)size.x, (int)size.y, format, data->data );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> glInternalFormat, glFormat, glType = RL.rlGetGlTextureFormats( int format )
|
||||||
|
|
||||||
|
Get OpenGL internal formats
|
||||||
|
|
||||||
|
- Success return int, int, int
|
||||||
|
*/
|
||||||
|
int lrlglGetGlTextureFormats( lua_State *L ) {
|
||||||
|
int format = luaL_checkinteger( L, 1 );
|
||||||
|
|
||||||
|
unsigned int glInternalFormat, glFormat, glType;
|
||||||
|
rlGetGlTextureFormats( format, &glInternalFormat, &glFormat, &glType );
|
||||||
|
|
||||||
|
lua_pushinteger( L, glInternalFormat );
|
||||||
|
lua_pushinteger( L, glFormat );
|
||||||
|
lua_pushinteger( L, glType );
|
||||||
|
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> name = RL.rlGetPixelFormatName( int format )
|
||||||
|
|
||||||
|
Get name string for pixel format
|
||||||
|
|
||||||
|
- Success return string
|
||||||
|
*/
|
||||||
|
int lrlglGetPixelFormatName( lua_State *L ) {
|
||||||
|
int format = luaL_checkinteger( L, 1 );
|
||||||
|
|
||||||
|
lua_pushstring( L, rlGetPixelFormatName( format ) );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
> RL.rlUnloadTexture( int id )
|
> RL.rlUnloadTexture( int id )
|
||||||
|
|
||||||
Unload texture from GPU memory
|
Unload texture from GPU memory
|
||||||
*/
|
*/
|
||||||
int lrlglUnloadTexture( lua_State *L ) {
|
int lrlglUnloadTexture( lua_State *L ) {
|
||||||
rlUnloadTexture( luaL_checkinteger( L, 1 ) );
|
rlUnloadTexture( (unsigned int)luaL_checkinteger( L, 1 ) );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> mipmapCount = RL.rlGenTextureMipmaps( int id, Vector2 size, int format )
|
||||||
|
|
||||||
|
Generate mipmap data for selected texture
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
*/
|
||||||
|
int lrlglGenTextureMipmaps( lua_State *L ) {
|
||||||
|
unsigned int id = (unsigned int)luaL_checkinteger( L, 1 );
|
||||||
|
Vector2 size = uluaGetVector2( L, 2 );
|
||||||
|
int format = luaL_checkinteger( L, 3 );
|
||||||
|
|
||||||
|
int mipmaps = 0;
|
||||||
|
rlGenTextureMipmaps( id, (int)size.x, (int)size.y, format, &mipmaps );
|
||||||
|
|
||||||
|
lua_pushinteger( L, mipmaps );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> data = RL.rlReadTexturePixels( int id, Vector2 size, int format )
|
||||||
|
|
||||||
|
Read texture pixel data
|
||||||
|
|
||||||
|
- Success return Buffer
|
||||||
|
*/
|
||||||
|
int lrlglReadTexturePixels( lua_State *L ) {
|
||||||
|
unsigned int id = (unsigned int)luaL_checkinteger( L, 1 );
|
||||||
|
Vector2 size = uluaGetVector2( L, 2 );
|
||||||
|
int format = luaL_checkinteger( L, 3 );
|
||||||
|
|
||||||
|
size_t dataSize = GetPixelDataSize( size.x, size.y, format );
|
||||||
|
Buffer data = {
|
||||||
|
.type = BUFFER_UNSIGNED_CHAR,
|
||||||
|
.size = dataSize,
|
||||||
|
.data = malloc( dataSize )
|
||||||
|
};
|
||||||
|
data.data = rlReadTexturePixels( id, (int)size.x, (int)size.y, format );
|
||||||
|
|
||||||
|
uluaPushBuffer( L, data );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> data = RL.rlReadScreenPixels( Vector2 size )
|
||||||
|
|
||||||
|
Read screen pixel data (color buffer)
|
||||||
|
|
||||||
|
- Success return Buffer
|
||||||
|
*/
|
||||||
|
int lrlglReadScreenPixels( lua_State *L ) {
|
||||||
|
Vector2 size = uluaGetVector2( L, 1 );
|
||||||
|
|
||||||
|
size_t dataSize = (int)size.x * (int)size.y * 4 * sizeof(unsigned char);
|
||||||
|
Buffer data = {
|
||||||
|
.type = BUFFER_UNSIGNED_CHAR,
|
||||||
|
.size = dataSize,
|
||||||
|
.data = malloc( dataSize )
|
||||||
|
};
|
||||||
|
data.data = rlReadScreenPixels( (int)size.x, (int)size.y );
|
||||||
|
|
||||||
|
uluaPushBuffer( L, data );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
## RLGL - Framebuffer management (fbo)
|
## RLGL - Framebuffer management (fbo)
|
||||||
*/
|
*/
|
||||||
@@ -1525,6 +1663,124 @@ int lrlglComputeShaderDispatch( lua_State *L ) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
## RLGL - Shader buffer storage object management (ssbo)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
> buffer = RL.rlLoadShaderBuffer( int size, Buffer data, int usageHint )
|
||||||
|
|
||||||
|
Load shader storage buffer object (SSBO)
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
*/
|
||||||
|
int lrlglLoadShaderBuffer( lua_State *L ) {
|
||||||
|
unsigned int size = (unsigned int)luaL_checkinteger( L, 1 );
|
||||||
|
Buffer *data = uluaGetBuffer( L, 2 );
|
||||||
|
int usageHint = luaL_checkinteger( L, 3 );
|
||||||
|
|
||||||
|
lua_pushinteger( L, rlLoadShaderBuffer( size, data->data, usageHint ) );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> RL.rlUnloadShaderBuffer( int ssboId )
|
||||||
|
|
||||||
|
Unload shader storage buffer object (SSBO)
|
||||||
|
*/
|
||||||
|
int lrlglUnloadShaderBuffer( lua_State *L ) {
|
||||||
|
unsigned int ssboId = (unsigned int)luaL_checkinteger( L, 1 );
|
||||||
|
|
||||||
|
rlUnloadShaderBuffer( ssboId );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> RL.rlUpdateShaderBuffer( int id, Buffer data, int offset )
|
||||||
|
|
||||||
|
Update SSBO buffer data
|
||||||
|
*/
|
||||||
|
int lrlglUpdateShaderBuffer( lua_State *L ) {
|
||||||
|
unsigned int id = (unsigned int)luaL_checkinteger( L, 1 );
|
||||||
|
Buffer *data = uluaGetBuffer( L, 2 );
|
||||||
|
unsigned int offset = (unsigned int)luaL_checkinteger( L, 3 );
|
||||||
|
|
||||||
|
rlUpdateShaderBuffer( id, data->data, data->size, offset );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> RL.rlBindShaderBuffer( int id, int index )
|
||||||
|
|
||||||
|
Bind SSBO buffer
|
||||||
|
*/
|
||||||
|
int lrlglBindShaderBuffer( lua_State *L ) {
|
||||||
|
unsigned int id = (unsigned int)luaL_checkinteger( L, 1 );
|
||||||
|
unsigned int index = (unsigned int)luaL_checkinteger( L, 2 );
|
||||||
|
|
||||||
|
rlBindShaderBuffer( id, index );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> data = RL.rlReadShaderBuffer( int id, int count, int offset )
|
||||||
|
|
||||||
|
Read SSBO buffer data (GPU->CPU)
|
||||||
|
|
||||||
|
- Success return Buffer
|
||||||
|
*/
|
||||||
|
int lrlglReadShaderBuffer( lua_State *L ) {
|
||||||
|
unsigned int id = (unsigned int)luaL_checkinteger( L, 1 );
|
||||||
|
unsigned int count = (unsigned int)luaL_checkinteger( L, 2 );
|
||||||
|
unsigned int offset = (unsigned int)luaL_checkinteger( L, 3 );
|
||||||
|
|
||||||
|
Buffer dest = {
|
||||||
|
.type = BUFFER_UNSIGNED_CHAR,
|
||||||
|
.size = count,
|
||||||
|
.data = malloc( count * sizeof( unsigned char ) )
|
||||||
|
};
|
||||||
|
rlReadShaderBuffer( id, &dest.data, count, offset );
|
||||||
|
uluaPushBuffer( L, dest );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> RL.rlCopyShaderBuffer( int destId, int srcId, int destOffset, int srcOffset, int count )
|
||||||
|
|
||||||
|
Copy SSBO data between buffers
|
||||||
|
*/
|
||||||
|
int lrlglCopyShaderBuffer( lua_State *L ) {
|
||||||
|
unsigned int destId = (unsigned int)luaL_checkinteger( L, 1 );
|
||||||
|
unsigned int srcId = (unsigned int)luaL_checkinteger( L, 2 );
|
||||||
|
unsigned int destOffset = (unsigned int)luaL_checkinteger( L, 3 );
|
||||||
|
unsigned int srcOffset = (unsigned int)luaL_checkinteger( L, 4 );
|
||||||
|
unsigned int count = (unsigned int)luaL_checkinteger( L, 5 );
|
||||||
|
|
||||||
|
rlCopyShaderBuffer( destId, srcId, destOffset, srcOffset, count );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> size = RL.rlGetShaderBufferSize( int id )
|
||||||
|
|
||||||
|
Get SSBO buffer size
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
*/
|
||||||
|
int lrlglGetShaderBufferSize( lua_State *L ) {
|
||||||
|
unsigned int id = (unsigned int)luaL_checkinteger( L, 1 );
|
||||||
|
|
||||||
|
lua_pushinteger( L, rlGetShaderBufferSize( id ) );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
## RLGL - Buffer management
|
## RLGL - Buffer management
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user