17#ifdef IMGUI_IMPL_OPENGL_LOADER_GL3W
19 #define GL_SILENCE_DEPRECATION
20 #include <OpenGL/gl.h>
24 #define STB_IMAGE_WRITE_IMPLEMENTATION
25 #include "stb_image_write.h"
31 if (std::filesystem::path inputPath{ path };
32 inputPath.is_relative())
34 filepath /= inputPath;
40 std::ifstream filestream(filepath);
42 if (!filestream.good())
44 LOG_ERROR(
"The ImPlot style config file could not be loaded: {}", filepath.string());
51 if (j.contains(
"implot") && j.at(
"implot").contains(
"style"))
53 j.at(
"implot").at(
"style").get_to(imPlotStyle);
54 LOG_DEBUG(
"Loaded ImPlot style from file {}", path);
59#ifdef IMGUI_IMPL_OPENGL_LOADER_GL3W
61NAV::ImGuiScreenshotImageBuf::ImGuiScreenshotImageBuf(
int x,
int y,
size_t w,
size_t h)
62 : Width(w), Height(h), Data(Width * Height * 4, 0)
64 glPixelStorei(GL_PACK_ALIGNMENT, 1);
65 glReadPixels(x, y,
static_cast<int>(w),
static_cast<int>(h), GL_RGBA, GL_UNSIGNED_BYTE, Data.data());
70void NAV::ImGuiScreenshotImageBuf::SaveFile(
const char* filename)
72 stbi_write_png(filename,
static_cast<int>(Width),
73 static_cast<int>(Height),
76 static_cast<int>(Width * 4));
79void NAV::ImGuiScreenshotImageBuf::RemoveAlpha()
81 uint32_t* p = Data.data();
82 auto n =
static_cast<int>(Width * Height);
90void NAV::ImGuiScreenshotImageBuf::FlipVertical()
93 size_t stride = Width * comp;
94 std::vector<unsigned char> line_tmp(stride);
95 auto* line_a =
reinterpret_cast<unsigned char*
>(Data.data());
96 auto* line_b =
reinterpret_cast<unsigned char*
>(Data.data()) + (stride * (Height - 1));
97 while (line_a < line_b)
99 memcpy(line_tmp.data(), line_a, stride);
100 memcpy(line_a, line_b, stride);
101 memcpy(line_b, line_tmp.data(), stride);
nlohmann::json json
json namespace
Defines how to save certain datatypes to json.
Utility class for logging to console and file.
#define LOG_DEBUG
Debug information. Should not be called on functions which receive observations (spamming)
#define LOG_ERROR
Error occurred, which stops part of the program to work, but not everything.
std::filesystem::path GetConfigPath()
Get the path where config files are searched.
void loadImPlotStyleFromConfigFile(const char *path, ImPlotStyle &imPlotStyle)
Loads the ImPlotStyle from a json file.