Simple Graphics Library  0.9.5
SGL API
sgl.h
1 
47 #ifndef SGL_H_
48 #define SGL_H_
49 
50 #ifdef _MSC_VER
51  #pragma warning(disable:4251)
52  #pragma warning(disable:4224)
53 #endif
54 
55 #include <iostream>
56 #include <vector>
57 //#include <list>
58 #include <string>
59 #include <ctime>
60 #include <fstream>
61 #include <functional>
62 
63 
68 namespace sgl {
69 
75 struct Point {
77  double x;
78 
80  double y;
81 
86  Point(double x, double y): x(x), y(y) {}
87 
91  Point(): x(0.0), y(0.0) {}
92 };
93 
98 class Color {
99 public:
101  double red;
103  double green;
105  double blue;
106 
113  Color(double r, double g, double b):
114  red(r < 0.0 ? 0.0 : (r > 1.0) ? 1.0 : r),
115  green(g < 0.0 ? 0.0 : (g > 1.0) ? 1.0 : g),
116  blue(b < 0.0 ? 0.0 : (b > 1.0) ? 1.0 : b) {};
117 };
118 
119 // These are duplicates of the GLUT constants. This hack allows
120 // clients to use the SGL library without exposing GLUT directly.
121 // If the GLUT constants values are changed (unlikely), these
122 // values would need to be changed to match.
123 // The implementation code could have wrapped the GLUT constants,
124 // but then each client access of a SGL constant would require a
125 // conversion to the corresponding GLUT equivalent. This hack
126 // avoids that processing overhead.
127 
128 /* Add MouseEvent and KeyEvent classes? */
129 
134 enum class MouseButton {
135  Left = 0,
136  Right = 2,
137  Unknown = -1
138 };
139 
144 enum SpecialKey {
145  F1_KEY = 10001,
146  F2_KEY,
147  F3_KEY,
148  F4_KEY,
149  F5_KEY,
150  F6_KEY,
151  F7_KEY,
152  F8_KEY,
153  F9_KEY,
154  F10_KEY,
155  F11_KEY,
156  F12_KEY,
157  LEFT_KEY = 10100,
158  UP_KEY,
159  RIGHT_KEY,
160  DOWN_KEY,
161  PAGE_UP_KEY,
162  PAGE_DOWN_KEY,
163  HOME_KEY,
164  END_KEY,
165  INSERT_KEY
166 };
167 
171 enum class CursorShape {
172  Right_arrow = 0,
173  Left_arrow,
174  /* Symbolic cursor shapes. */
175  Info,
176  Destroy,
177  Help,
178  Cycle,
179  Spray,
180  Wait,
181  Text,
182  Crosshair,
183  /* Directional cursors. */
184  Up_down,
185  Left_right,
186  /* Sizing cursors. */
187  Top_side,
188  Bottom_side,
189  Left_side,
190  Right_side,
191  Top_left_corner,
192  Top_right_corner,
193  Bottom_right_corner,
194  Bottom_left_corner,
195  /* Inherit from parent window. */
196  Inherit = 100,
197  /* Blank cursor. */
198  None,
199  /* Fullscreen crosshair (if available). */
200  Full_crosshair
201 };
202 
209 enum class KeyModifier {
210  NO_KEY = 0,
211  SHIFT_KEY = 1,
212  CTRL_KEY = 2,
213  ALT_KEY = 4
214 };
215 
216 class Window; // Forward reference
217 class ObjectWindow; // Forward reference
218 
219 
225 private:
227  static unsigned id_source;
228 
229 protected:
232 
235  double x_hit_offset;
236 
239  double y_hit_offset;
240 
243  double left;
244 
247  double bottom;
248 
251  double width;
252 
255  double height;
256 
260 
264 
265 
266 public:
268  const unsigned id;
269 
282  GraphicalObject(double left, double bottom, double width,
283  double height);
284 
291  GraphicalObject(const GraphicalObject& other);
292 
302  GraphicalObject& operator=(const GraphicalObject& other);
303 
307  virtual ~GraphicalObject();
308 
316  virtual double get_left() const;
317 
325  virtual double get_bottom() const;
326 
332  virtual double get_width() const;
333 
339  virtual double get_height() const;
340 
352  virtual void set(double x, double y, double width, double height);
353 
354 
362  virtual void paint() const = 0;
363 
364 
377  virtual void move_to(double left, double bottom);
378 
391  virtual void mouse_pressed(double x, double y, MouseButton button);
392 
405  virtual void mouse_released(double x, double y, MouseButton button);
406 
417  virtual void mouse_moved(double x, double y);
418 
435  virtual void mouse_dragged(double x, double y);
436 
450  virtual void key_pressed(int k, double x, double y);
451 
452 
453 
464  virtual bool hit(double x, double y);
465 
472  virtual Window *set_window(ObjectWindow *win);
473 
479  virtual Window *get_window() const;
480 
487  virtual void set_mouse_over(bool flag);
488 
494  virtual CursorShape set_cursor(CursorShape cursor);
495 
502  virtual CursorShape get_cursor();
503 };
504 
505 
506 
510 extern const Color BLACK, RED, GREEN, BLUE, YELLOW, MAGENTA, CYAN, WHITE,
511  DARK_RED, DARK_GREEN, DARK_BLUE, LIGHT_RED, LIGHT_GREEN,
512  LIGHT_BLUE, GRAY, LIGHT_GRAY, DARK_GRAY;
513 
520 class Window {
521 protected:
522  // Extents of window in viewport coordinates
525  double min_x;
526 
529  double max_x;
530 
533  double min_y;
534 
537  double max_y;
538 
541 
546 
566  void initialize(const std::string& title, int left, int top, int width, int height,
567  double min_x, double max_x, double min_y, double max_y);
568 
569 public:
570 
571 
593  Window(const std::string& title, int left, int top, int width, int height,
594  double min_x, double max_x, double min_y, double max_y);
595 
605  Window(const std::string& title, int width, int height);
606 
607 
622  Window(const std::string& title, double min_x, double max_x, double min_y, double max_y);
623 
627  Window();
628 
632  virtual ~Window();
633 
639  virtual void clear();
640 
641 
647  virtual void set_title(const std::string& str);
648 
655  virtual void set_background_color(const Color &color);
656 
664  virtual void set_position(int x, int y);
665 
673  virtual void set_size(int width, int height);
674 
684  virtual void set_viewport(double left, double right,
685  double bottom, double top);
686 
694  virtual void set_visible(bool visible);
695 
702  virtual CursorShape set_cursor(CursorShape cursor);
703 
708  virtual CursorShape get_cursor();
709 
710  /*
711  * Start the graphics event loop. Control is passed to the
712  * event manager and the event manager maintains control for the
713  * rest of the program's execution. This method should be
714  * called only once.
715  * @return nothing
716  */
717  virtual void run();
718 
723  virtual void repaint();
724 
729  virtual void prepaint();
730 
735  virtual void postpaint();
736 
743  virtual void paint() = 0;
744 
749  virtual void paint_all();
750 
757  virtual int get_x() const;
758 
765  virtual int get_y() const;
766 
771  virtual int get_width() const;
772 
777  virtual int get_height() const;
778 
785  virtual void set_window_size(int w, int h);
786 
795  virtual void resized(int w, int h);
796 
803  virtual double get_min_x() const;
804 
811  virtual double get_max_x() const;
812 
819  virtual double get_min_y() const;
820 
827  virtual double get_max_y() const;
828 
835  virtual void draw_axes(double x_inc, double y_inc) const;
836 
850  virtual void mouse_pressed(double x, double y, MouseButton button);
851 
865  virtual void mouse_released(double x, double y, MouseButton button);
866 
879  virtual void mouse_moved(double x, double y);
880 
894  virtual void mouse_dragged(double x, double y);
895 
901  virtual void mouse_entered();
902 
908  virtual void mouse_exited();
909 
910 
923  virtual void key_pressed(int k, double x, double y);
924 
931  KeyModifier get_key_modifiers() const;
932 
942  void set_key_modifiers(KeyModifier mod);
943 
950  virtual void start_timer(int msec);
951 
960  virtual void timer_expired();
961 };
962 
964 //typedef void (Window::*WindowCallback)();
965 //using WindowCallback = void (Window::*)();
966 //using WindowCallback = std::function<void()>;
967 
968 using MenuItemFunction = std::function<void()>;
969 
970 
975 class PopupMenu {
976 protected:
978  //Window *window;
979  int index; // The GLUT popup menu index
980 
981  struct MenuItem {
982  //const char *name;
983  std::string name;
984  int index;
985  //WindowCallback code;
986  MenuItemFunction code;
987  //MenuItem(const char *name, WindowCallback code):
988  //MenuItem(const std::string& name, WindowCallback code):
989  MenuItem(const std::string& name, MenuItemFunction code):
990  name(name), code(code) {}
991  };
992 
994  std::vector<MenuItem> items;
995 
997  static void process_menu_events(int option);
998 
999 public:
1000 
1004  //PopupMenu(Window *win);
1005  PopupMenu();
1006 
1010  virtual ~PopupMenu();
1011 
1021  //virtual void _add_menu_item(const char *item, WindowCallback func);
1022  //virtual void internal_add_menu_item(const std::string& item, WindowCallback func);
1023  //virtual void internal_add_menu_item(const std::string& item, MenuItemFunction func);
1024  virtual void add_menu_item(const std::string& item, MenuItemFunction func);
1025 
1035  //virtual void internal_replace_menu_item(const std::string& old_name,
1036  virtual void replace_menu_item(const std::string& old_name,
1037  const std::string& new_name,
1038  MenuItemFunction func);
1039 
1046  //virtual void remove_menu_item(const char *item);
1047  virtual void remove_menu_item(const std::string& item);
1048 
1057  virtual void execute_handler(int n);
1058 
1063  virtual void activate();
1064 };
1065 
1070 class ObjectWindow: public Window {
1071 protected:
1073  std::vector<GraphicalObject *> object_list;
1074  GraphicalObject *active_object;
1075 
1076 public:
1096  ObjectWindow(const std::string& title, int left, int top, int width,
1097  int height, double min_x, double max_x,
1098  double min_y, double max_y);
1099 
1106  ObjectWindow(const std::string& title, int width, int height);
1107 
1108 
1121  ObjectWindow(const std::string& title, double min_x, double max_x,
1122  double min_y, double max_y);
1123 
1127  ObjectWindow();
1128 
1132  ~ObjectWindow();
1133 
1138  void prepaint() override;
1139 
1144  void postpaint() override;
1145 
1159  void mouse_pressed(double x, double y, MouseButton button) override;
1160 
1174  void mouse_released(double x, double y, MouseButton button) override;
1175 
1188  void mouse_moved(double x, double y) override;
1189 
1203  void mouse_dragged(double x, double y) override;
1204 
1217  void key_pressed(int k, double x, double y) override;
1218 
1228  void internal_add(GraphicalObject *obj);
1229 
1230  //template <typename T, typename... Args>
1231  //inline T *add(Args&&... args);
1232 
1243  template <typename T, typename... Args>
1244  inline T *add(Args&&... args) {
1245  // The window owns the pointer to the graphical object
1246  T *obj = new T(args...);
1247  internal_add(obj);
1248  return obj;
1249  }
1250 
1251 
1258  void remove(GraphicalObject *obj);
1259 
1266  void remove_all();
1267 
1281  GraphicalObject *hit(double x, double y) const;
1282 
1289  std::vector<GraphicalObject *>::iterator begin();
1290 
1297  std::vector<GraphicalObject *>::iterator end();
1298 };
1299 
1300 
1307 protected:
1309  std::vector<GraphicalObject *> objects;
1310 public:
1315  CompositeObject();
1316 
1317  /*
1318  * The destructor frees up all contained objects.
1319  */
1320  ~CompositeObject();
1321 
1327  void paint() const override;
1328 
1334  void move_to(double x, double y) override;
1335 
1342  void internal_add(GraphicalObject *obj);
1343 
1354  template <typename T, typename... Args>
1355  inline T *add(Args&&... args) {
1356  // The window owns the pointer to the graphical object
1357  T *obj = new T(args...);
1358  internal_add(obj);
1359  return obj;
1360  }
1361 };
1362 
1363 
1374 class Pixmap {
1375  // Local type represents a color triple, each with 256
1376  // possible intensities
1377  struct RGB {
1378  unsigned char red, green, blue;
1379  };
1380 
1388  static unsigned short get_short(std::ifstream& fin);
1389 
1397  static unsigned long get_long(std::ifstream& fin);
1398 
1406  static bool power_of_2(int n);
1407 public :
1408  // dimensions of the pixmap
1409  int nRows, nCols;
1410 
1411  // array of pixels
1412  RGB* pixel;
1413 
1421  bool read_BMP_file(const char *fname);
1422 
1429  bool make_checkerboard();
1430 
1431  //
1432  //void set_texture(GLuint textureName);
1433  void set_texture(unsigned int textureName);
1434 };
1435 
1436 
1437 
1446  Pixmap pix;
1447  unsigned int texture_id;
1448 public:
1460  BitmapObject(const char *filename, double x, double y,
1461  double width, double height);
1462 
1466  void paint() const;
1467 };
1468 
1469 
1470 
1471 
1472 
1477 class OGLWindow: public Window {
1478 public:
1490  //OGLWindow(const char *title, int left, int top, int width, int height);
1491  OGLWindow(const std::string& title, int left, int top, int width, int height);
1492 
1497  //OGLWindow(const char *title);
1498  OGLWindow(const std::string& title);
1499 
1500  // TODO add deleted copy ctor, assignment, etc.
1501 
1505  ~OGLWindow();
1506 
1511  void prepaint() override;
1512 
1517  void postpaint() override;
1518 
1519 };
1520 
1521 
1522 /******************************************
1523  * Classes for seven segment digit displays
1524  ******************************************/
1525 
1531 protected:
1534 
1537 
1539  double x, y;
1540 
1542  double height;
1543 
1544  // Draw the segments:
1545  // +--- a ---+
1546  // | |
1547  // f b
1548  // | |
1549  // +--- g ---+
1550  // | |
1551  // e c
1552  // | |
1553  // +--- d ---+
1554 
1555  Point segment_a[4],
1556  segment_b[4],
1557  segment_c[4],
1558  segment_d[4],
1559  segment_e[4],
1560  segment_f[4],
1561  segment_g[6];
1562 
1563 
1570  void update_segment_locations();
1571 
1572 public:
1580  SevenSegmentDigit(Color color, double x, double y, double height);
1581 
1586  double get_x() const;
1587 
1592  double get_y() const;
1593 
1598  double get_height() const;
1599 
1603  void paint() const;
1604 
1611  void set_value(int value);
1612 
1617  int get_value() const;
1618 
1623  void increment();
1624 
1629  void decrement();
1630 
1637  void resize(double inc);
1638 
1646  void move_to(double x, double y);
1647 };
1648 
1649 
1654 protected:
1657 
1658 public:
1667  DisplayDigit(Color color, double x, double y, double height);
1668 
1670  void paint() const override;
1671 
1678  void set_value(int value);
1679 
1684  int get_value() const;
1685 
1686 
1691  void increment();
1692 
1697  void decrement();
1698 
1705  void resize(double inc);
1706 
1714  void mouse_dragged(double x, double y) override;
1715 };
1716 
1717 
1718 
1724 protected:
1727 
1730 
1734 
1737  bool visible;
1738 
1739 public:
1748  DoubleDigit(Color color, double x, double y, double height);
1749 
1751  void paint() const override;
1752 
1759  void set_value(int value);
1760 
1765  int get_value() const;
1766 
1771  void increment();
1772 
1777  void decrement();
1778 
1785  void resize(double inc);
1786 
1796  void mouse_dragged(double x, double y) override;
1797 
1804  void set_leading_zero(bool flag);
1805 
1812  void set_visible(bool flag);
1813 };
1814 
1815 
1821 protected:
1823  std::vector<SevenSegmentDigit> digits;
1824 
1825  // /** Dynamic array of seven segment digits */
1826  // SevenSegmentDigit *digits;
1827 
1831 
1834  bool visible;
1835 
1836  void increment_helper(int n);
1837 
1838  void decrement_helper(int n);
1839 
1840 public:
1851  Multidigit(int n, Color color, double x, double y, double height);
1852 
1854  void paint() const override;
1855 
1861  void set_value(int value);
1862 
1867  int get_value() const;
1868 
1873  void increment();
1874 
1879  void decrement();
1880 
1887  void resize(double inc);
1888 
1898  void mouse_dragged(double x, double y) override;
1899 
1912  virtual void move_to(double left, double bottom) override;
1913 
1920  void set_leading_zeros(bool flag);
1921 
1928  void set_visible(bool flag);
1929 };
1930 
1931 
1933 protected:
1936 
1939 
1942 
1945 
1948 
1951 
1953  int seconds;
1954 
1958 
1961  bool visible;
1962 
1969  void draw_separator(const SevenSegmentDigit& left_ones, const SevenSegmentDigit& right_tens) const;
1970 
1976  void paint_without_leading_units() const;
1977 
1978 public:
1987  TimeDisplay(Color color, double x, double y, int height);
1988 
1992  void paint() const override;
1993 
1999  void set_value(int sec);
2000 
2005  int get_value() const;
2006 
2011  void increment();
2012 
2017  void decrement();
2018 
2025  void resize(double inc);
2026 
2036  void mouse_dragged(double x, double y) override;
2037 
2047  void move_to(double x, double y) override;
2048 
2049 
2056  void set_leading_units(bool flag);
2057 
2064  void set_visible(bool flag);
2065 };
2066 
2067 
2068 
2069 
2070 
2071 /******************************************
2072  * Global drawing functions
2073  ******************************************/
2074 
2075 
2085 void initialize_graphics(unsigned int mode);
2086 
2096 void initialize_graphics();
2097 
2098 
2107 bool intersect(const GraphicalObject& obj1,
2108  const GraphicalObject& obj2);
2109 
2116 void draw_point(double x, double y);
2117 
2124 void draw_point(const Point& pt);
2125 
2131 void set_point_size(int point_size);
2132 
2133 
2146 void draw_line(double x0, double y0, double x1, double y1);
2147 
2162 void draw_dashed_line(double x0, double y0, double x1, double y1,
2163  int pattern=0x00FF);
2164 
2177 void draw_rectangle(double x, double y, double width, double height);
2178 
2191 void fill_rectangle(double x, double y, double width, double height);
2192 
2202 void draw_circle(double x, double y, double radius);
2203 
2213 void fill_circle(double x, double y, double radius);
2214 
2224 void draw_polygon(const std::vector<Point>& pts);
2225 
2236 void draw_polygon(const Point *pts, int n);
2237 
2247 void fill_polygon(const std::vector<Point>& pts);
2248 
2259 void fill_polygon(const Point *pts, int n);
2260 
2273 //void draw_text(const char *text, double x, double y, int font_size);
2274 void draw_text(const std::string& text, double x, double y, int font_size);
2275 
2289 //void draw_text(const char *text, double x, double y, double scale);
2290 void draw_text(const std::string& text, double x, double y, double scale);
2291 
2300 //double text_width(const char *text, int font_size);
2301 double text_width(const std::string& text, int font_size);
2302 
2317 void draw_function(double (*f)(double), double begin_x, double end_x,
2318  double delta);
2319 
2325 void set_color(const Color &color);
2326 
2334 void set_color(double r, double g, double b);
2335 
2341 void set_line_width(double width);
2342 
2343 
2353 template <typename T, typename... Args>
2354 inline void run(Args&&... args);
2355 
2365 template <typename T, typename... Args>
2366 inline T *make_window(Args&&... args);
2367 
2368 
2369 
2370 /****************************************************
2371  * Miscellaneous utility functions
2372  ****************************************************/
2373 
2379 int get_screen_width();
2380 
2386 int get_screen_height();
2387 
2388 
2389 /* Add a random number generator class? */
2390 
2399 void set_random_seed(int seed=-1);
2400 
2411 int random(int begin, int end);
2412 
2421 int random(int n);
2422 
2423 
2428 class Stopwatch {
2429 protected:
2431  clock_t start_time;
2432 
2434  clock_t end_time;
2435 
2437  bool running;
2438 
2439 public:
2444  Stopwatch();
2445 
2455  void start();
2456 
2466  void stop();
2467 
2474  void reset();
2475 
2486  double elapsed() const; // Reveal the elapsed time
2487 };
2488 
2496 void pause(int msec);
2497 
2498 
2499 
2513 bool equals(double d1, double d2, double delta);
2514 
2515 // Modern C++ provides standard functions for these:
2517 // * Converts an integer to a string so it can be displayed
2518 // * with draw_text.
2519 // * @param i the integer to convert
2520 // * @return the string representation of i
2521 // */
2522 //std::string to_string(int i);
2523 //
2525 // * Converts a double to a string so it can be displayed
2526 // * with draw_text.
2527 // * @param d the double to convert
2528 // * @return the string representation of d
2529 // */
2530 //std::string to_string(double d);
2531 
2532 
2536 std::string version();
2537 
2538 
2539 //------------------------------------------------------------------------------------------
2540 // Procedural interface to the SGL
2541 
2555 void create_window(const std::string& title, int x, int y, int width, int height);
2556 
2562 void run_window();
2563 
2570 void update_window();
2571 
2578 void set_paint_function(const std::function<void()>& f);
2579 
2586 void set_mouse_pressed_function(const std::function<void(double, double, MouseButton)>& f);
2587 
2594 void set_mouse_released_function(const std::function<void(double, double, MouseButton)>& f);
2595 
2602 void set_mouse_moved_function(const std::function<void(double, double)>& f);
2603 
2610 void set_mouse_dragged_function(const std::function<void(double, double)>& f);
2611 
2618 void set_key_pressed_function(const std::function<void(int, double, double)>& f);
2619 
2627 void set_window_background(const Color& c);
2628 
2634 void set_window_title(const std::string& str);
2635 
2636 
2637 
2638 } // End of namespace sgl
2639 
2643 //#define add_menu_item(x, y) internal_add_menu_item((x), (y));
2645 //#define replace_menu_item(x, y, z) internal_replace_menu_item((x), (y), (z));
2646 
2647 
2648 #endif
CursorShape cursor
Definition: sgl.h:259
KeyModifier
Definition: sgl.h:209
void draw_dashed_line(double x0, double y0, double x1, double y1, int pattern=0x00FF)
Definition: sgl.hpp:2702
SevenSegmentDigit seconds_ones
Definition: sgl.h:1950
void set_random_seed(int seed=-1)
Definition: sgl.hpp:3017
Definition: sgl.h:1932
void set_mouse_dragged_function(const std::function< void(double, double)> &f)
Definition: sgl.hpp:3189
MouseButton
Definition: sgl.h:134
bool visible
Definition: sgl.h:1961
void draw_line(double x0, double y0, double x1, double y1)
Definition: sgl.hpp:2695
double min_x
Definition: sgl.h:525
Color color
Definition: sgl.h:1536
SevenSegmentDigit minutes_ones
Definition: sgl.h:1944
Definition: sgl.h:975
double left
Definition: sgl.h:243
Definition: sgl.h:75
Color(double r, double g, double b)
Definition: sgl.h:113
bool visible
Definition: sgl.h:1834
std::string version()
Definition: sgl.hpp:200
bool leading_zeros
Definition: sgl.h:1830
double max_x
Definition: sgl.h:529
void fill_circle(double x, double y, double radius)
Definition: sgl.hpp:2760
void set_window_background(const Color &c)
Definition: sgl.hpp:3201
void draw_rectangle(double x, double y, double width, double height)
Definition: sgl.hpp:2717
clock_t start_time
Definition: sgl.h:2431
SevenSegmentDigit ones
Definition: sgl.h:1729
double x
Definition: sgl.h:1539
SevenSegmentDigit tens
Definition: sgl.h:1726
void set_paint_function(const std::function< void()> &f)
Definition: sgl.hpp:3164
Definition: sgl.h:1477
SevenSegmentDigit minutes_tens
Definition: sgl.h:1941
Definition: sgl.h:68
void set_window_title(const std::string &str)
Definition: sgl.hpp:3207
void update_window()
Definition: sgl.hpp:3158
std::vector< GraphicalObject * > objects
Definition: sgl.h:1309
double y_hit_offset
Definition: sgl.h:239
std::function< void()> MenuItemFunction
Definition: sgl.h:968
Definition: sgl.h:224
Definition: sgl.h:98
int index
Definition: sgl.h:979
Point(double x, double y)
Definition: sgl.h:86
Definition: sgl.h:1723
bool leading_zero
Definition: sgl.h:1733
void draw_function(double(*f)(double), double begin_x, double end_x, double delta)
Definition: sgl.hpp:2881
double width
Definition: sgl.h:251
void set_line_width(double width)
Definition: sgl.hpp:2627
int random(int begin, int end)
Definition: sgl.hpp:3026
double x_hit_offset
Definition: sgl.h:235
const Color BLACK
clock_t end_time
Definition: sgl.h:2434
Definition: sgl.h:1653
ObjectWindow * window
Definition: sgl.h:231
Definition: sgl.h:2428
void set_mouse_moved_function(const std::function< void(double, double)> &f)
Definition: sgl.hpp:3183
T * make_window(Args &&... args)
Definition: sgl.hpp:2940
KeyModifier key_mods
Definition: sgl.h:545
void fill_rectangle(double x, double y, double width, double height)
Definition: sgl.hpp:2732
double height
Definition: sgl.h:1542
Definition: sgl.h:981
void set_mouse_released_function(const std::function< void(double, double, MouseButton)> &f)
Definition: sgl.hpp:3177
T * add(Args &&... args)
Definition: sgl.h:1355
SevenSegmentDigit led
Definition: sgl.h:1656
SevenSegmentDigit hours_ones
Definition: sgl.h:1938
void create_window(const std::string &title, int x, int y, int width, int height)
Definition: sgl.hpp:3145
Definition: sgl.h:1374
void draw_circle(double x, double y, double radius)
Definition: sgl.hpp:2743
Definition: sgl.h:1445
void set_color(const Color &color)
Definition: sgl.hpp:2619
T * add(Args &&... args)
Definition: sgl.h:1244
const unsigned id
Definition: sgl.h:268
double x
Definition: sgl.h:77
void set_key_pressed_function(const std::function< void(int, double, double)> &f)
Definition: sgl.hpp:3195
bool equals(double d1, double d2, double delta)
Definition: sgl.hpp:3046
void set_mouse_pressed_function(const std::function< void(double, double, MouseButton)> &f)
Definition: sgl.hpp:3170
bool visible
Definition: sgl.h:1737
int seconds
Definition: sgl.h:1953
double bottom
Definition: sgl.h:247
Definition: sgl.h:520
double y
Definition: sgl.h:80
void pause(int msec)
Definition: sgl.hpp:3004
Definition: sgl.h:1070
SpecialKey
Definition: sgl.h:144
double height
Definition: sgl.h:255
Definition: sgl.h:1820
SevenSegmentDigit seconds_tens
Definition: sgl.h:1947
std::vector< GraphicalObject * > object_list
Definition: sgl.h:1073
std::vector< MenuItem > items
Definition: sgl.h:994
Definition: sgl.h:1530
int get_screen_width()
Definition: sgl.hpp:2901
CursorShape
Definition: sgl.h:171
bool running
Definition: sgl.h:2437
double max_y
Definition: sgl.h:537
Point()
Definition: sgl.h:91
void draw_polygon(const std::vector< Point > &pts)
Definition: sgl.hpp:2779
int current_value
Definition: sgl.h:1533
double red
Definition: sgl.h:101
void fill_polygon(const std::vector< Point > &pts)
Definition: sgl.hpp:2806
bool intersect(const GraphicalObject &obj1, const GraphicalObject &obj2)
Definition: sgl.hpp:2639
void run(Args &&... args)
Definition: sgl.hpp:2924
double text_width(const std::string &text, int font_size)
void initialize_graphics(unsigned int mode)
Definition: sgl.hpp:148
double green
Definition: sgl.h:103
CursorShape normal_cursor
Definition: sgl.h:540
bool mouse_over
Definition: sgl.h:263
void draw_text(const std::string &text, double x, double y, int font_size)
Definition: sgl.hpp:2830
Definition: sgl.h:1306
int get_screen_height()
Definition: sgl.hpp:2910
void run_window()
Definition: sgl.hpp:3152
double blue
Definition: sgl.h:105
double min_y
Definition: sgl.h:533
bool leading_units
Definition: sgl.h:1957
void draw_point(double x, double y)
Definition: sgl.hpp:2662
SevenSegmentDigit hours_tens
Definition: sgl.h:1935
std::vector< SevenSegmentDigit > digits
Definition: sgl.h:1823
void set_point_size(int point_size)
Definition: sgl.hpp:2686