-
Notifications
You must be signed in to change notification settings - Fork 5
Closed
Labels
Description
Hi @mgrojo, I was trying to use shaders functions such as Sf.Graphics.Shader.createFromFile or Sf.Graphics.Shader.createFromFile and got into problems. The issue is that those functions expect C strings (a.k.a. pointers) and the Ada String type is not that.
I see two complementary solutions to that:
- Change the specification to use the type
Interfaces.C.Strings .chars_ptr, and let the users do the conversion. - Add an Ada
Stringfriendly version of the function that does the conversion for the users.
function createFromFile
(vertexShaderFilename : chars_ptr;
geometryShaderFilename : chars_ptr;
fragmentShaderFilename : chars_ptr) return sfShader_Ptr;
function createFromFile
(vertexShaderFilename : String;
geometryShaderFilename : String;
fragmentShaderFilename : String) return sfShader_Ptr;
-- In the body
function createFromFile
(vertexShaderFilename : String;
geometryShaderFilename : String;
fragmentShaderFilename : String) return sfShader_Ptr
is
C_vertexShaderFilename : chars_ptr := New_String (vertexShaderFilename);
C_geometryShaderFilename : chars_ptr := New_String (geometryShaderFilename);
C_fragmentShaderFilename : chars_ptr := New_String (fragmentShaderFilename);
Result : sfShader_Ptr;
begin
Result := createFromFole (C_vertexShaderFilename, C_geometryShaderFilename, C_fragmentShaderFilename);
Free (C_vertexShaderFilename);
Free (C_geometryShaderFilename);
Free (C_fragmentShaderFilename);
end createFromFile;Thanks for all the great work :)
Reactions are currently unavailable