a little lcean up
This commit is contained in:
74
main.cpp
74
main.cpp
@ -1,14 +1,3 @@
|
||||
// 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_scancode.h>
|
||||
#include <cstddef>
|
||||
@ -106,43 +95,33 @@ Texture ReloadTexture(ImTextureID id, int width, int height) {
|
||||
return t;
|
||||
}
|
||||
|
||||
void rotate90()
|
||||
{
|
||||
}
|
||||
|
||||
void RotateImage(Texture t) {
|
||||
int height = t.size.y;
|
||||
int width = t.size.x;
|
||||
int channels = t.channels;
|
||||
|
||||
const unsigned int sizeBuffer = width * height * channels;
|
||||
unsigned char *tempBuffer = new unsigned char[sizeBuffer];
|
||||
const unsigned int sizeBuffer = width * height * channels;
|
||||
unsigned char *tempBuffer = new unsigned char[sizeBuffer];
|
||||
|
||||
|
||||
int nidx = 0;
|
||||
for (int x = 0; x < width; x++)
|
||||
int nidx = 0;
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
for (int y = height - 1; y >= 0; y--)
|
||||
{
|
||||
for (int y = height - 1; y >= 0; y--)
|
||||
{
|
||||
int idx = (x + y * width) * channels;
|
||||
for (int i = 0; i < channels; i++)
|
||||
tempBuffer[nidx + i] = image[idx + i];
|
||||
int idx = (x + y * width) * channels;
|
||||
for (int i = 0; i < channels; i++)
|
||||
tempBuffer[nidx + i] = image[idx + i];
|
||||
|
||||
nidx = nidx + 4;
|
||||
}
|
||||
nidx = nidx + 4;
|
||||
}
|
||||
}
|
||||
|
||||
// Copy rotated pixels
|
||||
|
||||
memcpy(image, tempBuffer, sizeBuffer);
|
||||
delete[] tempBuffer;
|
||||
memcpy(image, tempBuffer, sizeBuffer);
|
||||
delete[] tempBuffer;
|
||||
}
|
||||
|
||||
|
||||
static bool init = true;
|
||||
static bool showHelp = false;
|
||||
static int mode = 0;
|
||||
const int maxAnnotatedTexels = 10000;
|
||||
const int MAX_ANNOATED_TEXELS = 10000;
|
||||
|
||||
// Main code
|
||||
int main(int argc, char* argv[]) {
|
||||
@ -156,6 +135,8 @@ int main(int argc, char* argv[]) {
|
||||
bool TOOLTIP_ENABLED = false;
|
||||
bool GRID_ENABLED = false;
|
||||
bool AA_ENABLED = true;
|
||||
bool SHOW_HELP = false;
|
||||
int MODE = 0;
|
||||
|
||||
// Decide GL+GLSL versions
|
||||
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||
@ -209,7 +190,6 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
// Setup Dear ImGui context
|
||||
IMGUI_CHECKVERSION();
|
||||
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
(void)io;
|
||||
@ -218,34 +198,27 @@ int main(int argc, char* argv[]) {
|
||||
ImGuiTexInspect::ImplOpenGL3_Init(); // Or DirectX 11 equivalent (check your chosen backend header file)
|
||||
ImGuiTexInspect::Init();
|
||||
ImGuiTexInspect::CreateContext();
|
||||
|
||||
ImGui::StyleColorsDark();
|
||||
|
||||
ImGuiStyle &style = ImGui::GetStyle();
|
||||
|
||||
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
|
||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||
|
||||
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||
|
||||
Texture t;
|
||||
auto flags = ImGuiTexInspect::InspectorFlags_FillVertical | ImGuiTexInspect::InspectorFlags_FillHorizontal;
|
||||
|
||||
if (init) {
|
||||
init = false;
|
||||
try {
|
||||
auto args = argparse::parse<Args>(argc, argv, true);
|
||||
t = LoadTexture(args.fpath.c_str());
|
||||
} catch (const std::runtime_error &e) {
|
||||
std::cerr << "failed to parse arguments: " << e.what() << std::endl;
|
||||
return -1;
|
||||
}
|
||||
try {
|
||||
auto args = argparse::parse<Args>(argc, argv, true);
|
||||
t = LoadTexture(args.fpath.c_str());
|
||||
} catch (const std::runtime_error &e) {
|
||||
std::cerr << "failed to parse arguments: " << e.what() << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Main loop
|
||||
bool done = false;
|
||||
while (!done)
|
||||
{
|
||||
auto flags = ImGuiTexInspect::InspectorFlags_FillVertical | ImGuiTexInspect::InspectorFlags_FillHorizontal;
|
||||
|
||||
// Poll and handle events (inputs, window resize, etc.)
|
||||
SDL_Event event;
|
||||
@ -373,6 +346,7 @@ int main(int argc, char* argv[]) {
|
||||
ImGui::OpenPopup("HelpPopup");
|
||||
showHelp = !showHelp;
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopup("HelpPopup")) {
|
||||
ImGui::Text("tview Help");
|
||||
ImGui::Separator();
|
||||
|
Reference in New Issue
Block a user