lsnes rr2-β24
[lsnes.git] / src / core / dummygraphics.cpp
blob6ec055f7aadfe997567e3890577ecbcfe03533d7
1 #include "core/window.hpp"
3 #include <cstdlib>
4 #include <iostream>
6 namespace
8 uint64_t next_message_to_print = 0;
9 bool is_dummy = true;
11 void dummy_init() throw()
13 platform::pausing_allowed = false;
16 void dummy_quit() throw()
20 void dummy_notify_message() throw()
22 //Read without lock becase we run in the same thread.
23 while(platform::msgbuf.get_msg_first() + platform::msgbuf.get_msg_count() > next_message_to_print) {
24 if(platform::msgbuf.get_msg_first() > next_message_to_print)
25 next_message_to_print = platform::msgbuf.get_msg_first();
26 else
27 std::cout << platform::msgbuf.get_message(next_message_to_print++) << std::endl;
31 void dummy_error_message(const std::string& text) throw()
33 std::cerr << "Error message: " << text << std::endl;
36 void dummy_fatal_error() throw()
38 std::cerr << "Exiting on fatal error." << std::endl;
41 void dummy_request_rom(rom_request& req)
43 throw std::runtime_error("Headless build does not support ROM requests");
46 const char* dummy_name() { return "Dummy graphics plugin"; }
48 struct _graphics_driver driver = {
49 .init = dummy_init,
50 .quit = dummy_quit,
51 .notify_message = dummy_notify_message,
52 .error_message = dummy_error_message,
53 .fatal_error = dummy_fatal_error,
54 .name = dummy_name,
55 .request_rom = dummy_request_rom
60 graphics_driver::graphics_driver(_graphics_driver drv)
62 driver = drv;
63 is_dummy = false;
66 bool graphics_driver_is_dummy()
68 return is_dummy;
71 void graphics_driver_init() throw()
73 driver.init();
76 void graphics_driver_quit() throw()
78 driver.quit();
81 void graphics_driver_notify_message() throw()
83 driver.notify_message();
86 void graphics_driver_error_message(const std::string& text) throw()
88 driver.error_message(text);
91 void graphics_driver_fatal_error() throw()
93 driver.fatal_error();
96 const char* graphics_driver_name()
98 return driver.name();
101 void graphics_driver_request_rom(rom_request& req)
103 driver.request_rom(req);