Compare commits
No commits in common. "2ea4211c4b13b0db7ffe0f871c3816dbee48bf83" and "515c3028ccc0bc96d8192ccfa634b295071d638c" have entirely different histories.
2ea4211c4b
...
515c3028cc
35
lib/uuid.cpp
Normal file
35
lib/uuid.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#include "uuid.h"
|
||||||
|
|
||||||
|
namespace uuid {
|
||||||
|
static std::random_device rd;
|
||||||
|
static std::mt19937 gen(rd());
|
||||||
|
static std::uniform_int_distribution<> dis(0, 15);
|
||||||
|
static std::uniform_int_distribution<> dis2(8, 11);
|
||||||
|
|
||||||
|
std::string generate_uuid_v4() {
|
||||||
|
std::stringstream ss;
|
||||||
|
int i;
|
||||||
|
ss << std::hex;
|
||||||
|
for (i = 0; i < 8; i++) {
|
||||||
|
ss << dis(gen);
|
||||||
|
}
|
||||||
|
ss << "-";
|
||||||
|
for (i = 0; i < 4; i++) {
|
||||||
|
ss << dis(gen);
|
||||||
|
}
|
||||||
|
ss << "-4";
|
||||||
|
for (i = 0; i < 3; i++) {
|
||||||
|
ss << dis(gen);
|
||||||
|
}
|
||||||
|
ss << "-";
|
||||||
|
ss << dis2(gen);
|
||||||
|
for (i = 0; i < 3; i++) {
|
||||||
|
ss << dis(gen);
|
||||||
|
}
|
||||||
|
ss << "-";
|
||||||
|
for (i = 0; i < 12; i++) {
|
||||||
|
ss << dis(gen);
|
||||||
|
};
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
} // namespace uuid
|
12
lib/uuid.h
Normal file
12
lib/uuid.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef UUID_H
|
||||||
|
#define UUID_H
|
||||||
|
|
||||||
|
#include <random>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace uuid {
|
||||||
|
std::string generate_uuid_v4();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // UUID_H
|
56
main.cpp
56
main.cpp
@ -1,3 +1,14 @@
|
|||||||
|
// Dear ImGui: standalone example application for SDL2 + OpenGL
|
||||||
|
// (SDL is a cross-platform general purpose library for handling windows,
|
||||||
|
// inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
||||||
|
|
||||||
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/
|
||||||
|
// folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#include <SDL2/SDL_events.h>
|
#include <SDL2/SDL_events.h>
|
||||||
#include <SDL2/SDL_scancode.h>
|
#include <SDL2/SDL_scancode.h>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
@ -95,6 +106,10 @@ Texture ReloadTexture(ImTextureID id, int width, int height) {
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rotate90()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void RotateImage(Texture t) {
|
void RotateImage(Texture t) {
|
||||||
int height = t.size.y;
|
int height = t.size.y;
|
||||||
int width = t.size.x;
|
int width = t.size.x;
|
||||||
@ -103,6 +118,7 @@ void RotateImage(Texture t) {
|
|||||||
const unsigned int sizeBuffer = width * height * channels;
|
const unsigned int sizeBuffer = width * height * channels;
|
||||||
unsigned char *tempBuffer = new unsigned char[sizeBuffer];
|
unsigned char *tempBuffer = new unsigned char[sizeBuffer];
|
||||||
|
|
||||||
|
|
||||||
int nidx = 0;
|
int nidx = 0;
|
||||||
for (int x = 0; x < width; x++)
|
for (int x = 0; x < width; x++)
|
||||||
{
|
{
|
||||||
@ -116,12 +132,17 @@ void RotateImage(Texture t) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy rotated pixels
|
||||||
|
|
||||||
memcpy(image, tempBuffer, sizeBuffer);
|
memcpy(image, tempBuffer, sizeBuffer);
|
||||||
delete[] tempBuffer;
|
delete[] tempBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const int MAX_ANNOATED_TEXELS = 10000;
|
static bool init = true;
|
||||||
|
static bool showHelp = false;
|
||||||
|
static int mode = 0;
|
||||||
|
const int maxAnnotatedTexels = 10000;
|
||||||
|
|
||||||
// Main code
|
// Main code
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
@ -135,8 +156,6 @@ int main(int argc, char* argv[]) {
|
|||||||
bool TOOLTIP_ENABLED = false;
|
bool TOOLTIP_ENABLED = false;
|
||||||
bool GRID_ENABLED = false;
|
bool GRID_ENABLED = false;
|
||||||
bool AA_ENABLED = true;
|
bool AA_ENABLED = true;
|
||||||
bool SHOW_HELP = false;
|
|
||||||
int MODE = 0;
|
|
||||||
|
|
||||||
// Decide GL+GLSL versions
|
// Decide GL+GLSL versions
|
||||||
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||||
@ -190,6 +209,7 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
// Setup Dear ImGui context
|
// Setup Dear ImGui context
|
||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
|
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO &io = ImGui::GetIO();
|
ImGuiIO &io = ImGui::GetIO();
|
||||||
(void)io;
|
(void)io;
|
||||||
@ -198,15 +218,20 @@ int main(int argc, char* argv[]) {
|
|||||||
ImGuiTexInspect::ImplOpenGL3_Init(); // Or DirectX 11 equivalent (check your chosen backend header file)
|
ImGuiTexInspect::ImplOpenGL3_Init(); // Or DirectX 11 equivalent (check your chosen backend header file)
|
||||||
ImGuiTexInspect::Init();
|
ImGuiTexInspect::Init();
|
||||||
ImGuiTexInspect::CreateContext();
|
ImGuiTexInspect::CreateContext();
|
||||||
|
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
|
|
||||||
ImGuiStyle &style = ImGui::GetStyle();
|
ImGuiStyle &style = ImGui::GetStyle();
|
||||||
|
|
||||||
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
|
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
|
||||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||||
|
|
||||||
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
Texture t;
|
|
||||||
auto flags = ImGuiTexInspect::InspectorFlags_FillVertical | ImGuiTexInspect::InspectorFlags_FillHorizontal;
|
|
||||||
|
|
||||||
|
Texture t;
|
||||||
|
|
||||||
|
if (init) {
|
||||||
|
init = false;
|
||||||
try {
|
try {
|
||||||
auto args = argparse::parse<Args>(argc, argv, true);
|
auto args = argparse::parse<Args>(argc, argv, true);
|
||||||
t = LoadTexture(args.fpath.c_str());
|
t = LoadTexture(args.fpath.c_str());
|
||||||
@ -214,11 +239,13 @@ int main(int argc, char* argv[]) {
|
|||||||
std::cerr << "failed to parse arguments: " << e.what() << std::endl;
|
std::cerr << "failed to parse arguments: " << e.what() << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
bool done = false;
|
bool done = false;
|
||||||
while (!done)
|
while (!done)
|
||||||
{
|
{
|
||||||
|
auto flags = ImGuiTexInspect::InspectorFlags_FillVertical | ImGuiTexInspect::InspectorFlags_FillHorizontal;
|
||||||
|
|
||||||
// Poll and handle events (inputs, window resize, etc.)
|
// Poll and handle events (inputs, window resize, etc.)
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
@ -245,10 +272,10 @@ int main(int argc, char* argv[]) {
|
|||||||
AA_ENABLED = !AA_ENABLED;
|
AA_ENABLED = !AA_ENABLED;
|
||||||
break;
|
break;
|
||||||
case SDL_SCANCODE_H:
|
case SDL_SCANCODE_H:
|
||||||
SHOW_HELP = !SHOW_HELP;
|
showHelp = !showHelp;
|
||||||
break;
|
break;
|
||||||
case SDL_SCANCODE_D:
|
case SDL_SCANCODE_D:
|
||||||
MODE = (MODE + 1) % 5;
|
mode = (mode + 1) % 5;
|
||||||
break;
|
break;
|
||||||
case SDL_SCANCODE_R:
|
case SDL_SCANCODE_R:
|
||||||
RotateImage(t);
|
RotateImage(t);
|
||||||
@ -318,18 +345,18 @@ int main(int argc, char* argv[]) {
|
|||||||
CurrentInspector_SetFlags(ImGuiTexInspect::InspectorFlags_NoForceFilterNearest);
|
CurrentInspector_SetFlags(ImGuiTexInspect::InspectorFlags_NoForceFilterNearest);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(MODE) {
|
switch(mode) {
|
||||||
case 1:
|
case 1:
|
||||||
ImGuiTexInspect::DrawAnnotations(ImGuiTexInspect::Arrow().UsePreset(ImGuiTexInspect::Arrow::NormalMap), MAX_ANNOATED_TEXELS);
|
ImGuiTexInspect::DrawAnnotations(ImGuiTexInspect::Arrow().UsePreset(ImGuiTexInspect::Arrow::NormalMap), maxAnnotatedTexels);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
ImGuiTexInspect::DrawAnnotations(ImGuiTexInspect::ValueText(ImGuiTexInspect::ValueText::Format::HexString), MAX_ANNOATED_TEXELS);
|
ImGuiTexInspect::DrawAnnotations(ImGuiTexInspect::ValueText(ImGuiTexInspect::ValueText::Format::HexString), maxAnnotatedTexels);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
ImGuiTexInspect::DrawAnnotations(ImGuiTexInspect::ValueText(ImGuiTexInspect::ValueText::Format::BytesDec), MAX_ANNOATED_TEXELS);
|
ImGuiTexInspect::DrawAnnotations(ImGuiTexInspect::ValueText(ImGuiTexInspect::ValueText::Format::BytesDec), maxAnnotatedTexels);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
ImGuiTexInspect::DrawAnnotations(ImGuiTexInspect::ValueText(ImGuiTexInspect::ValueText::Format::Floats), MAX_ANNOATED_TEXELS);
|
ImGuiTexInspect::DrawAnnotations(ImGuiTexInspect::ValueText(ImGuiTexInspect::ValueText::Format::Floats), maxAnnotatedTexels);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -342,11 +369,10 @@ int main(int argc, char* argv[]) {
|
|||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
|
|
||||||
if (SHOW_HELP){
|
if (showHelp){
|
||||||
ImGui::OpenPopup("HelpPopup");
|
ImGui::OpenPopup("HelpPopup");
|
||||||
SHOW_HELP = !SHOW_HELP;
|
showHelp = !showHelp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::BeginPopup("HelpPopup")) {
|
if (ImGui::BeginPopup("HelpPopup")) {
|
||||||
ImGui::Text("tview Help");
|
ImGui::Text("tview Help");
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user