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.

85 lines
1.8KB

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