|
@@ -49,6 +49,8 @@ static Texture2D FontTexture;
|
|
static ImGuiMouseCursor CurrentMouseCursor = ImGuiMouseCursor_COUNT;
|
|
static ImGuiMouseCursor CurrentMouseCursor = ImGuiMouseCursor_COUNT;
|
|
static MouseCursor MouseCursorMap[ImGuiMouseCursor_COUNT];
|
|
static MouseCursor MouseCursorMap[ImGuiMouseCursor_COUNT];
|
|
|
|
|
|
|
|
+ImGuiContext* GlobalContext = nullptr;
|
|
|
|
+
|
|
static std::map<KeyboardKey, ImGuiKey> RaylibKeyMap;
|
|
static std::map<KeyboardKey, ImGuiKey> RaylibKeyMap;
|
|
|
|
|
|
static bool LastFrameFocused = false;
|
|
static bool LastFrameFocused = false;
|
|
@@ -187,9 +189,6 @@ static void rlImGuiEvents()
|
|
keyId = GetKeyPressed();
|
|
keyId = GetKeyPressed();
|
|
}
|
|
}
|
|
|
|
|
|
- for (auto keyItr : RaylibKeyMap)
|
|
|
|
- io.KeysData[keyItr.second].Down = IsKeyDown(keyItr.first);
|
|
|
|
-
|
|
|
|
// look for any keys that were down last frame and see if they were down and are released
|
|
// look for any keys that were down last frame and see if they were down and are released
|
|
for (const auto keyItr : RaylibKeyMap)
|
|
for (const auto keyItr : RaylibKeyMap)
|
|
{
|
|
{
|
|
@@ -304,6 +303,8 @@ void SetupMouseCursors()
|
|
|
|
|
|
void rlImGuiEndInitImGui()
|
|
void rlImGuiEndInitImGui()
|
|
{
|
|
{
|
|
|
|
+ ImGui::SetCurrentContext(GlobalContext);
|
|
|
|
+
|
|
SetupMouseCursors();
|
|
SetupMouseCursors();
|
|
|
|
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
@@ -436,8 +437,8 @@ void rlSetupKeymap()
|
|
|
|
|
|
void rlImGuiBeginInitImGui()
|
|
void rlImGuiBeginInitImGui()
|
|
{
|
|
{
|
|
|
|
+ GlobalContext = ImGui::CreateContext(nullptr);
|
|
rlSetupKeymap();
|
|
rlSetupKeymap();
|
|
- ImGui::CreateContext(nullptr);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void rlImGuiSetup(bool dark)
|
|
void rlImGuiSetup(bool dark)
|
|
@@ -474,6 +475,8 @@ void rlImGuiSetup(bool dark)
|
|
|
|
|
|
void rlImGuiReloadFonts()
|
|
void rlImGuiReloadFonts()
|
|
{
|
|
{
|
|
|
|
+ ImGui::SetCurrentContext(GlobalContext);
|
|
|
|
+
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
unsigned char* pixels = nullptr;
|
|
unsigned char* pixels = nullptr;
|
|
|
|
|
|
@@ -498,6 +501,7 @@ void rlImGuiBegin()
|
|
|
|
|
|
void rlImGuiBeginDelta(float deltaTime)
|
|
void rlImGuiBeginDelta(float deltaTime)
|
|
{
|
|
{
|
|
|
|
+ ImGui::SetCurrentContext(GlobalContext);
|
|
rlImGuiNewFrame(deltaTime);
|
|
rlImGuiNewFrame(deltaTime);
|
|
rlImGuiEvents();
|
|
rlImGuiEvents();
|
|
ImGui::NewFrame();
|
|
ImGui::NewFrame();
|
|
@@ -505,6 +509,7 @@ void rlImGuiBeginDelta(float deltaTime)
|
|
|
|
|
|
void rlImGuiEnd()
|
|
void rlImGuiEnd()
|
|
{
|
|
{
|
|
|
|
+ ImGui::SetCurrentContext(GlobalContext);
|
|
ImGui::Render();
|
|
ImGui::Render();
|
|
rlRenderData(ImGui::GetDrawData());
|
|
rlRenderData(ImGui::GetDrawData());
|
|
}
|
|
}
|
|
@@ -513,6 +518,7 @@ void rlImGuiShutdown()
|
|
{
|
|
{
|
|
UnloadTexture(FontTexture);
|
|
UnloadTexture(FontTexture);
|
|
|
|
|
|
|
|
+ ImGui::SetCurrentContext(GlobalContext);
|
|
ImGui::DestroyContext();
|
|
ImGui::DestroyContext();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -520,7 +526,7 @@ void rlImGuiImage(const Texture* image)
|
|
{
|
|
{
|
|
if (!image)
|
|
if (!image)
|
|
return;
|
|
return;
|
|
-
|
|
|
|
|
|
+ ImGui::SetCurrentContext(GlobalContext);
|
|
ImGui::Image((ImTextureID)image, ImVec2(float(image->width), float(image->height)));
|
|
ImGui::Image((ImTextureID)image, ImVec2(float(image->width), float(image->height)));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -528,7 +534,7 @@ bool rlImGuiImageButton(const char* name, const Texture* image)
|
|
{
|
|
{
|
|
if (!image)
|
|
if (!image)
|
|
return false;
|
|
return false;
|
|
-
|
|
|
|
|
|
+ ImGui::SetCurrentContext(GlobalContext);
|
|
return ImGui::ImageButton(name, (ImTextureID)image, ImVec2(float(image->width), float(image->height)));
|
|
return ImGui::ImageButton(name, (ImTextureID)image, ImVec2(float(image->width), float(image->height)));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -536,7 +542,7 @@ bool rlImGuiImageButtonSize(const char* name, const Texture* image, ImVec2 size)
|
|
{
|
|
{
|
|
if (!image)
|
|
if (!image)
|
|
return false;
|
|
return false;
|
|
-
|
|
|
|
|
|
+ ImGui::SetCurrentContext(GlobalContext);
|
|
return ImGui::ImageButton(name, (ImTextureID)image, size);
|
|
return ImGui::ImageButton(name, (ImTextureID)image, size);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -544,7 +550,7 @@ void rlImGuiImageSize(const Texture* image, int width, int height)
|
|
{
|
|
{
|
|
if (!image)
|
|
if (!image)
|
|
return;
|
|
return;
|
|
-
|
|
|
|
|
|
+ ImGui::SetCurrentContext(GlobalContext);
|
|
ImGui::Image((ImTextureID)image, ImVec2(float(width), float(height)));
|
|
ImGui::Image((ImTextureID)image, ImVec2(float(width), float(height)));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -552,7 +558,7 @@ void rlImGuiImageSizeV(const Texture* image, Vector2 size)
|
|
{
|
|
{
|
|
if (!image)
|
|
if (!image)
|
|
return;
|
|
return;
|
|
-
|
|
|
|
|
|
+ ImGui::SetCurrentContext(GlobalContext);
|
|
ImGui::Image((ImTextureID)image, ImVec2(size.x, size.y));
|
|
ImGui::Image((ImTextureID)image, ImVec2(size.x, size.y));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -560,7 +566,7 @@ void rlImGuiImageRect(const Texture* image, int destWidth, int destHeight, Recta
|
|
{
|
|
{
|
|
if (!image)
|
|
if (!image)
|
|
return;
|
|
return;
|
|
-
|
|
|
|
|
|
+ ImGui::SetCurrentContext(GlobalContext);
|
|
ImVec2 uv0;
|
|
ImVec2 uv0;
|
|
ImVec2 uv1;
|
|
ImVec2 uv1;
|
|
|
|
|
|
@@ -593,7 +599,7 @@ void rlImGuiImageRenderTexture(const RenderTexture* image)
|
|
{
|
|
{
|
|
if (!image)
|
|
if (!image)
|
|
return;
|
|
return;
|
|
-
|
|
|
|
|
|
+ ImGui::SetCurrentContext(GlobalContext);
|
|
rlImGuiImageRect(&image->texture, image->texture.width, image->texture.height, Rectangle{ 0,0, float(image->texture.width), -float(image->texture.height) });
|
|
rlImGuiImageRect(&image->texture, image->texture.width, image->texture.height, Rectangle{ 0,0, float(image->texture.width), -float(image->texture.height) });
|
|
}
|
|
}
|
|
|
|
|
|
@@ -601,7 +607,7 @@ void rlImGuiImageRenderTextureFit(const RenderTexture* image, bool center)
|
|
{
|
|
{
|
|
if (!image)
|
|
if (!image)
|
|
return;
|
|
return;
|
|
-
|
|
|
|
|
|
+ ImGui::SetCurrentContext(GlobalContext);
|
|
ImVec2 area = ImGui::GetContentRegionAvail();
|
|
ImVec2 area = ImGui::GetContentRegionAvail();
|
|
|
|
|
|
float scale = area.x / image->texture.width;
|
|
float scale = area.x / image->texture.width;
|