You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
1.8KB

  1. #pragma once
  2. #include <memory>
  3. #define GLEW_STATIC
  4. #include <GL/glew.h>
  5. #include <GLFW/glfw3.h>
  6. #include "nanovg.h"
  7. #include "nanosvg.h"
  8. #include "common.hpp"
  9. #ifdef ARCH_MAC
  10. #define WINDOW_MOD_KEY_NAME "Cmd"
  11. #else
  12. #define WINDOW_MOD_KEY_NAME "Ctrl"
  13. #endif
  14. namespace rack {
  15. // 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.
  16. struct Font {
  17. int handle;
  18. Font(const std::string &filename);
  19. ~Font();
  20. static std::shared_ptr<Font> load(const std::string &filename);
  21. };
  22. struct Image {
  23. int handle;
  24. Image(const std::string &filename);
  25. ~Image();
  26. static std::shared_ptr<Image> load(const std::string &filename);
  27. };
  28. struct SVG {
  29. NSVGimage *handle;
  30. SVG(const std::string &filename);
  31. ~SVG();
  32. static std::shared_ptr<SVG> load(const std::string &filename);
  33. };
  34. extern GLFWwindow *gWindow;
  35. extern NVGcontext *gVg;
  36. extern NVGcontext *gFramebufferVg;
  37. /** The default font to use for GUI elements */
  38. extern std::shared_ptr<Font> gGuiFont;
  39. /** The scaling ratio */
  40. extern float gPixelRatio;
  41. /* The ratio between the framebuffer size and the window size reported by the OS.
  42. This is not equal to gPixelRatio in general.
  43. */
  44. extern float gWindowRatio;
  45. extern bool gAllowCursorLock;
  46. extern int gGuiFrame;
  47. extern math::Vec gMousePos;
  48. void windowInit();
  49. void windowDestroy();
  50. void windowRun();
  51. void windowClose();
  52. void windowCursorLock();
  53. void windowCursorUnlock();
  54. bool windowIsModPressed();
  55. bool windowIsShiftPressed();
  56. math::Vec windowGetWindowSize();
  57. void windowSetWindowSize(math::Vec size);
  58. math::Vec windowGetWindowPos();
  59. void windowSetWindowPos(math::Vec pos);
  60. bool windowIsMaximized();
  61. void windowSetTheme(NVGcolor bg, NVGcolor fg);
  62. void windowSetFullScreen(bool fullScreen);
  63. bool windowGetFullScreen();
  64. } // namespace rack