Skip to content

Commit

Permalink
Align with CSFML master branch after fix of #227
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrojo committed Feb 14, 2024
1 parent 2447879 commit d440873
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 120 deletions.
2 changes: 1 addition & 1 deletion doc/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GNATdoc.Index = {
"project": "ASFML",
"timestamp": "2024-02-11 18:20:10"
"timestamp": "2024-02-11 22:29:49"
};
86 changes: 4 additions & 82 deletions doc/srcs/sf-window-vulkan.ads.js
Original file line number Diff line number Diff line change
Expand Up @@ -1491,89 +1491,11 @@ GNATdoc.SourceFile = {
"kind": "line",
"number": 74,
"children": [
{
"kind": "span",
"cssClass": "text",
"text": " "
},
{
"kind": "span",
"cssClass": "keyword",
"text": "pragma"
},
{
"kind": "span",
"cssClass": "text",
"text": " "
},
{
"kind": "span",
"cssClass": "identifier",
"text": "Compile_Time_Warning"
}
]
},
{
"kind": "line",
"number": 75,
"children": [
{
"kind": "span",
"cssClass": "text",
"text": " "
},
{
"kind": "span",
"cssClass": "identifier",
"text": "("
},
{
"kind": "span",
"cssClass": "identifier",
"text": "True"
},
{
"kind": "span",
"cssClass": "identifier",
"text": ","
}
]
},
{
"kind": "line",
"number": 76,
"children": [
{
"kind": "span",
"cssClass": "text",
"text": " "
},
{
"kind": "span",
"cssClass": "string",
"text": "\"getGraphicsRequiredInstanceExtensions is broken; see https://github.com/SFML/CSFML/issues/227\""
},
{
"kind": "span",
"cssClass": "identifier",
"text": ")"
},
{
"kind": "span",
"cssClass": "identifier",
"text": ";"
}
]
},
{
"kind": "line",
"number": 77,
"children": [
]
},
{
"kind": "line",
"number": 78,
"children": [
{
"kind": "span",
Expand All @@ -1584,13 +1506,13 @@ GNATdoc.SourceFile = {
},
{
"kind": "line",
"number": 79,
"number": 76,
"children": [
]
},
{
"kind": "line",
"number": 80,
"number": 77,
"children": [
{
"kind": "span",
Expand Down Expand Up @@ -1657,7 +1579,7 @@ GNATdoc.SourceFile = {
},
{
"kind": "line",
"number": 81,
"number": 78,
"children": [
{
"kind": "span",
Expand All @@ -1668,7 +1590,7 @@ GNATdoc.SourceFile = {
},
{
"kind": "line",
"number": 85,
"number": 82,
"children": [
{
"kind": "span",
Expand Down
2 changes: 1 addition & 1 deletion include/sf-system-thread.ads
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ package Sf.System.Thread is
--/
--//////////////////////////////////////////////////////////
function create (func : sfThreadFunc_Ptr;
userData : Standard.System.Address) return sfThread_Ptr;
userData : Standard.System.Address) return sfThread_Ptr;

--//////////////////////////////////////////////////////////
--/ @brief Destroy a thread
Expand Down
44 changes: 18 additions & 26 deletions include/sf-window-vulkan.adb
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,30 @@ package body Sf.Window.Vulkan is

function getGraphicsRequiredInstanceExtensions return sfArrayOfStrings is
use Interfaces.C;
use Interfaces.C.Strings;

function Internal return Standard.System.Address;
function Internal (count : access sfSize_t) return Standard.System.Address;
pragma Import (C, Internal, "sfVulkan_getGraphicsRequiredInstanceExtensions");

-- Arbitrary maximum
Maximum : constant := 256;
result : constant Standard.System.Address := Internal;
Last : sfSize_t;
subtype Sf_Chars_Ptr_Array is Strings.Chars_Ptr_Array (0 .. Maximum - 1);
cGraphicsRequiredInstanceExtensions : Sf_Chars_Ptr_Array;
pragma Import (Ada, cGraphicsRequiredInstanceExtensions);
for cGraphicsRequiredInstanceExtensions'Address use result;

AdaGraphicsRequiredInstanceExtensions : sfArrayOfStrings (0 .. Maximum - 1);

count : aliased sfSize_t;
result : constant Standard.System.Address := Internal (count'access);

begin
-- Empty case
if cGraphicsRequiredInstanceExtensions (0) = Null_Ptr then
return AdaGraphicsRequiredInstanceExtensions (1 .. 0);
end if;
declare
subtype Array_Of_Strings_Type is Strings.Chars_Ptr_Array (0 .. size_t (count) - 1);
cArray_Of_Strings : Array_Of_Strings_Type;
pragma Import (Ada, cArray_Of_Strings);
for cArray_Of_Strings'Address use result;

for i in Sf_Chars_Ptr_Array'Range loop
exit when cGraphicsRequiredInstanceExtensions (i) = Null_Ptr;
Last := sfSize_t (i);
AdaGraphicsRequiredInstanceExtensions (Last) :=
Ada.Strings.Unbounded.To_Unbounded_String
(Interfaces.C.Strings.Value (cGraphicsRequiredInstanceExtensions (i)));
end loop;
AdaArray_Of_Strings : sfArrayOfStrings (0 .. count - 1);

return AdaGraphicsRequiredInstanceExtensions (0 .. Last);
end getGraphicsRequiredInstanceExtensions;
begin
for i in Array_Of_Strings_Type'Range loop
AdaArray_Of_Strings(sfSize_t(i)) := Ada.Strings.Unbounded.To_Unbounded_String
(Interfaces.C.Strings.Value (cArray_Of_Strings(i)));
end loop;

return AdaArray_Of_Strings;
end;
end getGraphicsRequiredInstanceExtensions;

end Sf.Window.Vulkan;
3 changes: 0 additions & 3 deletions include/sf-window-vulkan.ads
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ package Sf.Window.Vulkan is
--/
--//////////////////////////////////////////////////////////
function getGraphicsRequiredInstanceExtensions return sfArrayOfStrings;
pragma Compile_Time_Warning
(True,
"getGraphicsRequiredInstanceExtensions is broken; see https://github.com/SFML/CSFML/issues/227");

private

Expand Down
10 changes: 3 additions & 7 deletions tests/vulkan/main.adb
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,15 @@ begin

if Sf.Window.Vulkan.isAvailable (requireGraphics => sf.sfTrue) then
Ada.Text_IO.Put_Line ("Vulkan with Graphics supported");
for Extension of Sf.Window.Vulkan.getGraphicsRequiredInstanceExtensions loop
Ada.Strings.Unbounded.Text_IO.Put_Line (Extension);
end loop;
else
if Sf.Window.Vulkan.isAvailable (requireGraphics => sf.sfFalse) then
Ada.Text_IO.Put_Line ("Vulkan without Graphics supported");
else
Ada.Text_IO.Put_Line ("Vulkan not supported");
end if;
-- API with problems, see https://github.com/SFML/CSFML/issues/227
-- for Extension of Sf.Window.Vulkan.getGraphicsRequiredInstanceExtensions loop
-- Ada.Strings.Unbounded.Text_IO.Put_Line (Extension);
-- end loop;
end if;

while IsOpen (Window) = sfTrue loop
Expand All @@ -48,9 +47,6 @@ begin
Put_Line ("Attempting to close");
end if;
end loop;



end loop;
Destroy (Window);

Expand Down

0 comments on commit d440873

Please sign in to comment.