rlSetVertexAttribute takes pointer as Buffer.

This commit is contained in:
jussi
2024-09-10 12:53:20 +03:00
parent 415f3b6c01
commit cd6471d339
9 changed files with 41 additions and 23 deletions

4
API.md
View File

@@ -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.
--- ---

View File

@@ -7333,13 +7333,13 @@ function RL.rlUnloadVertexArray( vaoId ) end
---@return any RL.rlUnloadVertexBuffer ---@return any RL.rlUnloadVertexBuffer
function RL.rlUnloadVertexBuffer( vboId ) end function RL.rlUnloadVertexBuffer( vboId ) end
---Set vertex attribute. NOTE: Pointer should be given in size of bytes ---Set vertex attribute.
---@param index integer ---@param index integer
---@param compSize integer ---@param compSize integer
---@param type integer ---@param type integer
---@param normalized boolean ---@param normalized boolean
---@param stride integer ---@param stride integer
---@param pointer integer ---@param pointer any
---@return any RL.rlSetVertexAttribute ---@return any RL.rlSetVertexAttribute
function RL.rlSetVertexAttribute( index, compSize, type, normalized, stride, pointer ) end function RL.rlSetVertexAttribute( index, compSize, type, normalized, stride, pointer ) end

View File

@@ -106,8 +106,6 @@ local raymath = {
MatrixToFloatV = "Can be replaced by Lua equivalent", MatrixToFloatV = "Can be replaced by Lua equivalent",
}, },
info = { info = {
Vector3Project = "Will be added",
Vector3Reject = "Will be added",
}, },
} }
local easings = { local easings = {

View File

@@ -71,6 +71,7 @@ DETAILED CHANGES:
- CHANGE: GetPixelDataSize takes Vector2 instead of width and height. - CHANGE: GetPixelDataSize takes Vector2 instead of width and height.
- ADDED: LoadBufferFormatted, SetBufferData and CopyBufferData. Compressed resource file example. - ADDED: LoadBufferFormatted, SetBufferData and CopyBufferData. Compressed resource file example.
- ADDED: GetBufferAsString. - ADDED: GetBufferAsString.
- FIXED: rlSetVertexAttribute takes pointer as Buffer.
------------------------------------------------------------------------ ------------------------------------------------------------------------
Release: ReiLua version 0.7.0 Using Raylib 5.0 and Forked Raygui 4.0 Release: ReiLua version 0.7.0 Using Raylib 5.0 and Forked Raygui 4.0

View File

@@ -75,7 +75,7 @@ function PropertyList:updateControl( control )
if type( control._controls ) == "table" then if type( control._controls ) == "table" then
for _, groupControl in ipairs( control._controls ) do for _, groupControl in ipairs( control._controls ) do
groupControl.visible = control.active groupControl.visible = control.active and control.visible
-- Deactivate any subgroups. -- Deactivate any subgroups.
if not control.active and type( groupControl._controls ) == "table" then if not control.active and type( groupControl._controls ) == "table" then
groupControl.active = false groupControl.active = false

View File

@@ -115,8 +115,8 @@ function RL.init()
Rect:new( 464, 256, 128, 32 ), Rect:new( 464, 256, 128, 32 ),
"Health", "Health",
0, 0,
0, -100,
10, 100,
false, false,
{ -- Callbacks. { -- Callbacks.
edit = function( self ) print( "Spinner value changed to "..self.value ) end edit = function( self ) print( "Spinner value changed to "..self.value ) end

View File

@@ -1,18 +1,19 @@
package.path = package.path..";"..RL.GetBasePath().."../resources/lib/?.lua" package.path = package.path..";"..RL.GetBasePath().."../resources/lib/?.lua"
Util = require( "utillib" ) 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 winScale = 1
local winSize = res:scale( winScale ) local winSize = res:scale( winScale )
local monitor = 0 local monitor = 0
local null = RL.LoadBuffer( {}, RL.BUFFER_UNSIGNED_CHAR );
local triangle = { local triangle = {
texture = { texture = {
id = -1, id = -1,
data = nil, data = nil,
size = Vec2:new( 0, 0 ), size = Vector2:new( 0, 0 ),
mipmaps = 0, mipmaps = 0,
format = 0, format = 0,
}, },
@@ -60,7 +61,7 @@ local function loadTexture( path )
local image = RL.LoadImage( path ) local image = RL.LoadImage( path )
triangle.texture.data = RL.GetImageData( image ) 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.format = RL.GetImageFormat( image )
triangle.texture.mipmaps = RL.GetImageMipmaps( image ) triangle.texture.mipmaps = RL.GetImageMipmaps( image )
@@ -96,7 +97,7 @@ local function createTriangle()
RL.BUFFER_FLOAT RL.BUFFER_FLOAT
) )
triangle.vbos.positions = RL.rlLoadVertexBuffer( vertexBuffer, false ) 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 ) RL.rlEnableVertexAttribute( 0 )
-- Colors. -- Colors.
@@ -109,7 +110,7 @@ local function createTriangle()
RL.BUFFER_FLOAT RL.BUFFER_FLOAT
) )
triangle.vbos.colors = RL.rlLoadVertexBuffer( colors, false ) 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 ) RL.rlEnableVertexAttribute( 1 )
-- Texcoords. -- Texcoords.
@@ -122,7 +123,7 @@ local function createTriangle()
RL.BUFFER_FLOAT RL.BUFFER_FLOAT
) )
triangle.vbos.texcoors = RL.rlLoadVertexBuffer( texcoors, false ) 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 ) RL.rlEnableVertexAttribute( 2 )
-- Disable. -- Disable.
@@ -131,8 +132,8 @@ local function createTriangle()
end end
function RL.init() function RL.init()
local monitorPos = Vec2:newT( RL.GetMonitorPosition( monitor ) ) local monitorPos = Vector2:newT( RL.GetMonitorPosition( monitor ) )
local monitorSize = Vec2:newT( RL.GetMonitorSize( monitor ) ) local monitorSize = Vector2:newT( RL.GetMonitorSize( monitor ) )
RL.SetWindowTitle( "RLGL Hello Triangle" ) RL.SetWindowTitle( "RLGL Hello Triangle" )
RL.SetWindowState( RL.FLAG_WINDOW_RESIZABLE ) RL.SetWindowState( RL.FLAG_WINDOW_RESIZABLE )

View File

@@ -2875,6 +2875,23 @@ int GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, in
keyCount++; keyCount++;
valueHasChanged = true; 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 // NOTE: We are not clamp values until user input finishes
//if (*value > maxValue) *value = maxValue; //if (*value > maxValue) *value = maxValue;

View File

@@ -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 lrlglSetVertexAttribute( lua_State* L ) {
int index = luaL_checkinteger( L, 1 ); int index = luaL_checkinteger( L, 1 );
@@ -1226,9 +1226,9 @@ int lrlglSetVertexAttribute( lua_State* L ) {
int type = luaL_checkinteger( L, 3 ); int type = luaL_checkinteger( L, 3 );
bool normalized = uluaGetBoolean( L, 4 ); bool normalized = uluaGetBoolean( L, 4 );
int stride = luaL_checkinteger( L, 5 ); 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; return 0;
} }