Tscope5
display.c
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // __ ______
4 // / /_______________ ____ ___ / ____/
5 // / __/ ___/ ___/ __ \/ __ \/ _ \ /___ )
6 // / /_(__ ) /__/ /_/ / /_/ / __/ ____/ /
7 // \__/____/\___/\____/ .___/\___/ /_____/
8 // /_/
9 //
10 /// \file display.c
11 /// Definitions of display functions.
12 /// \example display01.c
13 /// \example display01.cpp
14 /// \example display02.c
15 /// \example display03.c
16 /// \example display04.c
17 /// \example display05.c
18 ////////////////////////////////////////////////////////////////////////////////
19 
20 
21 #include "../include/tscope5/display.h"
22 #include "../include/tscope5/graphics.h"
23 #include "../include/tscope5/bitmaps.h"
24 #include "../include/tscope5/display_internal.h"
25 #include "../include/tscope5/system_internal.h"
26 #include "../include/tscope5/graphics_internal.h"
27 
28 #include <math.h>
29 
30 
31 ////////////////////////////////////////////////////////////////////////////////
32 /// @name Basic operations
33 /// A display can either be a window or a fullscreen display.
34 /// There are three basic display operations:
35 /// - You will need to install a display with ts5_install_display()
36 /// before anything can be drawn.
37 /// - The contents of a display can be cleared with ts5_clear_display().
38 /// - Anything that is drawn on a display only becomes visible
39 /// after a call to ts5_flip_display().
40 //@{
41 ////////////////////////////////////////////////////////////////////////////////
42 
43 
44 ////////////////////////////////////////////////////////////////////////////////
45 /// Open a new display.
46 ///
47 /// \return The index of the new display.
48 ///
49 /// TS5_FULLSCREEN_WINDOW mode:
50 /// - A fullscreen display will be opened using the same
51 /// display size and refreshrate as the desktop.
52 /// - In this mode, the display size, position and refreshrate
53 /// cannot be set by the user. These parameters will be ignored.
54 /// - Tscope5 will check whether the new display is the first
55 /// display on the adapter. If not, the program is aborted.
56 ///
57 /// TS5_FULLSCREEN mode:
58 /// - A fullscreen display will be opened.
59 /// The user can specify the display size and refreshrate.
60 /// - In this mode, the display position cannot be set by the user.
61 /// This parameter will be ignored.
62 /// - Tscope5 will check whether the new display is the
63 /// first display on the adapter. If not, the program is aborted.
64 /// - Tscope5 will check whether the display size and refreshrate is
65 /// supported by the adapter. If not, the program is aborted.
66 /// - A call to ts5_print_status() will list all combinations of
67 /// size and refreshrate that are supported by the adapter.
68 ///
69 /// TS5_WINDOWED mode:
70 /// - Opens a window. The user can specifiy the display size and position.
71 /// - In this mode, the refreshrate cannot be set by the user.
72 /// This parameter will be ignored.
73 /// - Tscope5 will check whether the adapter is already in use by
74 /// a TS5_FULLSCREEN_WINDOW or TS5_FULLSCREEN display.
75 /// If so, the program is aborted.
76 /// - Tscope5 will check whether the window will fit on the display.
77 /// If not, the dimensions of the display are reduced.
78 /// - Tscope5 will check whether the window will be visible on the screen.
79 /// If not, the window position is changed.
80 ///
81 /// The new display is the drawing target for future drawing operations.
82 ////////////////////////////////////////////////////////////////////////////////
84 {
85  ts5_check_display("ts5_install_display");
86 
87  TS5_DISPLAY_STATUS request = ts5_nextdisplay;
88 
89  // TS5_FULLSCREEN_WINDOW
90  if (ts5_nextdisplay.display_mode == TS5_FULLSCREEN_WINDOW) {
91 
92  // the adapter cannot be in use by another tscope5 display
93  int i;
94  for (i = 0; i < _ts5_status.num_displays; i++) {
95 
96  if (_ts5_status.display[i].adapter
97  == ts5_nextdisplay.adapter) {
98  ts5_fatal ("%s: %s, %s (%d)\n", "ts5_install_display",
99  "cannot open fullscreen display",
100  "adapter already in use by another display", i);
101  }
102  }
103 
104  // copy relevant settings
105  request.w = 320;
106  request.h = 240;
107  request.x = -1;
108  request.y = -1;
109  request.refreshrate = -1;
110  request.display_mode = TS5_FULLSCREEN_WINDOW;
111  request.vsync_mode = ts5_nextdisplay.vsync_mode;
112 
113  #ifdef TS5_RASPBERRYPI
114 
115  request.display_mode = TS5_FULLSCREEN;
116  request.w = ts5_get_display_adapter_width(1);
117  request.h = ts5_get_display_adapter_height(1);
118 
119 
120  #endif
121  }
122 
123 
124  // TS5_FULLSCREEN
125  if (ts5_nextdisplay.display_mode == TS5_FULLSCREEN) {
126 
127  // the adapter cannot be in use by another tscope5 display
128  int i;
129  for (i = 0; i < _ts5_status.num_displays; i++) {
130 
131  if (_ts5_status.display[i].adapter
132  == ts5_nextdisplay.adapter) {
133  ts5_fatal ("%s: %s, %s (%d)\n", "ts5_install_display",
134  "cannot open fullscreen display",
135  " adapter already in use by another display", i);
136  }
137  }
138 
139  // is the combination of display size and refresh rate supported by
140  // the adapter?
141  ALLEGRO_DISPLAY_MODE *mode;
142  mode = (ALLEGRO_DISPLAY_MODE *)al_malloc(sizeof(ALLEGRO_DISPLAY_MODE));
143  int nmodes = al_get_num_display_modes();
144  int found=0;
145 
146  for (i=0; i<nmodes; i++) {
147 
148  mode = al_get_display_mode(i, mode);
149 
150  if (mode->width==ts5_nextdisplay.w
151  && mode->height==ts5_nextdisplay.h
152  && (mode->refresh_rate==ts5_nextdisplay.refreshrate
153  || mode->refresh_rate==0)) {
154  found=1;
155  }
156  }
157 
158  al_free(mode);
159 
160  if (!found) {
161  ts5_fatal ("%s: %s (%d, %d) %s (%d) %s %d\n",
162  "ts5_install_display",
163  "the requested combination of size",
165  "and refreshate", ts5_nextdisplay.refreshrate,
166  "is not supported by display adapter",
167  ts5_nextdisplay.adapter);
168  }
169 
170  // copy relevant settings
171  request.w = ts5_nextdisplay.w;
172  request.h = ts5_nextdisplay.h;
173  request.x = -1;
174  request.y = -1;
175  request.refreshrate = ts5_nextdisplay.refreshrate;
176  request.display_mode = TS5_FULLSCREEN;
177  request.vsync_mode = ts5_nextdisplay.vsync_mode;
178  }
179 
180  // TS5_WINDOWED
181  if (ts5_nextdisplay.display_mode == TS5_WINDOWED) {
182 
183  // the adapter cannot be in used by a
184  // TS5_FULLSCREEN_WINDOW or TS5_FULLSCREEN display
185  int i;
186  for (i = 0; i < _ts5_status.num_displays; i++) {
187 
188  if (_ts5_status.display[i].adapter
189  == ts5_nextdisplay.adapter
190  && (_ts5_status.display[i].display_mode
191  == TS5_FULLSCREEN
192  || _ts5_status.display[i].display_mode
193  == TS5_FULLSCREEN_WINDOW)) {
194 
195  ts5_fatal ("%s: %s, %s (%d)\n", "ts5_install_display",
196  "cannot open display",
197  " adapter already in use by a fullscreen display",
198  i);
199  }
200  }
201 
202  // window should be at least 320 pixels wide
203  // and smaller than the width of the monitor
204  if (ts5_nextdisplay.w < 320 ) {
205  request.w = 320;
206  ts5_log(TS5_LOGLEVEL_1, "%s: %s %d (was %d)\n",
207  "ts5_install_display", "adjusting display width to",
208  request.w, ts5_nextdisplay.w);
209  }
210  else if (ts5_nextdisplay.w
211  > _ts5_status.display_adapter
212  [ts5_nextdisplay.adapter].w) {
213 
214  request.w = _ts5_status.display_adapter[ts5_nextdisplay.adapter].w;
215 
216  ts5_log(TS5_LOGLEVEL_1, "%s: %s %d (was %d)\n",
217  "ts5_install_display", "adjusting display width to",
218  request.w, ts5_nextdisplay.w);
219  }
220  else {
221  request.w = ts5_nextdisplay.w;
222  }
223 
224  // window should be at least 240 pixels high
225  // and smaller than the height of the monitor
226  if (ts5_nextdisplay.h < 240 ) {
227  request.h = 240;
228  ts5_log(TS5_LOGLEVEL_1, "%s: %s %d (was %d)\n",
229  "ts5_install_display", "adjusting display height to",
230  request.h, ts5_nextdisplay.h);
231  }
232  else if (ts5_nextdisplay.h
233  > _ts5_status.display_adapter
234  [ts5_nextdisplay.adapter].h) {
235 
236  request.h = _ts5_status.display_adapter
237  [ts5_nextdisplay.adapter].h;
238 
239  ts5_log(TS5_LOGLEVEL_1, "%s: %s %d (was %d)\n",
240  "ts5_install_display", "adjusting display height to",
241  request.h, ts5_nextdisplay.h);
242  }
243  else {
244  request.h = ts5_nextdisplay.h;
245  }
246 
247  request.x = ts5_nextdisplay.x;
248  request.y = ts5_nextdisplay.y;
249 
250  if (request.x == -1) {
251 
252  if (_ts5_status.graphics.coordinate_system
253  == TS5_CARTESIAN_COORDINATES) {
254 
255  request.x = (_ts5_status.display_adapter
256  [request.adapter].w - request.w)/2;
257  }
258  else {
259  request.x = 0;
260  }
261 
262  request.x += _ts5_status.display_adapter[request.adapter].x1;
263  }
264 
265  if (request.y == -1) {
266 
267  if (_ts5_status.graphics.coordinate_system
268  == TS5_CARTESIAN_COORDINATES) {
269 
270  request.y = (_ts5_status.display_adapter
271  [request.adapter].h - request.h)/2;
272  }
273  else {
274  request.y = 0;
275  }
276 
277  request.y += _ts5_status.display_adapter[request.adapter].y1;
278  }
279 
280  // copy relevant settings
281  request.refreshrate = -1;
282  request.display_mode = TS5_WINDOWED;
283  request.vsync_mode = ts5_nextdisplay.vsync_mode;
284  }
285 
286 
287  // pass on display parameters to Allegro
288  al_set_new_display_adapter(request.adapter);
289  al_set_new_display_refresh_rate(request.refreshrate);
290 
291  al_set_new_display_option(ALLEGRO_VSYNC, (int)request.vsync_mode,
292  ALLEGRO_SUGGEST);
293 
294  al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_REQUIRE);
295  al_set_new_display_option(ALLEGRO_SAMPLES, 16, ALLEGRO_SUGGEST);
296  al_set_new_bitmap_flags(ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR);
297 
298  if (request.display_mode == TS5_WINDOWED) {
299  al_set_new_window_position(request.x, request.y);
300  }
301 
302  if (request.display_mode == TS5_FULLSCREEN_WINDOW) {
303  al_set_new_window_position(INT_MAX, INT_MAX);
304  }
305 
306  al_set_new_display_flags(request.display_mode);
307 
308  // update counters
309  _ts5_status.num_displays++;
310  _ts5_status.active_display = _ts5_status.num_displays - 1;
311 
312  // try top open display
313  ts5_log(TS5_LOGLEVEL_1, "ts5_install_display: Opening display\n");
314 
315  TS5_DISPLAY **display;
316  display = al_realloc(_ts5_data.display,
317  _ts5_status.num_displays * sizeof(TS5_DISPLAY *));
318 
319  if (display == NULL) {
320  ts5_fatal("%s: %s\n", "ts5_install_display",
321  "failed to allocate memory for display pointer");
322  }
323 
324  _ts5_data.display = (TS5_DISPLAY **) display;
325 
326  _ts5_data.display[_ts5_status.active_display] =
327  al_create_display(request.w, request.h);
328 
329  if (!_ts5_data.display[_ts5_status.active_display]) {
330  ts5_fatal("ts5_install_display: could not open display\n");
331  }
332 
333  if (ts5_nextdisplay.display_mode == TS5_FULLSCREEN_WINDOW) {
334  request.w = _ts5_status.display_adapter[request.adapter].w;
335  request.h = _ts5_status.display_adapter[request.adapter].h;
336  }
337 
338  // make a display buffer
339  TS5_BITMAP **display_buffer;
340 
341  display_buffer = al_realloc(_ts5_data.display_buffer,
342  _ts5_status.num_displays * sizeof(TS5_BITMAP *));
343 
344  if (display_buffer == NULL) {
345  ts5_fatal("%s: %s\n", "ts5_install_display",
346  "failed to allocate memory for display buffer pointer");
347  }
348 
349  _ts5_data.display_buffer = (TS5_BITMAP **) display_buffer;
350 
351  _ts5_data.display_buffer[_ts5_status.active_display] =
352  al_create_bitmap(request.w, request.h);
353 
354  if (!_ts5_data.display_buffer[_ts5_status.active_display]) {
355  ts5_fatal("ts5_install_display: could not open display buffer\n");
356  }
357 
358 
359  // make a backup of the display buffer
360  TS5_BITMAP **display_backup;
361 
362  display_backup = al_realloc(_ts5_data.display_backup,
363  _ts5_status.num_displays * sizeof(TS5_BITMAP *));
364 
365  if (display_backup == NULL) {
366  ts5_fatal("%s: %s\n", "ts5_install_display",
367  "failed to allocate memory for display backup pointer");
368  }
369 
370  _ts5_data.display_backup = (TS5_BITMAP **) display_backup;
371 
372  _ts5_data.display_backup[_ts5_status.active_display] =
373  al_create_bitmap(request.w, request.h);
374 
375  if (!_ts5_data.display_backup[_ts5_status.active_display]) {
376  ts5_fatal("ts5_install_display: could not open display backup\n");
377  }
378 
379 
380  // copy the settings in the structure
381  TS5_DISPLAY_STATUS *display_status;
382  display_status = al_realloc(_ts5_status.display,
383  _ts5_status.num_displays * sizeof(TS5_DISPLAY_STATUS));
384 
385  if (display_status == NULL) {
386  ts5_fatal("%s: %s\n", "ts5_install_display",
387  "failed to allocate memory for display settings");
388  }
389 
390  _ts5_status.display = (TS5_DISPLAY_STATUS *) display_status;
391 
392  _ts5_status.display[_ts5_status.active_display].adapter =
393  request.adapter;
394 
395  if (request.display_mode==TS5_WINDOWED) {
396 
397  al_get_window_position(_ts5_data.display[_ts5_status.active_display],
398  &request.x, &request.y);
399 
400  if (request.x + request.w
401  > _ts5_status.display_adapter[ts5_nextdisplay.adapter].x2) {
402 
403  int oldw = request.w;
404 
405  request.w = _ts5_status.display_adapter
406  [ts5_nextdisplay.adapter].x2 - request.x;
407 
408  al_resize_display(_ts5_data.display[_ts5_status.active_display],
409  request.w, request.h);
410 
411  ts5_log(TS5_LOGLEVEL_1, "%s: %s %d (was %d)\n",
412  "ts5_install_display", "adjusting display width to",
413  request.w, oldw);
414  }
415 
416  if (request.y + request.h > _ts5_status.display_adapter
417  [ts5_nextdisplay.adapter].y2) {
418 
419  int oldh = request.h;
420 
421  request.h = _ts5_status.display_adapter
422  [ts5_nextdisplay.adapter].y2 - request.y;
423 
424  al_resize_display(_ts5_data.display[_ts5_status.active_display],
425  request.w, request.h);
426 
427  al_set_window_position(_ts5_data.display
428  [_ts5_status.active_display],
429  request.x, request.y + (request.h-oldh));
430 
431  ts5_log(TS5_LOGLEVEL_1, "%s: %s %d (was %d)\n",
432  "ts5_install_display", "adjusting display height to",
433  request.h, oldh);
434 
435  al_get_window_position(
436  _ts5_data.display[_ts5_status.active_display],
437  &request.x, &request.y);
438  }
439 
440  request.x -= _ts5_status.display_adapter[request.adapter].x1;
441  request.y -= _ts5_status.display_adapter[request.adapter].y1;
442 
443  if (_ts5_status.graphics.coordinate_system
444  == TS5_CARTESIAN_COORDINATES) {
445 
446  request.x =
447  request.x
448  - (_ts5_status.display_adapter[request.adapter].w
449  - request.w)/2.0;
450 
451  request.y =
452  (_ts5_status.display_adapter[request.adapter].h
453  - request.h)/2.0
454  - request.y;
455  }
456  }
457 
458  _ts5_status.display[_ts5_status.active_display].x = request.x;
459  _ts5_status.display[_ts5_status.active_display].y = request.y;
460  _ts5_status.display[_ts5_status.active_display].w = request.w;
461  _ts5_status.display[_ts5_status.active_display].h = request.h;
462 
463  _ts5_status.display[_ts5_status.active_display].refreshrate =
464  ts5_nextdisplay.refreshrate;
465 
466  _ts5_status.display[_ts5_status.active_display].display_mode =
467  request.display_mode;
468 
469  _ts5_status.display[_ts5_status.active_display].vsync_mode =
470  request.vsync_mode;
471 
472  // set the new display as the drawing target and clear the display
473  ts5_set_drawing_target(_ts5_data.display_backup
474  [_ts5_status.active_display]);
475  al_clear_to_color(_ts5_status.graphics.background_color);
476 
477  ts5_set_drawing_target(_ts5_data.display_buffer
478  [_ts5_status.active_display]);
479 
480 
481  // clear and flip
482  int i;
483  for(i=0; i<4; i++) {
484  al_flip_display();
485  }
486  _ts5_status.display[_ts5_status.active_display].last_sync = al_get_time();
489 
490  // set atexit and return
491  atexit(ts5_uninstall_displays);
492 
493  return _ts5_status.active_display;
494 }
495 
496 
497 ////////////////////////////////////////////////////////////////////////////////
498 /// Clear the current drawing target.
499 ///
500 /// The drawing target can either be a display or a bitmap (to clear a bitmap:
501 /// set it as drawing target and call ts5_clear_display()).
502 ///
503 /// The background color is controlled by ts5_set_background_color().
504 ////////////////////////////////////////////////////////////////////////////////
506 {
507  ts5_check_display("ts5_clear_display");
508  ts5_log(TS5_LOGLEVEL_5, "ts5_clear_display()\n");
509 
510  if (_ts5_data.target == NULL) {
511  ts5_fatal("ts5_clear_display: target is a NULL pointer\n");
512  }
513 
514  al_clear_to_color(_ts5_status.graphics.background_color);
515 }
516 
517 
518 ////////////////////////////////////////////////////////////////////////////////
519 /// Make what has been drawn visible on the screen.
520 ///
521 /// \return The time when the display flip occurs.
522 ///
523 /// All drawing operations (primitives, text, bitmaps, ...)
524 /// are performed on a back buffer.
525 /// Once you have finished drawing you should call this function
526 /// to make your drawings visible on the screen.
527 /// After a call to this function the back buffer is not cleared.
528 ////////////////////////////////////////////////////////////////////////////////
530 {
531  ts5_check_display("ts5_flip_display");
532  ts5_log(TS5_LOGLEVEL_5, "ts5_flip_display()\n");
533 
534 
535  // if we do not synchronize with _every_ vsync
536  // we need to call al_wait_for_vsync to get in sync again
537  #ifdef TS5_WINDOWS
538  if (al_get_time() - _ts5_status.display[_ts5_status.active_display].last_sync >
539  1.0 / _ts5_status.display[_ts5_status.active_display].refreshrate + 0.003) {
540  al_wait_for_vsync();
541  }
542  #endif
543 
544  // on mac we need another trick for this:
545  // blit the backup of the buffer
546  // then make a new backup of the buffer
547  #ifdef TS5_MACOSX
548  if (al_get_time() - _ts5_status.display[_ts5_status.active_display].last_sync >
549  1.0 / _ts5_status.display[_ts5_status.active_display].refreshrate + 0.003) {
550 
551  al_set_target_backbuffer(_ts5_data.display[_ts5_status.active_display]);
552  al_draw_bitmap(_ts5_data.display_backup[_ts5_status.active_display], 0.0, 0.0, 0);
553  al_flip_display();
554  }
555 
556  al_set_target_bitmap(_ts5_data.display_backup[_ts5_status.active_display]);
557  al_clear_to_color(_ts5_status.graphics.background_color);
558  al_draw_bitmap(_ts5_data.display_buffer[_ts5_status.active_display], 0.0, 0.0, 0);
559  #endif
560 
561 
562  al_set_target_backbuffer(_ts5_data.display[_ts5_status.active_display]);
563  al_draw_bitmap(_ts5_data.display_buffer[_ts5_status.active_display], 0.0, 0.0, 0);
564  al_flip_display();
565 
566  _ts5_status.display[_ts5_status.active_display].last_sync = al_get_time();
567 
568  al_clear_to_color(_ts5_status.graphics.background_color);
569 
570  al_set_target_bitmap(_ts5_data.display_buffer
571  [_ts5_status.active_display]);
572 
573  return _ts5_status.display[_ts5_status.active_display].last_sync;
574 }
575 
576 
577 ////////////////////////////////////////////////////////////////////////////////
578 //@}
579 ////////////////////////////////////////////////////////////////////////////////
580 
581 
582 ////////////////////////////////////////////////////////////////////////////////
583 /// @name Setting the display target
584 /// Tscope5 supports multiple displays
585 /// (each call to ts5_install_display() opens a new display).
586 /// - By default everything is drawn on the display that was opened last.
587 /// - With ts5_set_active_display() you can change the target display.
588 ///
589 /// You can also redirect drawing to memory bitmaps (see bitmaps.c)
590 /// using ts5_set_drawing_target().
591 //@{
592 ////////////////////////////////////////////////////////////////////////////////
593 
594 
595 ////////////////////////////////////////////////////////////////////////////////
596 /// Set the active display.
597 ///
598 /// \param display Index of the display.
599 ///
600 /// \return The index of the previous active display.
601 ///
602 /// The 'active' display is the display that will be used
603 /// for drawing operations.
604 ////////////////////////////////////////////////////////////////////////////////
605 int ts5_set_active_display(const int display)
606 {
607  ts5_check_display2("ts5_set_active_display", display);
608  ts5_log(TS5_LOGLEVEL_4, "ts5_set_active_display(%d)\n", display);
609 
610  int retval = _ts5_status.active_display + 1;
611  _ts5_status.active_display = display - 1;
612  _ts5_data.target = _ts5_data.display_buffer[_ts5_status.active_display];
613  al_set_target_bitmap(_ts5_data.target);
614 
615  _ts5_status.graphics.target_width =
616  al_get_bitmap_width(_ts5_data.target);
617 
618  _ts5_status.graphics.target_height =
619  al_get_bitmap_height(_ts5_data.target);
620 
621  return retval;
622 }
623 
624 
625 ////////////////////////////////////////////////////////////////////////////////
626 /// Get the active display.
627 ///
628 /// \return The index of the active display.
629 ///
630 /// The 'active' display is the display that will be used
631 /// for drawing operations.
632 ////////////////////////////////////////////////////////////////////////////////
634 {
635  ts5_check_display("ts5_get_active_display");
636  ts5_log(TS5_LOGLEVEL_4, "ts5_get_active_display()\n");
637 
638  return _ts5_status.active_display + 1;
639 }
640 
641 
642 ////////////////////////////////////////////////////////////////////////////////
643 //@}
644 ////////////////////////////////////////////////////////////////////////////////
645 
646 
647 ////////////////////////////////////////////////////////////////////////////////
648 /// @name Display adapter settings
649 /// A display adapter is a physical monitor that is attached to the computer.
650 /// Tscope5 supports multiple display adapters.
651 /// Functions are available to query the number and dimensions of
652 /// each display adapter.
653 //@{
654 ////////////////////////////////////////////////////////////////////////////////
655 
656 
657 ////////////////////////////////////////////////////////////////////////////////
658 /// Get the number of display adapters that are connected to the system.
659 ///
660 /// \return The number of display adapters that are connected to the system.
661 ////////////////////////////////////////////////////////////////////////////////
663 {
664  ts5_check_display("ts5_get_num_display_adapters");
665  ts5_log(TS5_LOGLEVEL_4, "ts5_get_num_display_adapters()\n");
666 
667  return _ts5_status.num_display_adapters;
668 }
669 
670 
671 ////////////////////////////////////////////////////////////////////////////////
672 /// Get the size of the monitor attached to a display adapter.
673 ///
674 /// \param adapter Index of the display adapter.
675 /// \param w Variable that will store the width.
676 /// \param h Variable that will store the height.
677 ///
678 /// w and h are the maximum size of a window that can be opened on that adapter.
679 ///
680 /// Pass 0 to get the size of the display adapter for the next display.
681 ///
682 /// You can pass NULL for values you are not interested in.
683 ////////////////////////////////////////////////////////////////////////////////
684 void ts5_get_display_adapter_size(const int adapter, double *w, double *h)
685 {
686  ts5_check_display("ts5_get_display_adapter_size");
687  ts5_log(TS5_LOGLEVEL_4, "ts5_get_display_adapter_size(%d,%f,%f)\n",
688  adapter, w, h);
689 
690  double ww, hh;
691 
692  if (adapter < 0) {
693  ts5_fatal("ts5_get_display_adapter_size: adapter index not valid\n");
694  }
695  else if (adapter == 0) {
696  ww = _ts5_status.display_adapter[ts5_nextdisplay.adapter].w;
697  hh = _ts5_status.display_adapter[ts5_nextdisplay.adapter].h;
698  }
699  else if (adapter <= _ts5_status.num_display_adapters) {
700  ww = _ts5_status.display_adapter[adapter-1].w;
701  hh = _ts5_status.display_adapter[adapter-1].h;
702  }
703  else {
704  ts5_fatal("ts5_get_display_adapter_size: adapter index not valid\n");
705  }
706 
707  if (w) {
708  *w = ww;
709  }
710 
711  if (h) {
712  *h = hh;
713  }
714 }
715 
716 
717 ////////////////////////////////////////////////////////////////////////////////
718 /// Get the width of the monitor attached to a display adapter.
719 ///
720 /// \param adapter Index of the display adapter.
721 ///
722 /// \return the width of the display adapter.
723 ///
724 /// Pass 0 to get the width of the display adapter for the next display.
725 ////////////////////////////////////////////////////////////////////////////////
726 double ts5_get_display_adapter_width(const int adapter)
727 {
728  ts5_check_display("ts5_get_display_adapter_width");
729  ts5_log(TS5_LOGLEVEL_4, "ts5_get_display_adapter_width(%d)\n", adapter);
730 
731  double w;
732  ts5_get_display_adapter_size(adapter, &w, NULL);
733 
734  return w;
735 }
736 
737 
738 ////////////////////////////////////////////////////////////////////////////////
739 /// Get the heigth of the monitor attached to a display adapter.
740 ///
741 /// \param adapter Index of the display adapter.
742 ///
743 /// \return the height of the display adapter.
744 ///
745 /// Pass 0 to get the height of the display adapter for the next display.
746 ////////////////////////////////////////////////////////////////////////////////
747 double ts5_get_display_adapter_height(const int adapter)
748 {
749  ts5_check_display("ts5_get_display_adapter_height");
750  ts5_log(TS5_LOGLEVEL_4, "ts5_get_display_adapter_height(%d)\n", adapter);
751 
752  double h;
753  ts5_get_display_adapter_size(adapter, NULL, &h);
754 
755  return h;
756 }
757 
758 
759 ////////////////////////////////////////////////////////////////////////////////
760 //@}
761 ////////////////////////////////////////////////////////////////////////////////
762 
763 
764 ////////////////////////////////////////////////////////////////////////////////
765 /// @name Display settings
766 /// Before opening a display various settings can be requested
767 /// using the functions below.
768 /// Once a display is opened the settings remain until the end of the program.
769 //@{
770 ////////////////////////////////////////////////////////////////////////////////
771 
772 
773 ////////////////////////////////////////////////////////////////////////////////
774 /// Set the display adapter for the next display that will be opened.
775 ///
776 /// \param adapter Index of the active display adapter.
777 ///
778 /// \return The index of the previous active display adapter.
779 ///
780 /// A display adapter corresponds to a physical display that is
781 /// attached to the computer.
782 /// The first adapter has index 1, etc.
783 ///
784 /// The display is attached to adapter 1 by default.
785 ////////////////////////////////////////////////////////////////////////////////
786 int ts5_set_display_adapter(const int adapter)
787 {
788  ts5_check_display("ts5_set_display_adapter");
789  ts5_log(TS5_LOGLEVEL_4, "ts5_set_display_adapter(%d)\n", adapter);
790 
791  int retval = ts5_nextdisplay.adapter + 1;
792 
793  if (adapter > 0 && adapter <= _ts5_status.num_display_adapters) {
794  ts5_nextdisplay.adapter = adapter - 1;
795  ts5_log(TS5_LOGLEVEL_4, "%s: %s %d (was %d)\n",
796  "ts5_set_display_adapter",
797  "set display adapter for next display to",
798  retval-1, ts5_nextdisplay.adapter+1);
799  }
800  else {
801  ts5_fatal ("ts5_set_display_adapter: adapter index not valid\n");
802  }
803 
804  return retval;
805 }
806 
807 
808 ////////////////////////////////////////////////////////////////////////////////
809 /// Get the index of the display adapter of a display.
810 ///
811 /// \param display Index of the display.
812 ///
813 /// \return The index of the adapter that the display is attached to.
814 ///
815 /// Pass 0 to get the index of the display adapter for the next display.
816 ////////////////////////////////////////////////////////////////////////////////
817 int ts5_get_display_adapter(const int display)
818 {
819  ts5_check_display2("ts5_get_display_adapter", display);
820  ts5_log(TS5_LOGLEVEL_4, "ts5_get_display_adapter(%d)\n", display);
821 
822  int retval;
823 
824  if (display == 0) {
825  retval = ts5_nextdisplay.adapter + 1;
826  }
827  else {
828  retval = _ts5_status.display[display-1].adapter + 1;
829  }
830 
831  return retval;
832 }
833 
834 
835 ////////////////////////////////////////////////////////////////////////////////
836 /// Set the size of the next display.
837 ///
838 /// \param w Width of the next display in pixels.
839 /// \param h Height of the next display in pixels.
840 ///
841 /// The default width and height is 320 x 240. This is also the minimum.
842 ////////////////////////////////////////////////////////////////////////////////
843 void ts5_set_display_size(double w, double h)
844 {
845  ts5_check_display("ts5_set_display_size");
846  ts5_log(TS5_LOGLEVEL_4, "ts5_set_display_size(%f,%f)\n", w, h);
847 
848  int oldw = ts5_nextdisplay.w;
849  int oldh = ts5_nextdisplay.h;
850 
851  if (_ts5_status.graphics.coordinate_scale
852  == TS5_RELATIVE_COORDINATES) {
853  w *= _ts5_status.display_adapter[ts5_nextdisplay.adapter].w;
854  h *= _ts5_status.display_adapter[ts5_nextdisplay.adapter].h;
855  }
856 
857  ts5_nextdisplay.w = w;
858  ts5_nextdisplay.h = h;
859 
860  ts5_log(TS5_LOGLEVEL_4, "%s: %s %d x %d (was %d x %d)\n",
861  "ts5_set_display_size",
862  "set display size for next display to",
863  ts5_nextdisplay.w, ts5_nextdisplay.h, oldw, oldh);
864 }
865 
866 
867 ////////////////////////////////////////////////////////////////////////////////
868 /// Get the size of a display.
869 ///
870 /// \param display Index of the display.
871 /// \param w Variable that will store the width.
872 /// \param h Variable that will store the height.
873 ///
874 /// Set display to 0 to get the width of the next display.
875 ///
876 /// You can pass NULL for values you are not interested in.
877 ////////////////////////////////////////////////////////////////////////////////
878 void ts5_get_display_size(const int display, double *w, double *h)
879 {
880  ts5_check_display2("ts5_get_display_size", display);
881  ts5_log(TS5_LOGLEVEL_4, "ts5_get_display_size(%d,%p,%p)\n", display, w, h);
882 
883  double ww, hh;
884 
885  if (display == 0) {
886  ww = ts5_nextdisplay.w;
887  hh = ts5_nextdisplay.h;
888  }
889  else {
890  ww = _ts5_status.display[display-1].w;
891  hh = _ts5_status.display[display-1].h;
892  }
893 
894  if (w) {
895  *w = ww;
896  }
897 
898  if (h) {
899  *h = hh;
900  }
901 }
902 
903 
904 ////////////////////////////////////////////////////////////////////////////////
905 /// Get the width of a display.
906 ///
907 /// \param display Index of the display.
908 ///
909 /// \return the width of the display.
910 ///
911 /// Set display to 0 to get the width of the next display.
912 ////////////////////////////////////////////////////////////////////////////////
913 double ts5_get_display_width(const int display)
914 {
915  ts5_check_display2("ts5_get_display_width", display);
916  ts5_log(TS5_LOGLEVEL_4, "ts5_get_display_width(%d)\n", display);
917 
918  double w;
919  ts5_get_display_size(display, &w, NULL);
920 
921  return w;
922 }
923 
924 
925 ////////////////////////////////////////////////////////////////////////////////
926 /// Get the height of a display.
927 ///
928 /// \param display Index of the display.
929 ///
930 /// \return the height of the display.
931 ///
932 /// Set display to 0 to get the height of the next display.
933 ////////////////////////////////////////////////////////////////////////////////
934 double ts5_get_display_height(const int display)
935 {
936  ts5_check_display2("ts5_get_display_height", display);
937  ts5_log(TS5_LOGLEVEL_4, "ts5_get_display_height(%d)\n", display);
938 
939  double h;
940  ts5_get_display_size(display, NULL, &h);
941 
942  return h;
943 }
944 
945 
946 ////////////////////////////////////////////////////////////////////////////////
947 /// Set the position of the next display.
948 ///
949 /// \param x Horizontal position of the display on the desktop.
950 /// \param y Vertical position of the display on the desktop.
951 ///
952 /// Only meaningful for non-fullscreen displays.
953 ///
954 /// CARTESIAN coordinates: Center of the display is the origin,
955 /// default position is the center of the display.
956 ///
957 /// COMPUTER coordinates: The upper left corner of the display is the origin,
958 /// default position is top left corner of the display.
959 ////////////////////////////////////////////////////////////////////////////////
960 void ts5_set_display_position(double x, double y)
961 {
962  ts5_check_display("ts5_set_display_position");
963  ts5_log(TS5_LOGLEVEL_4, "ts5_set_display_position(%f,%f)\n", x, y);
964 
965  int oldx = ts5_nextdisplay.x;
966  int oldy = ts5_nextdisplay.y;
967 
968  if (_ts5_status.graphics.coordinate_scale
969  == TS5_RELATIVE_COORDINATES) {
970 
971  if (_ts5_status.graphics.coordinate_system
972  == TS5_CARTESIAN_COORDINATES) {
973 
974  x *= _ts5_status.display_adapter[ts5_nextdisplay.adapter].w
975  / 2.0;
976 
977  y *= _ts5_status.display_adapter[ts5_nextdisplay.adapter].h
978  / 2.0;
979  }
980  else {
981  x *= _ts5_status.display_adapter[ts5_nextdisplay.adapter].w;
982  y *= _ts5_status.display_adapter[ts5_nextdisplay.adapter].h;
983  }
984  }
985 
986  if (_ts5_status.graphics.coordinate_system
987  == TS5_CARTESIAN_COORDINATES) {
988 
989  x += _ts5_status.display_adapter[ts5_nextdisplay.adapter].w/2.0;
990  x -= ts5_nextdisplay.w/2.0;
991  y = -y;
992  y += _ts5_status.display_adapter[ts5_nextdisplay.adapter].h/2.0;
993  y -= ts5_nextdisplay.h/2.0;
994  }
995 
996  x += _ts5_status.display_adapter[ts5_nextdisplay.adapter].x1;
997  y += _ts5_status.display_adapter[ts5_nextdisplay.adapter].y1;
998 
999  ts5_nextdisplay.x = x;
1000  ts5_nextdisplay.y = y;
1001 
1002  ts5_log(TS5_LOGLEVEL_4, "%s: %s (%d,%d) (was (%d,%d))\n",
1003  "ts5_set_display_position",
1004  "set display position for next display to",
1006  oldx, oldy);
1007 }
1008 
1009 
1010 ////////////////////////////////////////////////////////////////////////////////
1011 /// Get the position of a display.
1012 ///
1013 /// \param display Index of the display.
1014 /// \param x Variable that will store the horizontal position.
1015 /// \param y Variable that will store the vertical position.
1016 ///
1017 /// Only meaningful for non-fullscreen displays.
1018 ///
1019 /// Set display to 0 to get the x position of the next display.
1020 ///
1021 /// You can pass NULL for values you are not interested in.
1022 ////////////////////////////////////////////////////////////////////////////////
1023 void ts5_get_display_position(const int display, double *x, double *y)
1024 {
1025  ts5_check_display2("ts5_get_display_position", display);
1026  ts5_log(TS5_LOGLEVEL_4, "ts5_get_display_position(%d,%p,%p)\n",
1027  display, x, y);
1028 
1029  double xx, yy;
1030  double dw, dh, aw, ah;
1031 
1032  // get the values we need
1033  if (display != 0) {
1034 
1035  int adapter = ts5_get_display_adapter(display);
1036  al_get_window_position(_ts5_data.display[display-1],
1037  &_ts5_status.display[display-1].x,
1038  &_ts5_status.display[display-1].y);
1039 
1040  xx = _ts5_status.display[display-1].x;
1041  yy = _ts5_status.display[display-1].y;
1042 
1043  xx -= _ts5_status.display_adapter[adapter-1].x1;
1044  yy -= _ts5_status.display_adapter[adapter-1].y1;
1045 
1046  dw = _ts5_status.display[display-1].w;
1047  dh = _ts5_status.display[display-1].h;
1048 
1049  aw = _ts5_status.display_adapter[adapter-1].w;
1050  ah = _ts5_status.display_adapter[adapter-1].h;
1051  }
1052  else {
1053 
1054  xx = ts5_nextdisplay.x;
1055  yy = ts5_nextdisplay.y;
1056 
1057  dw = ts5_nextdisplay.w;
1058  dh = ts5_nextdisplay.h;
1059 
1060  aw = _ts5_status.display_adapter[ts5_nextdisplay.adapter].w;
1061  ah = _ts5_status.display_adapter[ts5_nextdisplay.adapter].h;
1062  }
1063 
1064  // if the settings are not default, compute xx and yy
1065  if (xx!=-1 && yy!=-1) {
1066 
1067 
1068  // convert to cartesian if necessary
1069  if (_ts5_status.graphics.coordinate_system
1070  == TS5_CARTESIAN_COORDINATES) {
1071  xx = xx + dw/2.0 - aw/2.0;
1072  yy = ah/2.0 - yy - dh/2.0;
1073  }
1074 
1075  // convert to relative if necessary
1076  if (_ts5_status.graphics.coordinate_scale
1077  == TS5_RELATIVE_COORDINATES) {
1078 
1079  if (_ts5_status.graphics.coordinate_system
1080  == TS5_CARTESIAN_COORDINATES) {
1081  xx /= aw/2.0;
1082  yy /= ah/2.0;
1083  }
1084  else {
1085  xx /= aw;
1086  yy /= ah;
1087  }
1088  }
1089  }
1090 
1091  if (x) {
1092  *x = xx;
1093  }
1094 
1095  if (y) {
1096  *y = yy;
1097  }
1098 
1099 
1100 }
1101 
1102 
1103 ////////////////////////////////////////////////////////////////////////////////
1104 /// Get the horizontal position of a display.
1105 ///
1106 /// \param display Index of the display.
1107 ///
1108 /// \return
1109 /// The horizontal position of the display.
1110 ////////////////////////////////////////////////////////////////////////////////
1111 double ts5_get_display_x(const int display)
1112 {
1113  ts5_check_display2("ts5_get_display_x", display);
1114  ts5_log(TS5_LOGLEVEL_4, "ts5_get_display_x(%d)\n", display);
1115 
1116  double x;
1117  ts5_get_display_position(display, &x, NULL);
1118 
1119  return x;
1120 }
1121 
1122 
1123 ////////////////////////////////////////////////////////////////////////////////
1124 /// Get the vertical position of a display.
1125 ///
1126 /// \param display Index of the display.
1127 ///
1128 /// \return
1129 /// The vertical position of the display.
1130 ////////////////////////////////////////////////////////////////////////////////
1131 double ts5_get_display_y(const int display)
1132 {
1133  ts5_check_display2("ts5_get_display_y", display);
1134  ts5_log(TS5_LOGLEVEL_4, "ts5_get_display_y(%d)\n", display);
1135 
1136  double y;
1137  ts5_get_display_position(display, NULL, &y);
1138 
1139  return y;
1140 }
1141 
1142 
1143 
1144 
1145 ////////////////////////////////////////////////////////////////////////////////
1146 /// Set the requested refreshrate for the next display.
1147 ///
1148 /// \param rate Refreshrate in cycles per second.
1149 ///
1150 /// \return The previous refresh rate.
1151 ///
1152 /// The refreshrate can only be changed for real fullscreen displays.
1153 ///
1154 /// Even then this is only a request.
1155 ///
1156 /// The default value 0 (let the system choose).
1157 ////////////////////////////////////////////////////////////////////////////////
1158 int ts5_set_refreshrate(const int rate)
1159 {
1160  ts5_check_display("ts5_set_refreshrate");
1161  ts5_log(TS5_LOGLEVEL_4, "ts5_set_refreshrate(%d)\n", rate);
1162 
1163  int retval = ts5_nextdisplay.refreshrate;
1164 
1165  ts5_nextdisplay.refreshrate = rate;
1166 
1167  ts5_log(TS5_LOGLEVEL_4, "%s: %s %d (was %d)\n", "ts5_set_refreshrate",
1168  "set refreshrate for next display to",
1169  ts5_nextdisplay.refreshrate, retval);
1170 
1171  return retval;
1172 }
1173 
1174 
1175 ////////////////////////////////////////////////////////////////////////////////
1176 /// Get the refreshrate of a display.
1177 ///
1178 /// \param display Index of the display.
1179 ///
1180 /// \return The refresh rate of the display.
1181 ///
1182 /// Set display to 0 to get the refreshrate of the next display.
1183 ////////////////////////////////////////////////////////////////////////////////
1184 int ts5_get_refreshrate(const int display)
1185 {
1186  ts5_check_display2("ts5_get_refreshrate", display);
1187  ts5_log(TS5_LOGLEVEL_4, "ts5_get_refreshrate(%d)\n", display);
1188 
1189  int retval;
1190 
1191  if (display == 0) {
1192  retval = ts5_nextdisplay.refreshrate;
1193  }
1194  else {
1195  retval = _ts5_status.display[display-1].refreshrate;
1196  }
1197 
1198  return retval;
1199 }
1200 
1201 
1202 ////////////////////////////////////////////////////////////////////////////////
1203 /// Set the display mode for the next display.
1204 ///
1205 /// \param mode Window mode.
1206 /// Can be TS5_WINDOWED, TS5_FULLSCREEN or TS5_FULLSCREEN_WINDOW.
1207 ///
1208 /// \return The previous display mode.
1209 ///
1210 /// In TS5_WINDOWED mode the window can have any dimension that
1211 /// will fit on the physical display
1212 /// and the position of the window on the display can be adjusted.
1213 /// Multiple TS5_WINDOWED displays can be combined on one physical display.
1214 /// The refreshrate is always the refreshrate of the physical display.
1215 ///
1216 /// In TS5_FULLSCREEN_WINDOW mode the display always has the dimension
1217 /// of the desktop.
1218 /// The refreshrate is always the refreshrate of the physical display.
1219 /// Only one TS5_FULLSCREEN_WINDOW display can be used
1220 /// per physical display.
1221 ///
1222 /// TS5_FULLSCREEN modes are the most flexible:
1223 /// any combination of display dimension and refreshrate
1224 /// that is supported by the monitor can be set.
1225 /// Does not seem to work on Mac OS X.
1226 ///
1227 /// The default window mode is TS5_WINDOWED.
1228 ////////////////////////////////////////////////////////////////////////////////
1229 int ts5_set_display_mode(const int mode)
1230 {
1231  ts5_check_display("ts5_set_display_mode");
1232  ts5_log(TS5_LOGLEVEL_4, "ts5_set_display_mode(%d)\n", mode);
1233 
1234  int retval = ts5_nextdisplay.display_mode;
1235 
1236  if (mode != TS5_WINDOWED
1237  && mode != TS5_FULLSCREEN
1238  && mode != TS5_FULLSCREEN_WINDOW) {
1239  ts5_fatal ("%s: %s (%d)\n", "ts5_set_display_mode",
1240  "requested display mode not available", mode);
1241  }
1242 
1243  ts5_nextdisplay.display_mode = mode;
1244 
1245  ts5_log(TS5_LOGLEVEL_4, "%s: %s %d (was %d)\n", "ts5_set_display_mode",
1246  "set display mode for next display to",
1247  ts5_nextdisplay.display_mode, retval);
1248 
1249  return retval;
1250 }
1251 
1252 
1253 ////////////////////////////////////////////////////////////////////////////////
1254 /// Get the display mode of a display.
1255 ///
1256 /// \param display Index of the display.
1257 ///
1258 /// \return The window mode of the display.
1259 ///
1260 /// Set display to 0 to get the display mode of the next display.
1261 ////////////////////////////////////////////////////////////////////////////////
1262 int ts5_get_display_mode(const int display)
1263 {
1264  ts5_check_display2("ts5_get_display_mode", display);
1265  ts5_log(TS5_LOGLEVEL_4, "ts5_get_display_mode(%d)\n", display);
1266 
1267  int retval;
1268 
1269  if (display == 0) {
1270  retval = ts5_nextdisplay.display_mode;
1271  }
1272  else {
1273  retval = _ts5_status.display[display-1].display_mode;
1274  }
1275 
1276  return retval;
1277 }
1278 
1279 
1280 ////////////////////////////////////////////////////////////////////////////////
1281 /// Set the vsync mode for the next display.
1282 ///
1283 /// \param mode Vsync mode.
1284 /// Can be TS5_VSYNC_WHATEVER, TS5_VSYNC_ON or TS5_VSYNC_OFF.
1285 ///
1286 /// \return The previous vsync mode.
1287 ///
1288 /// The default vsync mode is TS5_VSYNC_ON.
1289 ////////////////////////////////////////////////////////////////////////////////
1290 int ts5_set_vsync_mode(const int mode)
1291 {
1292  ts5_check_display("ts5_set_vsync_mode");
1293  ts5_log(TS5_LOGLEVEL_4, "ts5_set_vsync_mode(%d)\n", mode);
1294 
1295  int retval = ts5_nextdisplay.vsync_mode;
1296 
1297  if (mode < TS5_VSYNC_WHATEVER || mode > TS5_VSYNC_OFF) {
1298  ts5_fatal("ts5_set_vsync_mode: mode should be 0, 1 or 2 (is %d)\n",
1299  mode);
1300  }
1301 
1302  ts5_nextdisplay.vsync_mode = mode;
1303 
1304  ts5_log(TS5_LOGLEVEL_4, "%s: %s %d (was %d)\n", "ts5_set_vsync_mode",
1305  "set vsync mode for next display to",
1306  ts5_nextdisplay.vsync_mode, retval);
1307 
1308  return retval;
1309 }
1310 
1311 
1312 ////////////////////////////////////////////////////////////////////////////////
1313 /// Get the vsync mode of a display.
1314 ///
1315 /// \param display Index of the display.
1316 ///
1317 /// \return The vsync mode of the display.
1318 ///
1319 /// Set display to 0 to get the requested vsync mode for the next display.
1320 ////////////////////////////////////////////////////////////////////////////////
1321 int ts5_get_vsync_mode(const int display)
1322 {
1323  ts5_check_display2("ts5_get_vsync_mode", display);
1324  ts5_log(TS5_LOGLEVEL_4, "ts5_get_vsync_mode(%d)\n", display);
1325 
1326  int retval;
1327 
1328  if (display == 0) {
1329  retval = ts5_nextdisplay.vsync_mode;
1330  }
1331  else {
1332  retval = _ts5_status.display[display-1].vsync_mode;
1333  }
1334 
1335  return retval;
1336 }
1337 
1338 
1339 ////////////////////////////////////////////////////////////////////////////////
1340 //@}
1341 ////////////////////////////////////////////////////////////////////////////////
double ts5_get_display_adapter_width(const int adapter)
Get the width of the monitor attached to a display adapter.
Definition: display.c:726
int ts5_get_vsync_mode(const int display)
Get the vsync mode of a display.
Definition: display.c:1321
void ts5_check_display(char *calling_function)
Do some checks at the start of each display function.
int ts5_set_display_mode(const int mode)
Set the display mode for the next display.
Definition: display.c:1229
TS5_DISPLAY_STATUS ts5_nextdisplay
Settings for the next display that will be opened.
void ts5_check_display2(char *calling_function, const int display)
Do some checks at the start of each display function.
int ts5_get_num_display_adapters()
Get the number of display adapters that are connected to the system.
Definition: display.c:662
double ts5_flip_display()
Make what has been drawn visible on the screen.
Definition: display.c:529
int ts5_set_active_display(const int display)
Set the active display.
Definition: display.c:605
int ts5_set_vsync_mode(const int mode)
Set the vsync mode for the next display.
Definition: display.c:1290
void ts5_get_display_adapter_size(const int adapter, double *w, double *h)
Get the size of the monitor attached to a display adapter.
Definition: display.c:684
TS5_BITMAP * ts5_set_drawing_target(TS5_BITMAP *target)
Set the active drawing target.
Definition: bitmaps.c:243
void ts5_get_display_position(const int display, double *x, double *y)
Get the position of a display.
Definition: display.c:1023
int ts5_get_display_mode(const int display)
Get the display mode of a display.
Definition: display.c:1262
int ts5_install_display()
Open a new display.
Definition: display.c:83
void ts5_uninstall_displays()
Close all open displays.
double ts5_get_display_x(const int display)
Get the horizontal position of a display.
Definition: display.c:1111
void ts5_set_display_size(double w, double h)
Set the size of the next display.
Definition: display.c:843
int ts5_get_active_display()
Get the active display.
Definition: display.c:633
double ts5_get_display_adapter_height(const int adapter)
Get the heigth of the monitor attached to a display adapter.
Definition: display.c:747
void ts5_log(const unsigned int level, const char *format,...)
Send info to a logging window.
Definition: system.c:45
int ts5_get_refreshrate(const int display)
Get the refreshrate of a display.
Definition: display.c:1184
void ts5_clear_display()
Clear the current drawing target.
Definition: display.c:505
double ts5_get_display_width(const int display)
Get the width of a display.
Definition: display.c:913
void ts5_set_display_position(double x, double y)
Set the position of the next display.
Definition: display.c:960
int ts5_set_refreshrate(const int rate)
Set the requested refreshrate for the next display.
Definition: display.c:1158
double ts5_get_display_height(const int display)
Get the height of a display.
Definition: display.c:934
void ts5_fatal(const char *format,...)
Exit safely with an error message.
Definition: system.c:529
void ts5_get_display_size(const int display, double *w, double *h)
Get the size of a display.
Definition: display.c:878
double ts5_get_display_y(const int display)
Get the vertical position of a display.
Definition: display.c:1131
int ts5_set_display_adapter(const int adapter)
Set the display adapter for the next display that will be opened.
Definition: display.c:786
int ts5_get_display_adapter(const int display)
Get the index of the display adapter of a display.
Definition: display.c:817