diff --git a/ClickableTransparentOverlay/ClickableTransparentOverlay.csproj b/ClickableTransparentOverlay/ClickableTransparentOverlay.csproj
index 025a664..7db8ec1 100644
--- a/ClickableTransparentOverlay/ClickableTransparentOverlay.csproj
+++ b/ClickableTransparentOverlay/ClickableTransparentOverlay.csproj
@@ -105,6 +105,9 @@
..\packages\Veldrid.4.6.1\lib\netstandard2.0\Veldrid.dll
+
+ ..\packages\Veldrid.ImageSharp.4.6.1\lib\netstandard2.0\Veldrid.ImageSharp.dll
+
..\packages\Veldrid.SDL2.4.6.1\lib\netstandard2.0\Veldrid.SDL2.dll
diff --git a/ClickableTransparentOverlay/Overlay.cs b/ClickableTransparentOverlay/Overlay.cs
index bd0f652..24a787c 100644
--- a/ClickableTransparentOverlay/Overlay.cs
+++ b/ClickableTransparentOverlay/Overlay.cs
@@ -5,10 +5,12 @@
namespace ClickableTransparentOverlay
{
using System;
+ using System.Collections.Generic;
using System.Numerics;
using System.Threading;
using System.Windows.Forms;
using Veldrid;
+ using Veldrid.ImageSharp;
using Veldrid.Sdl2;
using Veldrid.StartupUtilities;
@@ -28,6 +30,7 @@ namespace ClickableTransparentOverlay
private static Vector4 clearColor;
private static int myFps;
private static bool isClosed;
+ private static Dictionary loadedImages;
// For Resizing SDL2Window
private static Vector2 futurePos;
@@ -58,6 +61,7 @@ namespace ClickableTransparentOverlay
///
public Overlay(int x, int y, int width, int height, int fps, bool debug)
{
+ loadedImages = new Dictionary();
clearColor = new Vector4(0.00f, 0.00f, 0.00f, 0.00f);
myFps = fps;
isClosed = false;
@@ -188,10 +192,37 @@ namespace ClickableTransparentOverlay
hookController.Dispose();
NativeMethods.ShowConsoleWindow();
this.SubmitUI = null;
+ loadedImages.Clear();
Console.WriteLine("All Overlay resources are cleared.");
Application.Exit();
}
+ ///
+ /// Adds the image to the Graphic Device as a texture.
+ /// Then returns the pointer of the added texture. It also
+ /// cache the image internally rather than creating a new texture on every call,
+ /// so this function can be called multiple times per image (per FPS).
+ ///
+ ///
+ /// Path to the image on disk. If the image is loaded in the memory
+ /// save it on the disk before sending to this function. Reason for this
+ /// is to cache the Image Texture using filePath as the key.
+ ///
+ ///
+ /// A pointer to the Texture in the Graphic Device.
+ ///
+ public IntPtr AddOrGetImagePointer(string filePath)
+ {
+ if (!loadedImages.TryGetValue(filePath, out Texture texture))
+ {
+ ImageSharpTexture imgSharpTexture = new ImageSharpTexture(filePath);
+ texture = imgSharpTexture.CreateDeviceTexture(graphicsDevice, graphicsDevice.ResourceFactory);
+ loadedImages.Add(filePath, texture);
+ }
+
+ return imController.GetOrCreateImGuiBinding(graphicsDevice.ResourceFactory, texture);
+ }
+
///
/// Infinite While Loop to render the ImGui.
///
diff --git a/ClickableTransparentOverlay/packages.config b/ClickableTransparentOverlay/packages.config
index 406325c..411b16e 100644
--- a/ClickableTransparentOverlay/packages.config
+++ b/ClickableTransparentOverlay/packages.config
@@ -14,6 +14,7 @@
+
\ No newline at end of file
diff --git a/DriverProgram/DriverProgram.csproj b/DriverProgram/DriverProgram.csproj
index f26e259..5aacd91 100644
--- a/DriverProgram/DriverProgram.csproj
+++ b/DriverProgram/DriverProgram.csproj
@@ -76,6 +76,10 @@
..\packages\ImGui.NET.1.70.0\lib\netstandard2.0\ImGui.NET.dll
+
+
+ ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll
+
diff --git a/DriverProgram/Program.cs b/DriverProgram/Program.cs
index 04527f2..f719c58 100644
--- a/DriverProgram/Program.cs
+++ b/DriverProgram/Program.cs
@@ -2,6 +2,8 @@
{
using ClickableTransparentOverlay;
using ImGuiNET;
+ using System.IO;
+ using System.Numerics;
using System.Threading;
class Program
@@ -64,6 +66,16 @@
showImGuiDemo = true;
}
+ ImGui.NewLine();
+ if (File.Exists("image.png"))
+ {
+ ImGui.Image(overlay.AddOrGetImagePointer("image.png"), new Vector2(600, 400));
+ }
+ else
+ {
+ ImGui.Text("Put any image where the exe is, name is 'image.png'");
+ }
+
ImGui.End();
}
diff --git a/DriverProgram/packages.config b/DriverProgram/packages.config
index 8bf74f3..da3f762 100644
--- a/DriverProgram/packages.config
+++ b/DriverProgram/packages.config
@@ -1,4 +1,5 @@
+
\ No newline at end of file