cgv
Loading...
Searching...
No Matches
display.h
1#pragma once
2
3#include <vector>
4#include <iostream>
5
6#include "lib_begin.h"
7
8namespace 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
28extern 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
42extern CGV_API std::ostream& operator << (std::ostream& os, const display_position& dp);
43
55
57extern CGV_API std::ostream& operator << (std::ostream& os, const display_configuration& dc);
58
60enum DisplayScanMode
61{
62 DSM_ALL = 0,
63 DSM_PHYSICAL = 1,
64 DSM_ACTIVE = 2,
65 DSM_PASSIVE = 4
66};
67
73class CGV_API display
74{
75public:
79 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
100 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
108 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
122 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
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
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
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
220extern CGV_API std::ostream& operator << (std::ostream& os, const display& disp);
221
222 }
223}
224
225#include <cgv/config/lib_end.h>
the display class gives access to the display modes of all available displays.
Definition display.h:74
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...
virtual unsigned int get_height() const =0
return the current height (only defined if display is active)
virtual display_mode get_registered_mode() const =0
return the display mode registered in the registry
virtual bool check_position(unsigned int x, unsigned int y) const =0
check given position
virtual display_configuration get_configuration() const =0
return the current display configuration
virtual unsigned int get_registered_width() const =0
return the registered width (this is changed by prepare_resolution)
virtual bool set_refresh_rate(unsigned int hz)=0
set new refresh rate of the display immediately, return whether this was successful....
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...
virtual bool make_primary()=0
make this display the primary display
static std::string last_error
if one of the methods return false, this static member gives textual information about the reason
Definition display.h:79
virtual unsigned int get_width() const =0
return the current width (only defined if display is active)
virtual unsigned int get_registered_refresh_rate() const =0
return the registered refresh rate in Hz (this is changed by prepare_refresh_rate)
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...
virtual bool is_removable() const =0
return whether display is removable
virtual bool deactivate()=0
deactivate the display, return whether deactivation was successful
virtual int get_y() const =0
return the current current y coordinate within the virtual screen spanned by the desktop (only define...
virtual bool is_mirror() const =0
return whether display is a mirrored display
virtual bool register_position(const display_position &dp)=0
register new position immediately, which is activated in the next activate() or activate_all() call
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()...
virtual display_mode get_mode() const =0
return the currently set display mode
virtual std::string get_name() const =0
return the name of the display
virtual bool set_configuration(const display_configuration &dc)=0
set the display configuration immediately, return whether this was successful.
virtual void enumerate_display_modes(std::vector< display_mode > &display_modes, bool compatible_with_attached_monitor=true)=0
enumerate all available display modes. If the display is active only the display modes supported by t...
virtual bool can_be_primary() const =0
check if this display can be made primary
virtual ~display()
virtual destructor frees all platform specifically allocated memory
Definition display.h:95
virtual bool is_primary() const =0
return whether display is the primary display
virtual bool register_mode(const display_mode &dm)=0
register new display mode, which is activated in the next activate() or activate_all() call
virtual bool check_activate() const =0
check if activation of the registered settings will work
virtual bool check_configuration(const display_configuration &dc) const =0
check given display configuration
virtual bool activate()=0
activate the display based on the registered settings or change the current display settings to the r...
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)
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...
virtual bool check_mode(const display_mode &dm) const =0
check given display mode
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...
virtual std::string get_ID() const =0
return the unique ID string of the display
virtual unsigned int get_bit_depth() const =0
return the current bit depth of the display pixels (only defined if display is active)
virtual int get_x() const =0
return the current current x coordinate within the virtual screen spanned by the desktop (only define...
virtual bool check_refresh_rate(unsigned int hz) const =0
check given refresh rate
virtual bool check_position(const display_position &dp) const =0
check given position
virtual bool check_bit_depth(unsigned int bits) const =0
check given bit depth
virtual bool set_position(const display_position &dp)=0
set the display position immediately, return whether this was successful. Only positions that result ...
virtual bool check_resolution(unsigned int w, unsigned int h) const =0
check given resolution
virtual unsigned int get_registered_height() const =0
return the registered height (this is changed by prepare_resolution)
virtual display_position get_position() const =0
return the current display position
virtual void show_display_modes(bool compatible_with_attached_monitor=true)=0
print out all available display modes
virtual bool set_mode(const display_mode &dm)=0
set the given display mode immediately, return whether this was successful. Only valid display modes ...
virtual bool is_active() const =0
return whether display is active
virtual bool set_resolution(unsigned int w, unsigned int h)=0
set new resolution of the display immediately, return whether this was successful....
virtual std::string get_description() const =0
return the description string of the display
virtual unsigned int get_refresh_rate() const =0
return the current refresh rate in Hz (only defined if display is active)
virtual bool register_configuration(const display_configuration &dc)=0
register new display configuration, which is activated in the next activate() or activate_all() call
the cgv namespace
Definition print.h:11
the display configuration combines a display mode and the position of the display on the virtual scre...
Definition display.h:46
display_configuration(const display_mode &dm=display_mode(), const display_position &dp=display_position())
constructor
Definition display.h:52
display_mode mode
display mode
Definition display.h:48
display_position position
display position
Definition display.h:50
a display mode describes a valid setting of the display parameters
Definition display.h:13
display_mode(unsigned int w=1024, unsigned int h=768, unsigned int bd=32, unsigned int rr=60)
constructor
Definition display.h:23
unsigned int height
height in pixel
Definition display.h:17
unsigned int refresh_rate
refresh rate in Hz
Definition display.h:21
unsigned int width
width in pixel
Definition display.h:15
unsigned int bit_depth
number of bits per pixel
Definition display.h:19
the display position gives the signed x and y coordinates on the virtual screen
Definition display.h:32
int y
signed y position on virtual screen
Definition display.h:36
int x
signed x position on virtual screen
Definition display.h:34
display_position(int _x=0, int _y=0)
constructor
Definition display.h:38