From cd6471d339c394a37a1d46119818e0cabdcf5b42 Mon Sep 17 00:00:00 2001 From: jussi Date: Tue, 10 Sep 2024 12:53:20 +0300 Subject: rlSetVertexAttribute takes pointer as Buffer. --- API.md | 4 ++-- ReiLua_API.lua | 4 ++-- apiScanner.lua | 2 -- changelog | 1 + examples/raygui_extensions/property_list.lua | 2 +- examples/raygui_lib/main.lua | 4 ++-- examples/rlgl_hello_triangle/main.lua | 19 ++++++++++--------- include/raygui.h | 20 +++++++++++++++++++- src/rlgl.c | 8 ++++---- 9 files changed, 41 insertions(+), 23 deletions(-) diff --git a/API.md b/API.md index 109b6c8..93c0374 100644 --- a/API.md +++ b/API.md @@ -10520,9 +10520,9 @@ Unload vertex buffer (VBO) --- -> RL.rlSetVertexAttribute( int index, int compSize, int type, bool normalized, int stride, int pointer ) +> RL.rlSetVertexAttribute( int index, int compSize, int type, bool normalized, int stride, buffer pointer ) -Set vertex attribute. NOTE: Pointer should be given in size of bytes +Set vertex attribute. --- diff --git a/ReiLua_API.lua b/ReiLua_API.lua index 604e6b8..740729b 100644 --- a/ReiLua_API.lua +++ b/ReiLua_API.lua @@ -7333,13 +7333,13 @@ function RL.rlUnloadVertexArray( vaoId ) end ---@return any RL.rlUnloadVertexBuffer function RL.rlUnloadVertexBuffer( vboId ) end ----Set vertex attribute. NOTE: Pointer should be given in size of bytes +---Set vertex attribute. ---@param index integer ---@param compSize integer ---@param type integer ---@param normalized boolean ---@param stride integer ----@param pointer integer +---@param pointer any ---@return any RL.rlSetVertexAttribute function RL.rlSetVertexAttribute( index, compSize, type, normalized, stride, pointer ) end diff --git a/apiScanner.lua b/apiScanner.lua index 36c6e1c..ad29d9b 100644 --- a/apiScanner.lua +++ b/apiScanner.lua @@ -106,8 +106,6 @@ local raymath = { MatrixToFloatV = "Can be replaced by Lua equivalent", }, info = { - Vector3Project = "Will be added", - Vector3Reject = "Will be added", }, } local easings = { diff --git a/changelog b/changelog index 4b6d88a..9afb55a 100644 --- a/changelog +++ b/changelog @@ -71,6 +71,7 @@ DETAILED CHANGES: - CHANGE: GetPixelDataSize takes Vector2 instead of width and height. - ADDED: LoadBufferFormatted, SetBufferData and CopyBufferData. Compressed resource file example. - ADDED: GetBufferAsString. + - FIXED: rlSetVertexAttribute takes pointer as Buffer. ------------------------------------------------------------------------ Release: ReiLua version 0.7.0 Using Raylib 5.0 and Forked Raygui 4.0 diff --git a/examples/raygui_extensions/property_list.lua b/examples/raygui_extensions/property_list.lua index 46cff6e..c65e598 100644 --- a/examples/raygui_extensions/property_list.lua +++ b/examples/raygui_extensions/property_list.lua @@ -75,7 +75,7 @@ function PropertyList:updateControl( control ) if type( control._controls ) == "table" then for _, groupControl in ipairs( control._controls ) do - groupControl.visible = control.active + groupControl.visible = control.active and control.visible -- Deactivate any subgroups. if not control.active and type( groupControl._controls ) == "table" then groupControl.active = false diff --git a/examples/raygui_lib/main.lua b/examples/raygui_lib/main.lua index 95f6a6c..bf7da18 100644 --- a/examples/raygui_lib/main.lua +++ b/examples/raygui_lib/main.lua @@ -115,8 +115,8 @@ function RL.init() Rect:new( 464, 256, 128, 32 ), "Health", 0, - 0, - 10, + -100, + 100, false, { -- Callbacks. edit = function( self ) print( "Spinner value changed to "..self.value ) end diff --git a/examples/rlgl_hello_triangle/main.lua b/examples/rlgl_hello_triangle/main.lua index b9ebf9f..1a0baca 100644 --- a/examples/rlgl_hello_triangle/main.lua +++ b/examples/rlgl_hello_triangle/main.lua @@ -1,18 +1,19 @@ package.path = package.path..";"..RL.GetBasePath().."../resources/lib/?.lua" Util = require( "utillib" ) -Vec2 = require( "vector2" ) +Vector2 = require( "vector2" ) -local res = Vec2:new( 1024, 720 ) +local res = Vector2:new( 1024, 720 ) local winScale = 1 local winSize = res:scale( winScale ) local monitor = 0 +local null = RL.LoadBuffer( {}, RL.BUFFER_UNSIGNED_CHAR ); local triangle = { texture = { id = -1, data = nil, - size = Vec2:new( 0, 0 ), + size = Vector2:new( 0, 0 ), mipmaps = 0, format = 0, }, @@ -60,7 +61,7 @@ local function loadTexture( path ) local image = RL.LoadImage( path ) triangle.texture.data = RL.GetImageData( image ) - triangle.texture.size = Vec2:newT( RL.GetImageSize( image ) ) + triangle.texture.size = Vector2:newT( RL.GetImageSize( image ) ) triangle.texture.format = RL.GetImageFormat( image ) triangle.texture.mipmaps = RL.GetImageMipmaps( image ) @@ -96,7 +97,7 @@ local function createTriangle() RL.BUFFER_FLOAT ) triangle.vbos.positions = RL.rlLoadVertexBuffer( vertexBuffer, false ) - RL.rlSetVertexAttribute( 0, 3, RL.RL_FLOAT, false, 0, 0 ) + RL.rlSetVertexAttribute( 0, 3, RL.RL_FLOAT, false, 0, null ) RL.rlEnableVertexAttribute( 0 ) -- Colors. @@ -109,7 +110,7 @@ local function createTriangle() RL.BUFFER_FLOAT ) triangle.vbos.colors = RL.rlLoadVertexBuffer( colors, false ) - RL.rlSetVertexAttribute( 1, 4, RL.RL_FLOAT, false, 0, 0 ) + RL.rlSetVertexAttribute( 1, 4, RL.RL_FLOAT, false, 0, null ) RL.rlEnableVertexAttribute( 1 ) -- Texcoords. @@ -122,7 +123,7 @@ local function createTriangle() RL.BUFFER_FLOAT ) triangle.vbos.texcoors = RL.rlLoadVertexBuffer( texcoors, false ) - RL.rlSetVertexAttribute( 2, 2, RL.RL_FLOAT, false, 0, 0 ) + RL.rlSetVertexAttribute( 2, 2, RL.RL_FLOAT, false, 0, null ) RL.rlEnableVertexAttribute( 2 ) -- Disable. @@ -131,8 +132,8 @@ local function createTriangle() end function RL.init() - local monitorPos = Vec2:newT( RL.GetMonitorPosition( monitor ) ) - local monitorSize = Vec2:newT( RL.GetMonitorSize( monitor ) ) + local monitorPos = Vector2:newT( RL.GetMonitorPosition( monitor ) ) + local monitorSize = Vector2:newT( RL.GetMonitorSize( monitor ) ) RL.SetWindowTitle( "RLGL Hello Triangle" ) RL.SetWindowState( RL.FLAG_WINDOW_RESIZABLE ) diff --git a/include/raygui.h b/include/raygui.h index 2d3a4ce..5c7ac49 100644 --- a/include/raygui.h +++ b/include/raygui.h @@ -2875,6 +2875,23 @@ int GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, in keyCount++; valueHasChanged = true; } + else if ( key == 45 ) { + if ( 0 < strtol( textValue, NULL, 10 ) ) { + keyCount++; + for ( int i = keyCount; 0 < i; i-- ) { + textValue[i] = textValue[i-1]; + } + textValue[0] = 45; + } + else { + for ( int i = 0; i < keyCount; i++ ) { + textValue[i] = textValue[i+1]; + } + textValue[ keyCount ] = '\0'; + keyCount--; + } + valueHasChanged = true; + } } } @@ -2889,7 +2906,8 @@ int GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, in } } - if (valueHasChanged) *value = TextToInteger(textValue); + // if (valueHasChanged) *value = TextToInteger(textValue); + if (valueHasChanged) *value = strtol( textValue, NULL, 10 ); // NOTE: We are not clamp values until user input finishes //if (*value > maxValue) *value = maxValue; diff --git a/src/rlgl.c b/src/rlgl.c index c18a171..414666c 100644 --- a/src/rlgl.c +++ b/src/rlgl.c @@ -1216,9 +1216,9 @@ int lrlglUnloadVertexBuffer( lua_State* L ) { } /* -> RL.rlSetVertexAttribute( int index, int compSize, int type, bool normalized, int stride, int pointer ) +> RL.rlSetVertexAttribute( int index, int compSize, int type, bool normalized, int stride, buffer pointer ) -Set vertex attribute. NOTE: Pointer should be given in size of bytes +Set vertex attribute. */ int lrlglSetVertexAttribute( lua_State* L ) { int index = luaL_checkinteger( L, 1 ); @@ -1226,9 +1226,9 @@ int lrlglSetVertexAttribute( lua_State* L ) { int type = luaL_checkinteger( L, 3 ); bool normalized = uluaGetBoolean( L, 4 ); int stride = luaL_checkinteger( L, 5 ); - int pointer = luaL_checkinteger( L, 6 ); + Buffer* pointer = uluaGetBuffer( L, 6 ); - rlSetVertexAttribute( index, compSize, type, normalized, stride, (void*)( pointer * sizeof( char ) ) ); + rlSetVertexAttribute( index, compSize, type, normalized, stride, pointer->data ); return 0; } -- cgit v1.2.3