2023-08-25 14:38:06 -07:00
|
|
|
#pragma once
|
2024-03-23 18:41:26 -07:00
|
|
|
#include "imgui/imgui.h"
|
2023-08-25 14:38:06 -07:00
|
|
|
#include <functional>
|
|
|
|
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
|
|
|
#include <SDL_opengles2.h>
|
|
|
|
#else
|
|
|
|
#include <SDL_opengl.h>
|
|
|
|
#endif
|
|
|
|
#include <SDL.h>
|
|
|
|
#include <SDL_video.h>
|
2024-04-24 09:59:51 -07:00
|
|
|
#ifdef __EMSCRIPTEN__
|
|
|
|
#include "emscripten_mainloop_stub.h"
|
|
|
|
#include <emscripten.h>
|
|
|
|
#include <emscripten/html5.h>
|
|
|
|
#endif
|
2023-08-25 14:38:06 -07:00
|
|
|
#include <string>
|
|
|
|
#include "theme.h"
|
2024-01-21 15:21:18 -08:00
|
|
|
static const char* NAME = "Looper";
|
2023-08-25 14:38:06 -07:00
|
|
|
class RendererBackend {
|
2024-04-24 09:59:51 -07:00
|
|
|
void BackendDeinit();
|
|
|
|
void LoopFunction();
|
2024-05-01 09:07:08 -07:00
|
|
|
bool started = false;
|
2024-04-28 12:31:40 -07:00
|
|
|
//SDL_GLContext gl_context;
|
2024-04-24 09:59:51 -07:00
|
|
|
bool resize_needed = true;
|
|
|
|
void on_resize();
|
2024-05-01 09:07:08 -07:00
|
|
|
bool update_scale = false;
|
2023-08-25 14:38:06 -07:00
|
|
|
public:
|
2024-04-28 12:31:40 -07:00
|
|
|
std::optional<bool> touchScreenModeOverride;
|
2024-05-01 09:07:08 -07:00
|
|
|
std::optional<double> scaleOverride;
|
2024-04-28 12:31:40 -07:00
|
|
|
bool isTouchScreenMode();
|
2024-04-24 09:59:51 -07:00
|
|
|
static void resize_static();
|
2023-09-03 11:54:07 -07:00
|
|
|
double scale = 1.0;
|
2023-08-25 14:38:06 -07:00
|
|
|
SDL_Window *window;
|
2024-04-28 12:31:40 -07:00
|
|
|
SDL_Renderer *rend;
|
2023-08-25 14:38:06 -07:00
|
|
|
int window_width = 475;
|
|
|
|
int window_height = 354;
|
|
|
|
bool done = false;
|
|
|
|
Theme *theme;
|
|
|
|
bool vsync = false;
|
|
|
|
std::string lang;
|
|
|
|
std::string userdir;
|
|
|
|
int framerate = 60;
|
|
|
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
|
|
|
ImFont *title;
|
|
|
|
const char *prefPath;
|
2024-01-21 15:22:27 -08:00
|
|
|
ImVec4 accent_color = ImVec4(0.75, 1.0, 1.0, 1.0);
|
2023-08-25 14:38:06 -07:00
|
|
|
int Run();
|
|
|
|
void SetWindowTitle(const char *title);
|
|
|
|
virtual void Init();
|
|
|
|
virtual void GuiFunction();
|
|
|
|
virtual void Deinit();
|
2023-10-16 10:44:25 -07:00
|
|
|
virtual void Drop(std::string file);
|
2024-05-01 09:07:08 -07:00
|
|
|
virtual void OnScale(float scale);
|
2023-09-03 11:54:07 -07:00
|
|
|
void UpdateScale();
|
2024-05-01 09:07:08 -07:00
|
|
|
void QueueUpdateScale();
|
2023-09-03 11:54:07 -07:00
|
|
|
void AddFonts();
|
|
|
|
void SetWindowSize(int w, int h);
|
|
|
|
void GetWindowsize(int *w, int *h);
|
2023-08-25 14:38:06 -07:00
|
|
|
RendererBackend();
|
|
|
|
~RendererBackend();
|
2024-04-24 09:59:51 -07:00
|
|
|
friend void main_loop();
|
|
|
|
};
|