Merge branch 'rr1-maint'
[lsnes.git] / src / core / dummygraphics.cpp
blob2445747fd0d3dc7485bea4bac26cccac5540f17a
1 #define GRAPHICS_WEAK
2 #include "core/window.hpp"
4 #include <cstdlib>
5 #include <iostream>
7 namespace
9 uint64_t next_message_to_print = 0;
10 bool is_dummy = true;
12 void dummy_init() throw()
14 platform::pausing_allowed = false;
17 void dummy_quit() throw()
21 void dummy_notify_message() throw()
23 //Read without lock becase we run in the same thread.
24 while(platform::msgbuf.get_msg_first() + platform::msgbuf.get_msg_count() > next_message_to_print) {
25 if(platform::msgbuf.get_msg_first() > next_message_to_print)
26 next_message_to_print = platform::msgbuf.get_msg_first();
27 else
28 std::cout << platform::msgbuf.get_message(next_message_to_print++) << std::endl;
32 void dummy_notify_status() throw()
36 void dummy_notify_screen() throw()
40 bool dummy_modal_message(const std::string& text, bool confirm) throw()
42 std::cerr << "Modal message: " << text << std::endl;
43 return confirm;
46 void dummy_fatal_error() throw()
48 std::cerr << "Exiting on fatal error." << std::endl;
51 const char* dummy_name() { return "Dummy graphics plugin"; }
53 struct _graphics_driver driver = {
54 .init = dummy_init,
55 .quit = dummy_quit,
56 .notify_message = dummy_notify_message,
57 .notify_status = dummy_notify_status,
58 .notify_screen = dummy_notify_screen,
59 .modal_message = dummy_modal_message,
60 .fatal_error = dummy_fatal_error,
61 .name = dummy_name
66 graphics_driver::graphics_driver(_graphics_driver drv)
68 driver = drv;
69 is_dummy = false;
72 bool graphics_driver_is_dummy()
74 return is_dummy;
77 void graphics_driver_init() throw()
79 driver.init();
82 void graphics_driver_quit() throw()
84 driver.quit();
87 void graphics_driver_notify_message() throw()
89 driver.notify_message();
92 void graphics_driver_notify_status() throw()
94 driver.notify_status();
97 void graphics_driver_notify_screen() throw()
99 driver.notify_screen();
102 bool graphics_driver_modal_message(const std::string& text, bool confirm) throw()
104 return driver.modal_message(text, confirm);
107 void graphics_driver_fatal_error() throw()
109 driver.fatal_error();
112 const char* graphics_driver_name()
114 return driver.name();