cgv
gl_cursor.h
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 
6 #include "lib_begin.h"
7 
8 namespace cgv {
9  namespace render {
10  namespace gl {
11 
15 class CGV_API gl_cursor
16 {
17 public:
18  int hot_x, hot_y;
19  unsigned w, h;
20  std::vector<unsigned> tex_ids;
21  std::vector<unsigned> frames;
22  std::vector<unsigned> periods;
23  unsigned duration;
24  void update_duration();
25  void clear();
26  void add_frame(unsigned tex_id);
27 public:
29  gl_cursor();
31  bool is_created() const;
33 
49  bool create(const std::string& id = "arrow");
51  bool create_from_file(const std::string& file_name);
53  unsigned get_width() const { return w; }
55  unsigned get_height() const { return h; }
57  int get_hot_x() const { return hot_x; }
59  int get_hot_y() const { return hot_y; }
61  void set_hot_spot(int _x, int _y) { hot_x = _x; hot_y = _x; }
63  unsigned get_nr_steps() const;
65  unsigned get_nr_frames() const;
67  unsigned get_texture_id(unsigned frame_idx = 0) const;
69  unsigned get_step_frame(unsigned step_idx) const;
71  void set_step_frame(unsigned step_idx, unsigned frame_idx);
73  unsigned get_step_period(unsigned step_idx) const;
75  void set_step_period(unsigned step_idx, unsigned period);
77  void append_step(unsigned frame_idx, unsigned period);
79  unsigned find_step_index(double elapsed_seconds) const;
81  unsigned get_frame_texture_id(int frame_idx) const;
83 
87  void draw(int x, int y, bool use_color = false, unsigned frame_idx = 0);
88 };
89 
90  }
91  }
92 }
93 
94 #include <cgv/config/lib_end.h>
cgv::render::gl::gl_cursor
Definition: gl_cursor.h:16
cgv::render::gl::gl_cursor::get_height
unsigned get_height() const
return the height of the cursor
Definition: gl_cursor.h:55
cgv::render::gl::gl_cursor::get_width
unsigned get_width() const
return the width of the cursor
Definition: gl_cursor.h:53
cgv::render::gl::gl_cursor::get_hot_y
int get_hot_y() const
return the y-coordinate of the hot spot of the cursor in local pixel coordinates
Definition: gl_cursor.h:59
cgv::render::gl::gl_cursor::get_frame_texture_id
unsigned get_frame_texture_id(int frame_idx) const
return the gl texture id of the given frame
cgv::render::gl::gl_cursor::set_hot_spot
void set_hot_spot(int _x, int _y)
set a new hot spot of the cursor in local pixel coordinates
Definition: gl_cursor.h:61
cgv::render::gl::gl_cursor::get_hot_x
int get_hot_x() const
return the x-coordinate of the hot spot of the cursor in local pixel coordinates
Definition: gl_cursor.h:57
cgv
the cgv namespace
Definition: vr_calib.cxx:9