begin cleanup from other project

This commit is contained in:
2024-06-12 09:20:04 -04:00
commit 9e47fdd28e
43 changed files with 80623 additions and 0 deletions

47
lib/image_model.h Normal file
View File

@ -0,0 +1,47 @@
#include "imgui.h"
#include <sstream>
#include <string_view>
#if defined(__APPLE__)
#include <SDL2/SDL.h>
#if defined(IMGUI_IMPL_OPENGL_ES2)
#include <SDL2/SDL_opengles.h>
#else
#include <SDL2/SDL_opengl.h>
#endif
#else
#include <SDL.h>
#if defined(IMGUI_IMPL_OPENGL_ES2)
#include <SDL_opengles2.h>
#else
#include <SDL_opengl.h>
#endif
#endif
class ImageBundle {
public:
int width;
int height;
int channels;
ImTextureID texture;
GLuint *glTextureID;
std::string_view raw_buffer;
uint8_t *image;
bool loaded;
std::string fname;
ImageBundle() {
fname = "";
loaded = false;
}
float aspectRatio() { return (float)width / (float)height; }
int calcResizedWidth(int newHeight) {
return (int)((float)newHeight * (1.0 / aspectRatio()));
}
int calcResizedHeight(int newWidth) {
return (int)((float)newWidth * (aspectRatio()));
}
};