Browse Source

Updating the demo code to support Delphi & FreePascal

- Tested with Delphi 12.0
Coldzer0 1 year ago
parent
commit
76f57db065
8 changed files with 410 additions and 224 deletions
  1. 54 19
      demo/ImGuiDemo.dpr
  2. 194 0
      demo/ImGuiDemo.dproj
  3. BIN
      demo/ImGuiDemo.exe
  4. 1 1
      demo/ImGuiDemo.lpi
  5. 138 186
      demo/ImGuiDemo.lps
  6. BIN
      demo/ImGuiDemo_Icon.ico
  7. 1 1
      demo/imgui_extra.pas
  8. 22 17
      demo/testwindow.pas

+ 54 - 19
demo/ImGuiDemo.lpr → demo/ImGuiDemo.dpr

@@ -1,5 +1,5 @@
 {
 {
-  FreePascal bindings for ImGui
+  FreePascal / Delphi bindings for ImGui
 
 
   Copyright (C) 2023 Coldzer0 <Coldzer0 [at] protonmail.ch>
   Copyright (C) 2023 Coldzer0 <Coldzer0 [at] protonmail.ch>
 
 
@@ -31,7 +31,9 @@ Program ImGuiDemo;
 {$EndIf}
 {$EndIf}
 
 
 Uses
 Uses
+  {$IFDEF FPC}
   cmem,
   cmem,
+  {$ENDIF}
   SysUtils,
   SysUtils,
   sdl2,
   sdl2,
   glad_gl,
   glad_gl,
@@ -67,7 +69,7 @@ Var
   flags: Longword;
   flags: Longword;
   gl_context: TSDL_GLContext;
   gl_context: TSDL_GLContext;
   w, h: Integer;
   w, h: Integer;
-  glsl_version: PChar = '';
+  glsl_version: PAnsiChar = '';
 
 
 
 
 
 
@@ -76,7 +78,7 @@ Var
     draw_list: PImDrawList;
     draw_list: PImDrawList;
     pos: ImVec2;
     pos: ImVec2;
   Const
   Const
-    HelloPascal: PChar = ' Hello From FreePascal ';
+    HelloPascal: PAnsiChar = ' Hello From FreePascal / Delphi ';
   Begin
   Begin
     Begin
     Begin
       //ImGui.SetWindowPos(ImVec2.New(100, 100), ImGuiCond_FirstUseEver);
       //ImGui.SetWindowPos(ImVec2.New(100, 100), ImGuiCond_FirstUseEver);
@@ -109,7 +111,7 @@ Var
       ImGui.SetCursorScreenPos(pos);
       ImGui.SetCursorScreenPos(pos);
 
 
       draw_list^.AddRectFilled(pos, ImVec2.New(pos.x +
       draw_list^.AddRectFilled(pos, ImVec2.New(pos.x +
-        ImGui.CalcTextSize(HelloPascal).x, pos.y + 20), $88005500);
+        ImGui.CalcTextSize(HelloPascal).x, pos.y + Trunc(ImGui.GetFont()^.EllipsisWidth * 2)), $88005500);
       ImGui.Text(HelloPascal);
       ImGui.Text(HelloPascal);
 
 
       If ImGui.IsWindowHovered() Then
       If ImGui.IsWindowHovered() Then
@@ -118,11 +120,12 @@ Var
         ImGui.Text('some window hovered');
         ImGui.Text('some window hovered');
       ImGui.End_;
       ImGui.End_;
     End;
     End;
+
     Pos := ImGui.GetCenterViewPort(ImGui.GetMainViewport());
     Pos := ImGui.GetCenterViewPort(ImGui.GetMainViewport());
-    Pos.y += 100;
+    Pos.y := Pos.y + 100;
     ImGui.SetNextWindowPos(Pos, ImGuiCond_FirstUseEver, ImVec2.New(0.5, 0.5));
     ImGui.SetNextWindowPos(Pos, ImGuiCond_FirstUseEver, ImVec2.New(0.5, 0.5));
     Begin
     Begin
-      ImGui.Begin_('Another greeting');
+      ImGui.Begin_('Another greeting', @showAnotherWindow);
       ImGui.SetWindowPos(ImVec2.New(400, 200), ImGuiCond_FirstUseEver);
       ImGui.SetWindowPos(ImVec2.New(400, 200), ImGuiCond_FirstUseEver);
       ImGui.Text('Hello, next world %d', [counter]);
       ImGui.Text('Hello, next world %d', [counter]);
       If ImGui.Button('Not OK!') Then
       If ImGui.Button('Not OK!') Then
@@ -139,11 +142,12 @@ Var
   Begin
   Begin
     //draw your scene or simple windows
     //draw your scene or simple windows
     Pos := ImGui.GetCenterViewPort(ImGui.GetMainViewport());
     Pos := ImGui.GetCenterViewPort(ImGui.GetMainViewport());
-    Pos.y -= 160;
+    Pos.y := Pos.y - 160;
     ImGui.SetNextWindowPos(Pos, ImGuiCond_FirstUseEver, ImVec2.New(0.5, 0.5));
     ImGui.SetNextWindowPos(Pos, ImGuiCond_FirstUseEver, ImVec2.New(0.5, 0.5));
     Begin
     Begin
-      ImGui.Begin_('Hello From FreePascal', nil, ImGuiWindowFlags_None);
+      ImGui.Begin_('Hello From FreePascal / Delphi', nil, ImGuiWindowFlags_None);
       ImGui.Text('This is some useful text', []);
       ImGui.Text('This is some useful text', []);
+
       ImGui.Checkbox('Demo window', @showDemoWindow);
       ImGui.Checkbox('Demo window', @showDemoWindow);
       ImGui.Checkbox('Another Pascal window', @showAnotherWindow);
       ImGui.Checkbox('Another Pascal window', @showAnotherWindow);
       ImGui.Checkbox('Pascal Demo Window', @showPascalDemoWindow);
       ImGui.Checkbox('Pascal Demo Window', @showPascalDemoWindow);
@@ -151,8 +155,10 @@ Var
       ImGui.SliderFloat('Float', @float_value, 0.0, 1.0, '%.3f', ImGuiSliderFlags_None);
       ImGui.SliderFloat('Float', @float_value, 0.0, 1.0, '%.3f', ImGuiSliderFlags_None);
       ImGui.ColorEdit3('Background color', @clearColor, ImGuiColorEditFlags_None);
       ImGui.ColorEdit3('Background color', @clearColor, ImGuiColorEditFlags_None);
 
 
-      If (ImGui.Button('Button')) Then
-        counter += 1;
+      If (ImGui.Button('Add')) Then
+      begin
+         Inc(counter);
+      end;
 
 
       ImGui.SameLine(0.0, -1.0);
       ImGui.SameLine(0.0, -1.0);
       ImGui.Text('counter = %d', [counter]);
       ImGui.Text('counter = %d', [counter]);
@@ -176,16 +182,19 @@ Var
 
 
   Function PasAllocMem(sz: size_t; {%H-}user_data: Pointer): Pointer; Cdecl;
   Function PasAllocMem(sz: size_t; {%H-}user_data: Pointer): Pointer; Cdecl;
   Begin
   Begin
-    Result := cmem.Malloc(sz);
+    Result := {$IFDEF FPC}cmem.Malloc(sz);{$ELSE}AllocMem(sz);{$ENDIF}
   End;
   End;
 
 
   Procedure PasFreeMem(ptr: Pointer; {%H-}user_data: Pointer); Cdecl;
   Procedure PasFreeMem(ptr: Pointer; {%H-}user_data: Pointer); Cdecl;
   Begin
   Begin
-    cmem.Free(ptr);
+    {$IFDEF FPC}cmem.Free(ptr);{$ELSE}FreeMem(ptr);{$ENDIF}
   End;
   End;
 
 
+{$IFDEF FPC}
 Var
 Var
   saved_FpuFlags: Cardinal;
   saved_FpuFlags: Cardinal;
+{$ENDIF}  
+
 
 
   {$R *.res}
   {$R *.res}
 
 
@@ -200,9 +209,13 @@ Begin
   SDL_SetHint(SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING, '1');
   SDL_SetHint(SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING, '1');
 
 
   //open new SDL window with OpenGL rendering support
   //open new SDL window with OpenGL rendering support
-  If SDL_Init(SDL_INIT_VIDEO) < 0 Then
+  If SDL_Init(SDL_INIT_VIDEO or SDL_INIT_TIMER) < 0 Then
   Begin
   Begin
+    {$IFDEF FPC}
     SDL_Log('failed to init: %s', [SDL_GetError()]);
     SDL_Log('failed to init: %s', [SDL_GetError()]);
+    {$ELSE}
+    Writeln(Format('failed to init: %s', [SDL_GetError()]));
+    {$ENDIF}
   End;
   End;
 
 
   // Decide GL+GLSL versions
   // Decide GL+GLSL versions
@@ -223,6 +236,9 @@ Begin
   SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
   SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
   {$EndIf}
   {$EndIf}
 
 
+  // From 2.0.18: Enable native IME.
+  SDL_SetHint(SDL_HINT_IME_SHOW_UI, '1');
+
   SDL_SetHint(SDL_HINT_RENDER_DRIVER, 'opengl');
   SDL_SetHint(SDL_HINT_RENDER_DRIVER, 'opengl');
   SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
   SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
   SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
   SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
@@ -234,11 +250,15 @@ Begin
 
 
   h := 720;
   h := 720;
   w := 1280;
   w := 1280;
-  window := SDL_CreateWindow('Hello From FreePascal (SDL2+OpenGL3)', SDL_WINDOWPOS_CENTERED,
+  window := SDL_CreateWindow('Hello From FreePascal / Delphi (SDL2+OpenGL3)', SDL_WINDOWPOS_CENTERED,
     SDL_WINDOWPOS_CENTERED, w, h, flags);
     SDL_WINDOWPOS_CENTERED, w, h, flags);
   If window = nil Then
   If window = nil Then
   Begin
   Begin
+    {$IFDEF FPC}
     SDL_Log('Failed to create window: %s', [SDL_GetError()]);
     SDL_Log('Failed to create window: %s', [SDL_GetError()]);
+    {$ELSE}
+    Writeln(Format('Failed to create window: %s', [SDL_GetError()]));
+    {$ENDIF}  
     halt;
     halt;
   End;
   End;
 
 
@@ -249,11 +269,25 @@ Begin
   // Loading OpenGL APIs
   // Loading OpenGL APIs
   If Not ImGLInit() Then
   If Not ImGLInit() Then
   Begin
   Begin
+    {$IFDEF FPC}
     SDL_Log('Error while Loading OpenGL3', []);
     SDL_Log('Error while Loading OpenGL3', []);
+    {$ELSE}
+    {$IFDEF DEBUG}
+    Writeln('Error while Loading OpenGL3');
+    {$ENDIF}
+    {$ENDIF}   
+    Halt;
   End;
   End;
 
 
   // Show opengl version sdl uses
   // Show opengl version sdl uses
-  SDL_Log('opengl version: %s', [glGetString(GL_VERSION)]);
+  {$IFDEF FPC}
+  SDL_Log('Opengl version: %s', [glGetString(GL_VERSION)]);
+  {$ELSE}
+  {$IFDEF DEBUG}
+  Writeln(Format('Opengl version: %s', [PAnsiChar(glGetString(GL_VERSION))]));
+  {$ENDIF}
+  {$ENDIF}   
+  
 
 
   // setup imgui
   // setup imgui
   ImGui.CreateContext(nil);
   ImGui.CreateContext(nil);
@@ -293,7 +327,7 @@ Begin
     style^.Colors[Ord(ImGuiCol_WindowBg)].w := 1.0;
     style^.Colors[Ord(ImGuiCol_WindowBg)].w := 1.0;
   end;
   end;
 
 
-  // Fonts
+  // Load Fonts
   //ioptr^.Fonts^.AddFontDefault();
   //ioptr^.Fonts^.AddFontDefault();
   ioptr^.Fonts^.AddFontFromFileTTF('fonts/DroidSans.ttf', 20.0);
   ioptr^.Fonts^.AddFontFromFileTTF('fonts/DroidSans.ttf', 20.0);
 
 
@@ -337,12 +371,12 @@ Begin
     SDL_GL_MakeCurrent(window, gl_context);
     SDL_GL_MakeCurrent(window, gl_context);
 
 
 
 
-    saved_FpuFlags := SetFpuFlags();
+    {$IFDEF FPC}saved_FpuFlags := SetFpuFlags();{$ENDIF}
     glViewport(0, 0, Trunc(ioptr^.DisplaySize.x), Trunc(ioptr^.DisplaySize.y));
     glViewport(0, 0, Trunc(ioptr^.DisplaySize.x), Trunc(ioptr^.DisplaySize.y));
     glClearColor(clearColor.x, clearColor.y, clearColor.z, clearColor.w);
     glClearColor(clearColor.x, clearColor.y, clearColor.z, clearColor.w);
     glClear(GL_COLOR_BUFFER_BIT);
     glClear(GL_COLOR_BUFFER_BIT);
-    ResetFpuFlags(saved_FpuFlags);
-
+    {$IFDEF FPC}ResetFpuFlags(saved_FpuFlags);{$ENDIF}
+    
     ImGui_Impl_OpenGL3_RenderDrawData(ImGui.GetDrawData());
     ImGui_Impl_OpenGL3_RenderDrawData(ImGui.GetDrawData());
 
 
 
 
@@ -376,3 +410,4 @@ Begin
   End;
   End;
   SDL_Quit();
   SDL_Quit();
 End.
 End.
+

+ 194 - 0
demo/ImGuiDemo.dproj

@@ -0,0 +1,194 @@
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+    <PropertyGroup>
+        <ProjectGuid>{B77F45C3-3CEB-4E07-9F00-8AFFDA8F2C9C}</ProjectGuid>
+        <MainSource>ImGuiDemo.dpr</MainSource>
+        <Base>True</Base>
+        <Config Condition="'$(Config)'==''">Release</Config>
+        <TargetedPlatforms>660611</TargetedPlatforms>
+        <AppType>Console</AppType>
+        <FrameworkType>None</FrameworkType>
+        <ProjectVersion>20.1</ProjectVersion>
+        <Platform Condition="'$(Platform)'==''">Win64</Platform>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
+        <Base>true</Base>
+    </PropertyGroup>
+    <PropertyGroup Condition="('$(Platform)'=='iOSDevice64' and '$(Base)'=='true') or '$(Base_iOSDevice64)'!=''">
+        <Base_iOSDevice64>true</Base_iOSDevice64>
+        <CfgParent>Base</CfgParent>
+        <Base>true</Base>
+    </PropertyGroup>
+    <PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Base)'=='true') or '$(Base_Win32)'!=''">
+        <Base_Win32>true</Base_Win32>
+        <CfgParent>Base</CfgParent>
+        <Base>true</Base>
+    </PropertyGroup>
+    <PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Base)'=='true') or '$(Base_Win64)'!=''">
+        <Base_Win64>true</Base_Win64>
+        <CfgParent>Base</CfgParent>
+        <Base>true</Base>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_1)'!=''">
+        <Cfg_1>true</Cfg_1>
+        <CfgParent>Base</CfgParent>
+        <Base>true</Base>
+    </PropertyGroup>
+    <PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win64)'!=''">
+        <Cfg_1_Win64>true</Cfg_1_Win64>
+        <CfgParent>Cfg_1</CfgParent>
+        <Cfg_1>true</Cfg_1>
+        <Base>true</Base>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_2)'!=''">
+        <Cfg_2>true</Cfg_2>
+        <CfgParent>Base</CfgParent>
+        <Base>true</Base>
+    </PropertyGroup>
+    <PropertyGroup Condition="('$(Platform)'=='iOSDevice64' and '$(Cfg_2)'=='true') or '$(Cfg_2_iOSDevice64)'!=''">
+        <Cfg_2_iOSDevice64>true</Cfg_2_iOSDevice64>
+        <CfgParent>Cfg_2</CfgParent>
+        <Cfg_2>true</Cfg_2>
+        <Base>true</Base>
+    </PropertyGroup>
+    <PropertyGroup Condition="('$(Platform)'=='OSX64' and '$(Cfg_2)'=='true') or '$(Cfg_2_OSX64)'!=''">
+        <Cfg_2_OSX64>true</Cfg_2_OSX64>
+        <CfgParent>Cfg_2</CfgParent>
+        <Cfg_2>true</Cfg_2>
+        <Base>true</Base>
+    </PropertyGroup>
+    <PropertyGroup Condition="('$(Platform)'=='OSXARM64' and '$(Cfg_2)'=='true') or '$(Cfg_2_OSXARM64)'!=''">
+        <Cfg_2_OSXARM64>true</Cfg_2_OSXARM64>
+        <CfgParent>Cfg_2</CfgParent>
+        <Cfg_2>true</Cfg_2>
+        <Base>true</Base>
+    </PropertyGroup>
+    <PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win32)'!=''">
+        <Cfg_2_Win32>true</Cfg_2_Win32>
+        <CfgParent>Cfg_2</CfgParent>
+        <Cfg_2>true</Cfg_2>
+        <Base>true</Base>
+    </PropertyGroup>
+    <PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win64)'!=''">
+        <Cfg_2_Win64>true</Cfg_2_Win64>
+        <CfgParent>Cfg_2</CfgParent>
+        <Cfg_2>true</Cfg_2>
+        <Base>true</Base>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Base)'!=''">
+        <DCC_E>false</DCC_E>
+        <DCC_F>false</DCC_F>
+        <DCC_K>false</DCC_K>
+        <DCC_N>false</DCC_N>
+        <DCC_S>false</DCC_S>
+        <DCC_ImageBase>00400000</DCC_ImageBase>
+        <SanitizedProjectName>ImGuiDemo</SanitizedProjectName>
+        <VerInfo_Locale>1033</VerInfo_Locale>
+        <VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName=</VerInfo_Keys>
+        <DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)</DCC_Namespace>
+        <Icon_MainIcon>$(BDS)\bin\delphi_PROJECTICON.ico</Icon_MainIcon>
+        <Icns_MainIcns>$(BDS)\bin\delphi_PROJECTICNS.icns</Icns_MainIcns>
+        <DCC_ExeOutput>.\</DCC_ExeOutput>
+        <DCC_DcuOutput>.\$(Platform)\$(Config)\dcu</DCC_DcuOutput>
+        <DCC_UnitSearchPath>..\src;..\impl;..\OpenGL3;..\SDL2-for-Pascal\units;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Base_iOSDevice64)'!=''">
+        <iOS_AppStore1024>$(BDS)\bin\Artwork\iOS\iPhone\FM_ApplicationIcon_1024x1024.png</iOS_AppStore1024>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Base_Win32)'!=''">
+        <DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
+        <BT_BuildType>Debug</BT_BuildType>
+        <VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName)</VerInfo_Keys>
+        <VerInfo_Locale>1033</VerInfo_Locale>
+        <Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File>
+        <Icon_MainIcon>ImGuiDemo_Icon.ico</Icon_MainIcon>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Base_Win64)'!=''">
+        <Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File>
+        <Icon_MainIcon>ImGuiDemo_Icon.ico</Icon_MainIcon>
+        <DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace)</DCC_Namespace>
+        <BT_BuildType>Debug</BT_BuildType>
+        <VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Cfg_1)'!=''">
+        <DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
+        <DCC_DebugInformation>0</DCC_DebugInformation>
+        <DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
+        <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
+        <VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
+        <Icon_MainIcon>ImGuiDemo_Icon.ico</Icon_MainIcon>
+        <AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Cfg_2)'!=''">
+        <DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
+        <DCC_Optimize>false</DCC_Optimize>
+        <DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
+        <DCC_RangeChecking>true</DCC_RangeChecking>
+        <DCC_IntegerOverflowCheck>true</DCC_IntegerOverflowCheck>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Cfg_2_iOSDevice64)'!=''">
+        <BT_BuildType>Debug</BT_BuildType>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Cfg_2_OSX64)'!=''">
+        <BT_BuildType>Debug</BT_BuildType>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Cfg_2_OSXARM64)'!=''">
+        <BT_BuildType>Debug</BT_BuildType>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
+        <VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName)</VerInfo_Keys>
+        <Icon_MainIcon>ImGuiDemo_Icon.ico</Icon_MainIcon>
+        <AppDPIAwarenessMode>none</AppDPIAwarenessMode>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Cfg_2_Win64)'!=''">
+        <VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
+        <Icon_MainIcon>ImGuiDemo_Icon.ico</Icon_MainIcon>
+        <AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
+    </PropertyGroup>
+    <ItemGroup>
+        <DelphiCompile Include="$(MainSource)">
+            <MainSource>MainSource</MainSource>
+        </DelphiCompile>
+        <BuildConfiguration Include="Base">
+            <Key>Base</Key>
+        </BuildConfiguration>
+        <BuildConfiguration Include="Release">
+            <Key>Cfg_1</Key>
+            <CfgParent>Base</CfgParent>
+        </BuildConfiguration>
+        <BuildConfiguration Include="Debug">
+            <Key>Cfg_2</Key>
+            <CfgParent>Base</CfgParent>
+        </BuildConfiguration>
+    </ItemGroup>
+    <ProjectExtensions>
+        <Borland.Personality>Delphi.Personality.12</Borland.Personality>
+        <Borland.ProjectType/>
+        <BorlandProject>
+            <Delphi.Personality>
+                <Source>
+                    <Source Name="MainSource">ImGuiDemo.dpr</Source>
+                </Source>
+                <Excluded_Packages>
+                    <Excluded_Packages Name="$(BDSBIN)\bcboffice2k290.bpl">Embarcadero C++Builder Office 2000 Servers Package</Excluded_Packages>
+                    <Excluded_Packages Name="$(BDSBIN)\bcbofficexp290.bpl">Embarcadero C++Builder Office XP Servers Package</Excluded_Packages>
+                    <Excluded_Packages Name="$(BDSBIN)\dcloffice2k290.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
+                    <Excluded_Packages Name="$(BDSBIN)\dclofficexp290.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
+                </Excluded_Packages>
+            </Delphi.Personality>
+            <Platforms>
+                <Platform value="iOSDevice64">True</Platform>
+                <Platform value="iOSSimARM64">True</Platform>
+                <Platform value="Linux64">True</Platform>
+                <Platform value="OSX64">True</Platform>
+                <Platform value="OSXARM64">True</Platform>
+                <Platform value="Win32">True</Platform>
+                <Platform value="Win64">True</Platform>
+            </Platforms>
+        </BorlandProject>
+        <ProjectFileVersion>12</ProjectFileVersion>
+    </ProjectExtensions>
+    <Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/>
+    <Import Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj" Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')"/>
+</Project>

BIN
demo/ImGuiDemo.exe


+ 1 - 1
demo/ImGuiDemo.lpi

@@ -136,7 +136,7 @@
     </RunParams>
     </RunParams>
     <Units Count="5">
     <Units Count="5">
       <Unit0>
       <Unit0>
-        <Filename Value="ImGuiDemo.lpr"/>
+        <Filename Value="ImGuiDemo.dpr"/>
         <IsPartOfProject Value="True"/>
         <IsPartOfProject Value="True"/>
       </Unit0>
       </Unit0>
       <Unit1>
       <Unit1>

+ 138 - 186
demo/ImGuiDemo.lps

@@ -3,15 +3,13 @@
   <ProjectSession>
   <ProjectSession>
     <PathDelim Value="\"/>
     <PathDelim Value="\"/>
     <Version Value="12"/>
     <Version Value="12"/>
-    <BuildModes Active="Release_windows"/>
-    <Units Count="55">
+    <BuildModes Active="Debug_windows"/>
+    <Units Count="51">
       <Unit0>
       <Unit0>
-        <Filename Value="ImGuiDemo.lpr"/>
+        <Filename Value="ImGuiDemo.dpr"/>
         <IsPartOfProject Value="True"/>
         <IsPartOfProject Value="True"/>
         <IsVisibleTab Value="True"/>
         <IsVisibleTab Value="True"/>
-        <TopLine Value="275"/>
-        <CursorPos X="19" Y="298"/>
-        <FoldState Value=" T3iU2yd"/>
+        <CursorPos X="52" Y="14"/>
         <UsageCount Value="200"/>
         <UsageCount Value="200"/>
         <Loaded Value="True"/>
         <Loaded Value="True"/>
       </Unit0>
       </Unit0>
@@ -20,8 +18,8 @@
         <IsPartOfProject Value="True"/>
         <IsPartOfProject Value="True"/>
         <UnitName Value="TestWindow"/>
         <UnitName Value="TestWindow"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
-        <TopLine Value="141"/>
-        <CursorPos X="31" Y="156"/>
+        <TopLine Value="72"/>
+        <CursorPos X="15" Y="87"/>
         <UsageCount Value="200"/>
         <UsageCount Value="200"/>
       </Unit1>
       </Unit1>
       <Unit2>
       <Unit2>
@@ -43,14 +41,14 @@
         <Filename Value="..\OpenGL3\OpenGl3.Loader.pas"/>
         <Filename Value="..\OpenGL3\OpenGl3.Loader.pas"/>
         <IsPartOfProject Value="True"/>
         <IsPartOfProject Value="True"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
-        <UsageCount Value="199"/>
+        <UsageCount Value="204"/>
       </Unit4>
       </Unit4>
       <Unit5>
       <Unit5>
         <Filename Value="display.pas"/>
         <Filename Value="display.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="135"/>
         <TopLine Value="135"/>
         <CursorPos X="10" Y="143"/>
         <CursorPos X="10" Y="143"/>
-        <UsageCount Value="196"/>
+        <UsageCount Value="194"/>
       </Unit5>
       </Unit5>
       <Unit6>
       <Unit6>
         <Filename Value="sdl2.pas"/>
         <Filename Value="sdl2.pas"/>
@@ -58,361 +56,315 @@
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="9926"/>
         <TopLine Value="9926"/>
         <CursorPos X="30" Y="9944"/>
         <CursorPos X="30" Y="9944"/>
-        <UsageCount Value="196"/>
+        <UsageCount Value="194"/>
       </Unit6>
       </Unit6>
       <Unit7>
       <Unit7>
         <Filename Value="..\fpimgui.pas"/>
         <Filename Value="..\fpimgui.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <CursorPos X="16" Y="6"/>
         <CursorPos X="16" Y="6"/>
-        <UsageCount Value="196"/>
+        <UsageCount Value="194"/>
       </Unit7>
       </Unit7>
       <Unit8>
       <Unit8>
         <Filename Value="..\examples\fpimgui_impl_sdlgl2.pas"/>
         <Filename Value="..\examples\fpimgui_impl_sdlgl2.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
-        <UsageCount Value="196"/>
+        <UsageCount Value="194"/>
       </Unit8>
       </Unit8>
       <Unit9>
       <Unit9>
         <Filename Value="..\ImGui.Types.pas"/>
         <Filename Value="..\ImGui.Types.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="518"/>
         <TopLine Value="518"/>
         <CursorPos X="23" Y="535"/>
         <CursorPos X="23" Y="535"/>
-        <UsageCount Value="196"/>
+        <UsageCount Value="194"/>
       </Unit9>
       </Unit9>
       <Unit10>
       <Unit10>
         <Filename Value="ImGui.Enums.pas"/>
         <Filename Value="ImGui.Enums.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
-        <UsageCount Value="198"/>
+        <UsageCount Value="196"/>
       </Unit10>
       </Unit10>
       <Unit11>
       <Unit11>
         <Filename Value="..\impl\PasImGui.Impl.SDL2.pas"/>
         <Filename Value="..\impl\PasImGui.Impl.SDL2.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <CursorPos X="27" Y="16"/>
         <CursorPos X="27" Y="16"/>
-        <UsageCount Value="196"/>
+        <UsageCount Value="194"/>
       </Unit11>
       </Unit11>
       <Unit12>
       <Unit12>
         <Filename Value="..\impl\PasImGui.Impl.OpenGL3.pas"/>
         <Filename Value="..\impl\PasImGui.Impl.OpenGL3.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="36"/>
         <TopLine Value="36"/>
         <CursorPos X="56" Y="45"/>
         <CursorPos X="56" Y="45"/>
-        <UsageCount Value="196"/>
+        <UsageCount Value="194"/>
       </Unit12>
       </Unit12>
       <Unit13>
       <Unit13>
         <Filename Value="..\PasImGui.Gen.Types.pas"/>
         <Filename Value="..\PasImGui.Gen.Types.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="163"/>
         <TopLine Value="163"/>
         <CursorPos Y="177"/>
         <CursorPos Y="177"/>
-        <UsageCount Value="201"/>
+        <UsageCount Value="199"/>
       </Unit13>
       </Unit13>
       <Unit14>
       <Unit14>
         <Filename Value="..\PasImGui.SDL2.pas"/>
         <Filename Value="..\PasImGui.SDL2.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="114"/>
         <TopLine Value="114"/>
         <CursorPos X="52" Y="143"/>
         <CursorPos X="52" Y="143"/>
-        <UsageCount Value="162"/>
+        <UsageCount Value="160"/>
       </Unit14>
       </Unit14>
       <Unit15>
       <Unit15>
-        <Filename Value="..\ImGui.Apis.pas"/>
-        <UnitName Value="PasImGui.Apis"/>
-        <EditorIndex Value="-1"/>
-        <CursorPos X="14" Y="6"/>
-        <UsageCount Value="0"/>
-      </Unit15>
-      <Unit16>
         <Filename Value="..\PasImGui.Apis.pas"/>
         <Filename Value="..\PasImGui.Apis.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="106"/>
         <TopLine Value="106"/>
         <CursorPos X="31" Y="122"/>
         <CursorPos X="31" Y="122"/>
-        <UsageCount Value="104"/>
-      </Unit16>
-      <Unit17>
+        <UsageCount Value="102"/>
+      </Unit15>
+      <Unit16>
         <Filename Value="..\PasImGui.Types.pas"/>
         <Filename Value="..\PasImGui.Types.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="30"/>
         <TopLine Value="30"/>
         <CursorPos X="24" Y="40"/>
         <CursorPos X="24" Y="40"/>
-        <UsageCount Value="103"/>
-      </Unit17>
-      <Unit18>
+        <UsageCount Value="101"/>
+      </Unit16>
+      <Unit17>
         <Filename Value="..\PasImGui.Enums.pas"/>
         <Filename Value="..\PasImGui.Enums.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="703"/>
         <TopLine Value="703"/>
         <CursorPos X="40" Y="729"/>
         <CursorPos X="40" Y="729"/>
-        <UsageCount Value="98"/>
-      </Unit18>
-      <Unit19>
+        <UsageCount Value="96"/>
+      </Unit17>
+      <Unit18>
         <Filename Value="..\PasImGui.pas"/>
         <Filename Value="..\PasImGui.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="42"/>
         <TopLine Value="42"/>
         <CursorPos X="20" Y="58"/>
         <CursorPos X="20" Y="58"/>
-        <UsageCount Value="96"/>
-      </Unit19>
-      <Unit20>
+        <UsageCount Value="94"/>
+      </Unit18>
+      <Unit19>
         <Filename Value="..\..\PasGen\PasImGui.Apis.pas"/>
         <Filename Value="..\..\PasGen\PasImGui.Apis.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="1423"/>
         <TopLine Value="1423"/>
         <CursorPos X="7" Y="1515"/>
         <CursorPos X="7" Y="1515"/>
-        <UsageCount Value="2"/>
-      </Unit20>
-      <Unit21>
+        <UsageCount Value="10"/>
+      </Unit19>
+      <Unit20>
         <Filename Value="..\..\PasGen\Full.pas"/>
         <Filename Value="..\..\PasGen\Full.pas"/>
         <UnitName Value="PasImGui.Types"/>
         <UnitName Value="PasImGui.Types"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="709"/>
         <TopLine Value="709"/>
         <CursorPos X="23" Y="722"/>
         <CursorPos X="23" Y="722"/>
-        <UsageCount Value="2"/>
-      </Unit21>
-      <Unit22>
+        <UsageCount Value="10"/>
+      </Unit20>
+      <Unit21>
         <Filename Value="..\..\PasGen\PasImGui.Enums.pas"/>
         <Filename Value="..\..\PasGen\PasImGui.Enums.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="1461"/>
         <TopLine Value="1461"/>
         <CursorPos Y="1487"/>
         <CursorPos Y="1487"/>
-        <UsageCount Value="2"/>
-      </Unit22>
-      <Unit23>
-        <Filename Value="..\..\cimgui\imgui\backends\imgui_impl_opengl3.cpp"/>
-        <EditorIndex Value="-1"/>
-        <TopLine Value="387"/>
-        <CursorPos Y="405"/>
-        <UsageCount Value="0"/>
-        <DefaultSyntaxHighlighter Value="C_2B_2B"/>
-      </Unit23>
-      <Unit24>
-        <Filename Value="..\..\cimgui\imgui\backends\imgui_impl_sdl2.cpp"/>
-        <EditorIndex Value="-1"/>
-        <TopLine Value="792"/>
-        <CursorPos Y="793"/>
-        <UsageCount Value="0"/>
-        <DefaultSyntaxHighlighter Value="C_2B_2B"/>
-      </Unit24>
-      <Unit25>
+        <UsageCount Value="10"/>
+      </Unit21>
+      <Unit22>
         <Filename Value="F:\FPCross\fpcsrc\rtl\win\wininc\base.inc"/>
         <Filename Value="F:\FPCross\fpcsrc\rtl\win\wininc\base.inc"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="135"/>
         <TopLine Value="135"/>
         <CursorPos X="6" Y="150"/>
         <CursorPos X="6" Y="150"/>
-        <UsageCount Value="22"/>
-      </Unit25>
-      <Unit26>
+        <UsageCount Value="20"/>
+      </Unit22>
+      <Unit23>
         <Filename Value="F:\FPCross\fpcsrc\rtl\inc\systemh.inc"/>
         <Filename Value="F:\FPCross\fpcsrc\rtl\inc\systemh.inc"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="517"/>
         <TopLine Value="517"/>
         <CursorPos X="3" Y="530"/>
         <CursorPos X="3" Y="530"/>
-        <UsageCount Value="6"/>
-      </Unit26>
-      <Unit27>
+        <UsageCount Value="4"/>
+      </Unit23>
+      <Unit24>
         <Filename Value="F:\FPCross\fpcsrc\rtl\win\wininc\defines.inc"/>
         <Filename Value="F:\FPCross\fpcsrc\rtl\win\wininc\defines.inc"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="3011"/>
         <TopLine Value="3011"/>
         <CursorPos X="6" Y="3021"/>
         <CursorPos X="6" Y="3021"/>
-        <UsageCount Value="5"/>
-      </Unit27>
-      <Unit28>
-        <Filename Value="..\..\..\zydis-pascal-old\Zydis\Zydis.Enums.pas"/>
-        <EditorIndex Value="-1"/>
-        <TopLine Value="34"/>
-        <CursorPos X="49" Y="47"/>
-        <UsageCount Value="0"/>
-      </Unit28>
-      <Unit29>
+        <UsageCount Value="3"/>
+      </Unit24>
+      <Unit25>
         <Filename Value="F:\FPCross\fpcsrc\rtl\inc\resh.inc"/>
         <Filename Value="F:\FPCross\fpcsrc\rtl\inc\resh.inc"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="48"/>
         <TopLine Value="48"/>
         <CursorPos X="10" Y="64"/>
         <CursorPos X="10" Y="64"/>
-        <UsageCount Value="9"/>
-      </Unit29>
-      <Unit30>
+        <UsageCount Value="7"/>
+      </Unit25>
+      <Unit26>
         <Filename Value="..\SDL2-for-Pascal\units\sdlkeycode.inc"/>
         <Filename Value="..\SDL2-for-Pascal\units\sdlkeycode.inc"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="17"/>
         <TopLine Value="17"/>
         <CursorPos X="37" Y="37"/>
         <CursorPos X="37" Y="37"/>
-        <UsageCount Value="10"/>
-      </Unit30>
-      <Unit31>
+        <UsageCount Value="8"/>
+      </Unit26>
+      <Unit27>
         <Filename Value="..\SDL2-for-Pascal\units\sdlsyswm.inc"/>
         <Filename Value="..\SDL2-for-Pascal\units\sdlsyswm.inc"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="224"/>
         <TopLine Value="224"/>
         <CursorPos X="4" Y="240"/>
         <CursorPos X="4" Y="240"/>
-        <UsageCount Value="22"/>
-      </Unit31>
-      <Unit32>
+        <UsageCount Value="20"/>
+      </Unit27>
+      <Unit28>
         <Filename Value="..\SDL2-for-Pascal\units\sdlversion.inc"/>
         <Filename Value="..\SDL2-for-Pascal\units\sdlversion.inc"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="20"/>
         <TopLine Value="20"/>
         <CursorPos X="3" Y="34"/>
         <CursorPos X="3" Y="34"/>
-        <UsageCount Value="21"/>
-      </Unit32>
-      <Unit33>
+        <UsageCount Value="19"/>
+      </Unit28>
+      <Unit29>
         <Filename Value="..\SDL2-for-Pascal\units\sdl2.pas"/>
         <Filename Value="..\SDL2-for-Pascal\units\sdl2.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="186"/>
         <TopLine Value="186"/>
         <CursorPos X="10" Y="202"/>
         <CursorPos X="10" Y="202"/>
-        <UsageCount Value="23"/>
-      </Unit33>
-      <Unit34>
+        <UsageCount Value="21"/>
+      </Unit29>
+      <Unit30>
         <Filename Value="..\SDL2-for-Pascal\units\sdlvideo.inc"/>
         <Filename Value="..\SDL2-for-Pascal\units\sdlvideo.inc"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="1333"/>
         <TopLine Value="1333"/>
         <CursorPos X="10" Y="1348"/>
         <CursorPos X="10" Y="1348"/>
-        <UsageCount Value="7"/>
-      </Unit34>
-      <Unit35>
+        <UsageCount Value="5"/>
+      </Unit30>
+      <Unit31>
         <Filename Value="..\SDL2-for-Pascal\units\sdllog.inc"/>
         <Filename Value="..\SDL2-for-Pascal\units\sdllog.inc"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="76"/>
         <TopLine Value="76"/>
-        <CursorPos X="11" Y="97"/>
-        <UsageCount Value="4"/>
-      </Unit35>
-      <Unit36>
+        <CursorPos Y="97"/>
+        <UsageCount Value="10"/>
+      </Unit31>
+      <Unit32>
         <Filename Value="..\SDL2-for-Pascal\units\sdlerror.inc"/>
         <Filename Value="..\SDL2-for-Pascal\units\sdlerror.inc"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <CursorPos X="10" Y="30"/>
         <CursorPos X="10" Y="30"/>
-        <UsageCount Value="5"/>
-      </Unit36>
-      <Unit37>
+        <UsageCount Value="3"/>
+      </Unit32>
+      <Unit33>
         <Filename Value="F:\FPCross\fpcsrc\rtl\inc\currh.inc"/>
         <Filename Value="F:\FPCross\fpcsrc\rtl\inc\currh.inc"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <CursorPos X="14" Y="22"/>
         <CursorPos X="14" Y="22"/>
-        <UsageCount Value="5"/>
-      </Unit37>
-      <Unit38>
+        <UsageCount Value="3"/>
+      </Unit33>
+      <Unit34>
         <Filename Value="..\SDL2-for-Pascal\units\sdlmessagebox.inc"/>
         <Filename Value="..\SDL2-for-Pascal\units\sdlmessagebox.inc"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="92"/>
         <TopLine Value="92"/>
         <CursorPos X="10" Y="107"/>
         <CursorPos X="10" Y="107"/>
-        <UsageCount Value="6"/>
-      </Unit38>
-      <Unit39>
+        <UsageCount Value="4"/>
+      </Unit34>
+      <Unit35>
         <Filename Value="..\impl\CImGui.Impl.OpenGL3.pas"/>
         <Filename Value="..\impl\CImGui.Impl.OpenGL3.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
-        <UsageCount Value="11"/>
-      </Unit39>
-      <Unit40>
+        <UsageCount Value="9"/>
+      </Unit35>
+      <Unit36>
         <Filename Value="..\impl\PasImGui.SDL2.pas"/>
         <Filename Value="..\impl\PasImGui.SDL2.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
-        <TopLine Value="691"/>
-        <CursorPos X="40" Y="696"/>
-        <UsageCount Value="19"/>
-      </Unit40>
-      <Unit41>
+        <TopLine Value="727"/>
+        <CursorPos X="14" Y="749"/>
+        <UsageCount Value="16"/>
+      </Unit36>
+      <Unit37>
         <Filename Value="..\impl\CImGui.Impl.SDL2.pas"/>
         <Filename Value="..\impl\CImGui.Impl.SDL2.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <CursorPos X="2" Y="14"/>
         <CursorPos X="2" Y="14"/>
-        <UsageCount Value="10"/>
-      </Unit41>
-      <Unit42>
+        <UsageCount Value="8"/>
+      </Unit37>
+      <Unit38>
         <Filename Value="F:\FPCross\fpcsrc\rtl\inc\dynlibs.pas"/>
         <Filename Value="F:\FPCross\fpcsrc\rtl\inc\dynlibs.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="17"/>
         <TopLine Value="17"/>
         <CursorPos X="3" Y="30"/>
         <CursorPos X="3" Y="30"/>
-        <UsageCount Value="10"/>
-      </Unit42>
-      <Unit43>
+        <UsageCount Value="8"/>
+      </Unit38>
+      <Unit39>
         <Filename Value="F:\FPCross\fpcsrc\rtl\unix\sysdlh.inc"/>
         <Filename Value="F:\FPCross\fpcsrc\rtl\unix\sysdlh.inc"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <CursorPos X="3" Y="28"/>
         <CursorPos X="3" Y="28"/>
-        <UsageCount Value="10"/>
-      </Unit43>
-      <Unit44>
+        <UsageCount Value="8"/>
+      </Unit39>
+      <Unit40>
         <Filename Value="F:\FPCross\fpcsrc\rtl\win\sysdlh.inc"/>
         <Filename Value="F:\FPCross\fpcsrc\rtl\win\sysdlh.inc"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <CursorPos X="3" Y="23"/>
         <CursorPos X="3" Y="23"/>
-        <UsageCount Value="6"/>
-      </Unit44>
-      <Unit45>
+        <UsageCount Value="4"/>
+      </Unit40>
+      <Unit41>
         <Filename Value="F:\FPCross\fpcsrc\rtl\objpas\math.pp"/>
         <Filename Value="F:\FPCross\fpcsrc\rtl\objpas\math.pp"/>
         <UnitName Value="Math"/>
         <UnitName Value="Math"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="845"/>
         <TopLine Value="845"/>
         <CursorPos X="3" Y="861"/>
         <CursorPos X="3" Y="861"/>
-        <UsageCount Value="7"/>
-      </Unit45>
-      <Unit46>
+        <UsageCount Value="5"/>
+      </Unit41>
+      <Unit42>
         <Filename Value="F:\FPCross\fpcsrc\rtl\inc\mathh.inc"/>
         <Filename Value="F:\FPCross\fpcsrc\rtl\inc\mathh.inc"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="54"/>
         <TopLine Value="54"/>
         <CursorPos X="45" Y="70"/>
         <CursorPos X="45" Y="70"/>
-        <UsageCount Value="7"/>
-      </Unit46>
-      <Unit47>
+        <UsageCount Value="5"/>
+      </Unit42>
+      <Unit43>
         <Filename Value="..\src\PasImGui.Types.pas"/>
         <Filename Value="..\src\PasImGui.Types.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
-        <TopLine Value="1256"/>
-        <CursorPos X="24" Y="1272"/>
-        <UsageCount Value="11"/>
-      </Unit47>
-      <Unit48>
+        <TopLine Value="1535"/>
+        <CursorPos X="44" Y="1556"/>
+        <UsageCount Value="17"/>
+      </Unit43>
+      <Unit44>
         <Filename Value="..\src\PasImGui.Apis.pas"/>
         <Filename Value="..\src\PasImGui.Apis.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="129"/>
         <TopLine Value="129"/>
         <CursorPos X="156" Y="145"/>
         <CursorPos X="156" Y="145"/>
-        <UsageCount Value="11"/>
-      </Unit48>
-      <Unit49>
+        <UsageCount Value="8"/>
+      </Unit44>
+      <Unit45>
         <Filename Value="..\src\PasImGui.Enums.pas"/>
         <Filename Value="..\src\PasImGui.Enums.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
-        <TopLine Value="453"/>
-        <CursorPos X="5" Y="469"/>
-        <UsageCount Value="13"/>
-      </Unit49>
-      <Unit50>
+        <TopLine Value="1134"/>
+        <CursorPos X="55" Y="1150"/>
+        <UsageCount Value="22"/>
+      </Unit45>
+      <Unit46>
         <Filename Value="..\src\PasImGui.pas"/>
         <Filename Value="..\src\PasImGui.pas"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
-        <TopLine Value="3691"/>
-        <CursorPos X="95" Y="3710"/>
-        <UsageCount Value="12"/>
-      </Unit50>
-      <Unit51>
+        <TopLine Value="202"/>
+        <CursorPos X="21" Y="217"/>
+        <UsageCount Value="13"/>
+      </Unit46>
+      <Unit47>
         <Filename Value="..\SDL2-for-Pascal\units\sdlevents.inc"/>
         <Filename Value="..\SDL2-for-Pascal\units\sdlevents.inc"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="46"/>
         <TopLine Value="46"/>
         <CursorPos X="27" Y="59"/>
         <CursorPos X="27" Y="59"/>
-        <UsageCount Value="10"/>
-      </Unit51>
-      <Unit52>
+        <UsageCount Value="7"/>
+      </Unit47>
+      <Unit48>
         <Filename Value="F:\FPCross\fpcsrc\rtl\inc\cmem.pp"/>
         <Filename Value="F:\FPCross\fpcsrc\rtl\inc\cmem.pp"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="155"/>
         <TopLine Value="155"/>
         <CursorPos X="16" Y="53"/>
         <CursorPos X="16" Y="53"/>
-        <UsageCount Value="10"/>
-      </Unit52>
-      <Unit53>
+        <UsageCount Value="7"/>
+      </Unit48>
+      <Unit49>
         <Filename Value="F:\FPCross\fpcsrc\rtl\inc\heaph.inc"/>
         <Filename Value="F:\FPCross\fpcsrc\rtl\inc\heaph.inc"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="79"/>
         <TopLine Value="79"/>
         <CursorPos X="10" Y="102"/>
         <CursorPos X="10" Y="102"/>
-        <UsageCount Value="10"/>
-      </Unit53>
-      <Unit54>
+        <UsageCount Value="7"/>
+      </Unit49>
+      <Unit50>
         <Filename Value="..\SDL2-for-Pascal\units\sdlhints.inc"/>
         <Filename Value="..\SDL2-for-Pascal\units\sdlhints.inc"/>
         <EditorIndex Value="-1"/>
         <EditorIndex Value="-1"/>
         <TopLine Value="2410"/>
         <TopLine Value="2410"/>
         <CursorPos Y="2426"/>
         <CursorPos Y="2426"/>
-        <UsageCount Value="10"/>
-      </Unit54>
+        <UsageCount Value="7"/>
+      </Unit50>
     </Units>
     </Units>
-    <JumpHistory Count="6" HistoryIndex="5">
+    <JumpHistory Count="2" HistoryIndex="1">
       <Position1>
       <Position1>
-        <Filename Value="ImGuiDemo.lpr"/>
-        <Caret Line="226" Column="3" TopLine="202"/>
+        <Filename Value="ImGuiDemo.dpr"/>
+        <Caret Line="273" Column="9" TopLine="254"/>
       </Position1>
       </Position1>
       <Position2>
       <Position2>
-        <Filename Value="ImGuiDemo.lpr"/>
-        <Caret Line="224" Column="3" TopLine="209"/>
+        <Filename Value="ImGuiDemo.dpr"/>
+        <Caret Line="281" Column="22" TopLine="260"/>
       </Position2>
       </Position2>
-      <Position3>
-        <Filename Value="ImGuiDemo.lpr"/>
-        <Caret Line="292" Column="26" TopLine="251"/>
-      </Position3>
-      <Position4>
-        <Filename Value="ImGuiDemo.lpr"/>
-        <Caret Line="262" Column="36" TopLine="251"/>
-      </Position4>
-      <Position5>
-        <Filename Value="ImGuiDemo.lpr"/>
-        <Caret Line="295" Column="6" TopLine="275"/>
-      </Position5>
-      <Position6>
-        <Filename Value="ImGuiDemo.lpr"/>
-        <Caret Line="298" Column="19" TopLine="275"/>
-      </Position6>
     </JumpHistory>
     </JumpHistory>
     <RunParams>
     <RunParams>
       <FormatVersion Value="2"/>
       <FormatVersion Value="2"/>

BIN
demo/ImGuiDemo_Icon.ico


+ 1 - 1
demo/imgui_extra.pas

@@ -1,5 +1,5 @@
 {
 {
-  FreePascal bindings for ImGui
+  FreePascal / Delphi bindings for ImGui
 
 
   Copyright (C) 2023 Coldzer0 <Coldzer0 [at] protonmail.ch>
   Copyright (C) 2023 Coldzer0 <Coldzer0 [at] protonmail.ch>
 
 

+ 22 - 17
demo/testwindow.pas

@@ -1,5 +1,5 @@
 {
 {
-  FreePascal bindings for ImGui
+  FreePascal / Delphi bindings for ImGui
 
 
   Copyright (C) 2023 Coldzer0 <Coldzer0 [at] protonmail.ch>
   Copyright (C) 2023 Coldzer0 <Coldzer0 [at] protonmail.ch>
 
 
@@ -23,7 +23,12 @@
     * a quick guide if something isn't translated in a straightforward way
     * a quick guide if something isn't translated in a straightforward way
 }
 }
 Unit TestWindow;
 Unit TestWindow;
-{$mode objfpc}{$H+}
+
+{$IFDEF FPC}
+  {$mode objfpc}{$H+}
+{$ENDIF}
+
+{$J+}
 
 
 Interface
 Interface
 
 
@@ -70,7 +75,7 @@ Type
 
 
 Implementation
 Implementation
 
 
-Procedure ShowHelpMarker(Const desc: string);
+Procedure ShowHelpMarker(Const desc: AnsiString);
 Begin
 Begin
   ImGui.TextDisabled('(?)');
   ImGui.TextDisabled('(?)');
   If (ImGui.IsItemHovered()) Then
   If (ImGui.IsItemHovered()) Then
@@ -88,7 +93,7 @@ End;
 Procedure TTestWindow.Trees;
 Procedure TTestWindow.Trees;
 Const  //static vars
 Const  //static vars
   align_label_with_current_x_position: boolean = False;
   align_label_with_current_x_position: boolean = False;
-  selection_mask: integer = 1 << 2;
+  selection_mask: integer = 1 shl 2;
   // Dumb representation of what may be user-side selection state. You may carry selection state inside or outside your objects in whatever format you see fit.
   // Dumb representation of what may be user-side selection state. You may carry selection state inside or outside your objects in whatever format you see fit.
 Var
 Var
   node_open: Boolean;
   node_open: Boolean;
@@ -115,8 +120,7 @@ Begin
 
 
   If (ImGui.TreeNode('Advanced, with Selectable nodes')) Then
   If (ImGui.TreeNode('Advanced, with Selectable nodes')) Then
   Begin
   Begin
-    ShowHelpMarker('This is a more standard looking tree with selectable nodes.' +
-      LineEnding +
+    ShowHelpMarker('This is a more standard looking tree with selectable nodes.' + #10 +
       'Click to select, CTRL+Click to toggle, click on arrows or double-click to open.');
       'Click to select, CTRL+Click to toggle, click on arrows or double-click to open.');
     ImGui.Checkbox('Align label with current X position)',
     ImGui.Checkbox('Align label with current X position)',
       @align_label_with_current_x_position);
       @align_label_with_current_x_position);
@@ -133,7 +137,7 @@ Begin
       //ImGuiTreeNodeFlags node_flags := ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ((selection_mask & (1 << i)) ? ImGuiTreeNodeFlags_Selected : 0);
       //ImGuiTreeNodeFlags node_flags := ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ((selection_mask & (1 << i)) ? ImGuiTreeNodeFlags_Selected : 0);
       node_flags := ImGuiTreeNodeFlags_OpenOnArrow Or
       node_flags := ImGuiTreeNodeFlags_OpenOnArrow Or
         ImGuiTreeNodeFlags_OpenOnDoubleClick;
         ImGuiTreeNodeFlags_OpenOnDoubleClick;
-      If (selection_mask And (1 << i)) > 0 Then
+      If (selection_mask And (1 shl i)) > 0 Then
         node_flags := node_flags Or ImGuiTreeNodeFlags_Selected;
         node_flags := node_flags Or ImGuiTreeNodeFlags_Selected;
       If (i < 3) Then
       If (i < 3) Then
       Begin
       Begin
@@ -144,7 +148,7 @@ Begin
           node_clicked := i;
           node_clicked := i;
         If (node_open) Then
         If (node_open) Then
         Begin
         Begin
-          ImGui.Text('Blah blah' + LineEnding + 'Blah Blah');
+          ImGui.Text('Blah blah' + #10 + 'Blah Blah');
           ImGui.TreePop();
           ImGui.TreePop();
         End;
         End;
       End
       End
@@ -162,11 +166,10 @@ Begin
     Begin
     Begin
       // Update selection state. Process outside of tree loop to avoid visual inconsistencies during the clicking-frame.
       // Update selection state. Process outside of tree loop to avoid visual inconsistencies during the clicking-frame.
       If (ImGui.GetIO()^.KeyCtrl) Then
       If (ImGui.GetIO()^.KeyCtrl) Then
-        selection_mask :=
-          selection_mask Xor (1 << node_clicked)          // CTRL+click to toggle
+        selection_mask := selection_mask Xor (1 shl node_clicked)          // CTRL+click to toggle
       Else
       Else
         //if (!(selection_mask & (1 << node_clicked))) // Depending on selection behavior you want, this commented bit preserve selection when clicking on item that is part of the selection
         //if (!(selection_mask & (1 << node_clicked))) // Depending on selection behavior you want, this commented bit preserve selection when clicking on item that is part of the selection
-        selection_mask := (1 << node_clicked);           // Click to single-select
+        selection_mask := (1 shl node_clicked);           // Click to single-select
     End;
     End;
     ImGui.PopStyleVar();
     ImGui.PopStyleVar();
     If (align_label_with_current_x_position) Then
     If (align_label_with_current_x_position) Then
@@ -205,10 +208,11 @@ End;
 Procedure TTestWindow.Show(Var p_open: boolean);
 Procedure TTestWindow.Show(Var p_open: boolean);
 Var
 Var
   io: PImGuiIO;
   io: PImGuiIO;
-  window_flags: ImGuiWindowFlags = ImGuiWindowFlags_None;
+  window_flags: ImGuiWindowFlags;
   draw_list: PImDrawList;
   draw_list: PImDrawList;
   value_raw, value_with_lock_threshold, mouse_delta: ImVec2;
   value_raw, value_with_lock_threshold, mouse_delta: ImVec2;
 Begin
 Begin
+  window_flags := ImGuiWindowFlags_None;
   // Demonstrate the various window flags. Typically you would just use the default.
   // Demonstrate the various window flags. Typically you would just use the default.
   If (no_titlebar) Then window_flags := window_flags Or ImGuiWindowFlags_NoTitleBar;
   If (no_titlebar) Then window_flags := window_flags Or ImGuiWindowFlags_NoTitleBar;
   If (no_resize) Then window_flags := window_flags Or ImGuiWindowFlags_NoResize;
   If (no_resize) Then window_flags := window_flags Or ImGuiWindowFlags_NoResize;
@@ -216,8 +220,9 @@ Begin
   If (no_scrollbar) Then window_flags := window_flags Or ImGuiWindowFlags_NoScrollbar;
   If (no_scrollbar) Then window_flags := window_flags Or ImGuiWindowFlags_NoScrollbar;
   If (no_collapse) Then window_flags := window_flags Or ImGuiWindowFlags_NoCollapse;
   If (no_collapse) Then window_flags := window_flags Or ImGuiWindowFlags_NoCollapse;
   If (Not no_menu) Then window_flags := window_flags Or ImGuiWindowFlags_MenuBar;
   If (Not no_menu) Then window_flags := window_flags Or ImGuiWindowFlags_MenuBar;
+
   ImGui.SetNextWindowSize(ImVec2.New(550, 680), ImGuiCond_FirstUseEver);
   ImGui.SetNextWindowSize(ImVec2.New(550, 680), ImGuiCond_FirstUseEver);
-  If Not ImGui.Begin_('ImGui Demo (FreePascal version)', @p_open, window_flags) Then
+  If Not ImGui.Begin_('ImGui Demo (FreePascal / Delphi version)', @p_open, window_flags) Then
   Begin
   Begin
     // Early out if the window is collapsed, as an optimization.
     // Early out if the window is collapsed, as an optimization.
     ImGui.End_;
     ImGui.End_;
@@ -271,8 +276,8 @@ Begin
   Begin
   Begin
     ImGui.TextWrapped(
     ImGui.TextWrapped(
       'This window is being created by the ShowTestWindow() function. Please refer to the code for programming reference.'
       'This window is being created by the ShowTestWindow() function. Please refer to the code for programming reference.'
-      +
-      LineEnding + LineEnding + 'User Guide:');
+      + #10#10 +
+      'User Guide:');
     ImGui.ShowUserGuide();
     ImGui.ShowUserGuide();
   End;
   End;
 
 
@@ -324,7 +329,7 @@ Begin
         draw_list := ImGui.GetWindowDrawList();
         draw_list := ImGui.GetWindowDrawList();
         draw_list^.PushClipRectFullScreen;
         draw_list^.PushClipRectFullScreen;
         draw_list^.AddLine(io^.MouseClickedPos[0], io^.MousePos,
         draw_list^.AddLine(io^.MouseClickedPos[0], io^.MousePos,
-          ImGui.GetColorU32Vec(ImGui.GetStyle()^.Colors[Ord(ImGuiCol_Button)]),
+          ImGui.GetColorU32Vec(ImGui.GetStyle()^.Colors[Ord(ImGuiCol_DragDropTarget)]),
           4.0);
           4.0);
         draw_list^.PopClipRect;
         draw_list^.PopClipRect;
 
 
@@ -332,7 +337,7 @@ Begin
         value_with_lock_threshold := ImGui.GetMouseDragDelta(ImGuiMouseButton_Left);
         value_with_lock_threshold := ImGui.GetMouseDragDelta(ImGuiMouseButton_Left);
         mouse_delta := ImGui.GetIO()^.MouseDelta;
         mouse_delta := ImGui.GetIO()^.MouseDelta;
         ImGui.SameLine();
         ImGui.SameLine();
-        ImGui.Text(
+        ImGui.TextWrapped(
           'Raw (%.1f, %.1f), WithLockThresold (%.1f, %.1f), MouseDelta (%.1f, %.1f)',
           'Raw (%.1f, %.1f), WithLockThresold (%.1f, %.1f), MouseDelta (%.1f, %.1f)',
           [value_raw.x, value_raw.y, value_with_lock_threshold.x,
           [value_raw.x, value_raw.y, value_with_lock_threshold.x,
           value_with_lock_threshold.y, mouse_delta.x, mouse_delta.y]);
           value_with_lock_threshold.y, mouse_delta.x, mouse_delta.y]);