#pragma once #include #include #define GLEW_STATIC #define GLEW_NO_GLU #include #include #include #define NANOVG_GL2 #include #include #include #include #include namespace rack { // Constructing these directly will load from the disk each time. Use the load() functions to load from disk and cache them as long as the shared_ptr is held. struct Font { NVGcontext* vg; int handle = -1; /** Don't call this directly but instead use `APP->window->loadFont()` */ void loadFile(const std::string& filename, NVGcontext* vg); ~Font(); /** Use `APP->window->loadFont()` instead. */ DEPRECATED static std::shared_ptr load(const std::string& filename); }; struct Image { NVGcontext* vg; int handle = -1; /** Don't call this directly but instead use `APP->window->loadImage()` */ void loadFile(const std::string& filename, NVGcontext* vg); ~Image(); /** Use `APP->window->loadImage()` instead. */ DEPRECATED static std::shared_ptr load(const std::string& filename); }; struct Svg { NSVGimage* handle = NULL; /** Don't call this directly but instead use `APP->window->loadSvg()` */ void loadFile(const std::string& filename); ~Svg(); /** Use `APP->window->loadSvg()` instead. */ DEPRECATED static std::shared_ptr load(const std::string& filename); }; DEPRECATED typedef Svg SVG; struct Window { struct Internal; Internal* internal; GLFWwindow* win = NULL; NVGcontext* vg = NULL; /** The scaling ratio */ float pixelRatio = 1.f; /* The ratio between the framebuffer size and the window size reported by the OS. This is not equal to gPixelRatio in general. */ float windowRatio = 1.f; int frame = 0; std::shared_ptr uiFont; double frameTimeStart = 0.f; /** Use load*() instead of modifying these directly. */ std::map> fontCache; std::map> imageCache; std::map> svgCache; Window(); ~Window(); void run(); /** Takes a screenshot of each module */ void screenshot(float zoom); void close(); void cursorLock(); void cursorUnlock(); bool isCursorLocked(); /** Gets the current keyboard mod state Don't call this from a Key event. Simply use `e.mods` instead. */ int getMods(); void setFullScreen(bool fullScreen); bool isFullScreen(); bool isFrameOverdue(); float getMonitorRefreshRate(); float getLastFrameRate(); std::shared_ptr loadFont(const std::string& filename); std::shared_ptr loadImage(const std::string& filename); std::shared_ptr loadSvg(const std::string& filename); }; void windowInit(); void windowDestroy(); } // namespace rack