cgv
display.h
1 #pragma once
2 
3 #include <vector>
4 #include <iostream>
5 
6 #include "lib_begin.h"
7 
8 namespace cgv {
9  namespace os {
10 
13 {
15  unsigned int width;
17  unsigned int height;
19  unsigned int bit_depth;
21  unsigned int refresh_rate;
23  display_mode(unsigned int w = 1024, unsigned int h = 768, unsigned int bd = 32, unsigned int rr = 60)
24  : width(w), height(h), bit_depth(bd), refresh_rate(rr) {}
25 };
26 
28 extern CGV_API std::ostream& operator << (std::ostream& os, const display_mode& dm);
29 
32 {
34  int x;
36  int y;
38  display_position(int _x = 0, int _y = 0) : x(_x), y(_y) {}
39 };
40 
42 extern CGV_API std::ostream& operator << (std::ostream& os, const display_position& dp);
43 
46 {
53  : mode(dm), position(dp) {}
54 };
55 
57 extern CGV_API std::ostream& operator << (std::ostream& os, const display_configuration& dc);
58 
60 enum DisplayScanMode
61 {
62  DSM_ALL = 0,
63  DSM_PHYSICAL = 1,
64  DSM_ACTIVE = 2,
65  DSM_PASSIVE = 4
66 };
67 
73 class CGV_API display
74 {
75 public:
78  static std::string last_error;
81  static void scan_displays(DisplayScanMode mode = DSM_ALL);
83  static const std::vector<display*>& get_displays();
85  static void clear_displays();
87  static bool activate_all();
89  static bool check_activate_all();
91  static void show_all_displays(DisplayScanMode scan_mode = DSM_ALL);
93 
95  virtual ~display() {}
96 
99  virtual void enumerate_display_modes(std::vector<display_mode>& display_modes, bool compatible_with_attached_monitor = true) = 0;
102  virtual void show_display_modes(bool compatible_with_attached_monitor = true) = 0;
104 
107  virtual std::string get_name() const = 0;
110  virtual std::string get_description() const = 0;
112  virtual std::string get_ID() const = 0;
114  virtual bool is_mirror() const = 0;
116  virtual bool is_removable() const = 0;
118 
121  virtual bool is_active() const = 0;
124  virtual bool activate() = 0;
126  virtual bool check_activate() const = 0;
128  virtual bool deactivate() = 0;
130  virtual bool is_primary() const = 0;
132  virtual bool make_primary() = 0;
134  virtual bool can_be_primary() const = 0;
136 
139  virtual display_configuration get_configuration() const = 0;
142  virtual display_mode get_mode() const = 0;
144  virtual unsigned int get_width() const = 0;
146  virtual unsigned int get_height() const = 0;
148  virtual unsigned int get_bit_depth() const = 0;
150  virtual unsigned int get_refresh_rate() const = 0;
152  virtual display_position get_position() const = 0;
154  virtual int get_x() const = 0;
156  virtual int get_y() const = 0;
157 
159  virtual bool set_configuration(const display_configuration& dc) = 0;
161  virtual bool set_mode(const display_mode& dm) = 0;
163  virtual bool set_resolution(unsigned int w, unsigned int h) = 0;
165  virtual bool set_bit_depth(unsigned int bits) = 0;
167  virtual bool set_refresh_rate(unsigned int hz) = 0;
169  virtual bool set_position(const display_position& dp) = 0;
171  virtual bool set_position(unsigned int x, unsigned int y) = 0;
173 
176  virtual display_mode get_registered_mode() const = 0;
179  virtual unsigned int get_registered_width() const = 0;
181  virtual unsigned int get_registered_height() const = 0;
183  virtual unsigned int get_registered_bit_depth() const = 0;
185  virtual unsigned int get_registered_refresh_rate() const = 0;
186 
188  virtual bool register_configuration(const display_configuration& dc) = 0;
190  virtual bool register_mode(const display_mode& dm) = 0;
192  virtual bool register_resolution(unsigned int w, unsigned int h) = 0;
194  virtual bool register_bit_depth(unsigned int bits) = 0;
196  virtual bool register_refresh_rate(unsigned int hz) = 0;
198  virtual bool register_position(const display_position& dp) = 0;
200  virtual bool register_position(unsigned int x, unsigned int y) = 0;
201 
203  virtual bool check_configuration(const display_configuration& dc) const = 0;
205  virtual bool check_mode(const display_mode& dm) const = 0;
207  virtual bool check_resolution(unsigned int w, unsigned int h) const = 0;
209  virtual bool check_bit_depth(unsigned int bits) const = 0;
211  virtual bool check_refresh_rate(unsigned int hz) const = 0;
213  virtual bool check_position(const display_position& dp) const = 0;
215  virtual bool check_position(unsigned int x, unsigned int y) const = 0;
217 };
218 
220 extern CGV_API std::ostream& operator << (std::ostream& os, const display& disp);
221 
222  }
223 }
224 
225 #include <cgv/config/lib_end.h>
cgv::os::display::is_removable
virtual bool is_removable() const =0
return whether display is removable
cgv::os::display::register_position
virtual bool register_position(const display_position &dp)=0
register new position immediately, which is activated in the next activate() or activate_all() call
cgv::os::display::check_resolution
virtual bool check_resolution(unsigned int w, unsigned int h) const =0
check given resolution
cgv::os::display_configuration::position
display_position position
display position
Definition: display.h:50
cgv::os::display::set_bit_depth
virtual bool set_bit_depth(unsigned int bits)=0
set new bit depth of the display immediately, return whether this was successful. Only bit depths tha...
cgv::os::display::get_registered_refresh_rate
virtual unsigned int get_registered_refresh_rate() const =0
return the registered refresh rate in Hz (this is changed by prepare_refresh_rate)
cgv::os::display::get_bit_depth
virtual unsigned int get_bit_depth() const =0
return the current bit depth of the display pixels (only defined if display is active)
cgv::os::display::is_mirror
virtual bool is_mirror() const =0
return whether display is a mirrored display
cgv::os::display::get_x
virtual int get_x() const =0
return the current current x coordinate within the virtual screen spanned by the desktop (only define...
cgv::os::display::get_description
virtual std::string get_description() const =0
return the description string of the display
cgv::os::display_position::display_position
display_position(int _x=0, int _y=0)
constructor
Definition: display.h:38
cgv::os::display::set_configuration
virtual bool set_configuration(const display_configuration &dc)=0
set the display configuration immediately, return whether this was successful.
cgv::os::display::register_configuration
virtual bool register_configuration(const display_configuration &dc)=0
register new display configuration, which is activated in the next activate() or activate_all() call
cgv::os::display::get_registered_height
virtual unsigned int get_registered_height() const =0
return the registered height (this is changed by prepare_resolution)
cgv::os::display::register_bit_depth
virtual bool register_bit_depth(unsigned int bits)=0
register new bit depth of the display, which is activated in the next activate() or activate_all() ca...
cgv::os::display::check_activate
virtual bool check_activate() const =0
check if activation of the registered settings will work
cgv::os::display::is_primary
virtual bool is_primary() const =0
return whether display is the primary display
cgv::os::display_position::y
int y
signed y position on virtual screen
Definition: display.h:36
cgv::os::display::deactivate
virtual bool deactivate()=0
deactivate the display, return whether deactivation was successful
cgv::os::display::get_refresh_rate
virtual unsigned int get_refresh_rate() const =0
return the current refresh rate in Hz (only defined if display is active)
cgv::os::display::check_configuration
virtual bool check_configuration(const display_configuration &dc) const =0
check given display configuration
cgv::os::display_mode
a display mode describes a valid setting of the display parameters
Definition: display.h:13
cgv::os::display::register_resolution
virtual bool register_resolution(unsigned int w, unsigned int h)=0
register new resolution of the display, which is activated in the next activate() or activate_all() c...
cgv::os::display::get_position
virtual display_position get_position() const =0
return the current display position
cgv::os::display::register_position
virtual bool register_position(unsigned int x, unsigned int y)=0
register new position of the display, which is activated in the next activate() or activate_all() cal...
cgv::os::display::get_height
virtual unsigned int get_height() const =0
return the current height (only defined if display is active)
cgv::os::display::activate
virtual bool activate()=0
activate the display based on the registered settings or change the current display settings to the r...
cgv::os::display_mode::height
unsigned int height
height in pixel
Definition: display.h:17
cgv::os::display::check_mode
virtual bool check_mode(const display_mode &dm) const =0
check given display mode
cgv::os::display_position::x
int x
signed x position on virtual screen
Definition: display.h:34
cgv::os::display_mode::display_mode
display_mode(unsigned int w=1024, unsigned int h=768, unsigned int bd=32, unsigned int rr=60)
constructor
Definition: display.h:23
cgv::os::display::check_position
virtual bool check_position(unsigned int x, unsigned int y) const =0
check given position
cgv::os::display_configuration::display_configuration
display_configuration(const display_mode &dm=display_mode(), const display_position &dp=display_position())
constructor
Definition: display.h:52
cgv::os::display_mode::refresh_rate
unsigned int refresh_rate
refresh rate in Hz
Definition: display.h:21
cgv::os::display::get_ID
virtual std::string get_ID() const =0
return the unique ID string of the display
cgv::os::display::get_registered_bit_depth
virtual unsigned int get_registered_bit_depth() const =0
return the registered bit depth of a display pixel (this is changed by prepare_bit_depth)
cgv::os::display::get_y
virtual int get_y() const =0
return the current current y coordinate within the virtual screen spanned by the desktop (only define...
cgv::os::display_mode::width
unsigned int width
width in pixel
Definition: display.h:15
cgv::os::display::show_display_modes
virtual void show_display_modes(bool compatible_with_attached_monitor=true)=0
print out all available display modes
cgv::os::display::set_position
virtual bool set_position(unsigned int x, unsigned int y)=0
set new position of the display within the virtual screen immediately, return whether this was succes...
cgv::os::display::make_primary
virtual bool make_primary()=0
make this display the primary display
cgv::os::display::get_width
virtual unsigned int get_width() const =0
return the current width (only defined if display is active)
cgv::os::display::can_be_primary
virtual bool can_be_primary() const =0
check if this display can be made primary
cgv::os::display::set_mode
virtual bool set_mode(const display_mode &dm)=0
set the given display mode immediately, return whether this was successful. Only valid display modes ...
cgv::os::display_mode::bit_depth
unsigned int bit_depth
number of bits per pixel
Definition: display.h:19
cgv::os::display
Definition: display.h:74
cgv::os::display_configuration
the display configuration combines a display mode and the position of the display on the virtual scre...
Definition: display.h:46
cgv::os::display::set_position
virtual bool set_position(const display_position &dp)=0
set the display position immediately, return whether this was successful. Only positions that result ...
cgv::os::display::check_refresh_rate
virtual bool check_refresh_rate(unsigned int hz) const =0
check given refresh rate
cgv::os::display::register_mode
virtual bool register_mode(const display_mode &dm)=0
register new display mode, which is activated in the next activate() or activate_all() call
cgv::os::display::get_mode
virtual display_mode get_mode() const =0
return the currently set display mode
cgv::os::display::check_position
virtual bool check_position(const display_position &dp) const =0
check given position
cgv::os::display::~display
virtual ~display()
virtual destructor frees all platform specifically allocated memory
Definition: display.h:95
cgv::os::display::set_resolution
virtual bool set_resolution(unsigned int w, unsigned int h)=0
set new resolution of the display immediately, return whether this was successful....
cgv::os::display_position
the display position gives the signed x and y coordinates on the virtual screen
Definition: display.h:32
cgv
the cgv namespace
Definition: vr_calib.cxx:9
cgv::os::display::register_refresh_rate
virtual bool register_refresh_rate(unsigned int hz)=0
register new refresh rate of the display, which is activated in the next activate() or activate_all()...
cgv::os::display_configuration::mode
display_mode mode
display mode
Definition: display.h:48
cgv::os::display::check_bit_depth
virtual bool check_bit_depth(unsigned int bits) const =0
check given bit depth
cgv::os::display::get_registered_width
virtual unsigned int get_registered_width() const =0
return the registered width (this is changed by prepare_resolution)
cgv::os::display::set_refresh_rate
virtual bool set_refresh_rate(unsigned int hz)=0
set new refresh rate of the display immediately, return whether this was successful....