Allow binding commands to class instance
[lsnes.git] / include / core / framebuffer.hpp
blob9cd79fde95f786d2b147adf447bd6b6f63b39c22
1 #ifndef _framebuffer__hpp__included__
2 #define _framebuffer__hpp__included__
4 #include "core/window.hpp"
5 #include "library/command.hpp"
6 #include "library/framebuffer.hpp"
7 #include "library/triplebuffer.hpp"
9 #include <stdexcept>
11 class subtitle_commentary;
12 class memwatch_set;
13 class emulator_dispatch;
14 class lua_state;
15 class loaded_rom;
16 class status_updater;
17 namespace settingvar
19 class group;
21 namespace keyboard
23 class keyboard;
26 /**
27 * Emulator frame buffer.
29 class emu_framebuffer
31 public:
32 emu_framebuffer(subtitle_commentary& _subtitles, settingvar::group& _settings, memwatch_set& _mwatch,
33 keyboard::keyboard& _keyboard, emulator_dispatch& _dispatch, lua_state& _lua2, loaded_rom& _rom,
34 status_updater& _supdater, command::group& _cmd);
35 /**
36 * The main framebuffer.
38 framebuffer::raw main_framebuffer;
39 /**
40 * Special screen: "SYSTEM STATE CORRUPT".
42 static framebuffer::raw screen_corrupt;
43 /**
44 * The main screen to draw on.
46 framebuffer::fb<false> main_screen;
47 /**
48 * Initialize special screens.
50 * throws std::bad_alloc: Not enough memory.
52 static void init_special_screens() throw(std::bad_alloc);
53 /**
54 * Copy framebuffer to backing store, running Lua hooks if any.
56 void redraw_framebuffer(framebuffer::raw& torender, bool no_lua = false, bool spontaneous = false);
57 /**
58 * Redraw the framebuffer, reusing contents from last redraw. Runs lua hooks if last redraw ran them.
60 void redraw_framebuffer();
61 /**
62 * Return last complete framebuffer.
64 framebuffer::raw get_framebuffer() throw(std::bad_alloc);
65 /**
66 * Render framebuffer to main screen.
68 void render_framebuffer();
69 /**
70 * Get the size of current framebuffer.
72 std::pair<uint32_t, uint32_t> get_framebuffer_size();
73 /**
74 * Take a screenshot to specified file.
76 void take_screenshot(const std::string& file) throw(std::bad_alloc, std::runtime_error);
77 /**
78 * Kill pending requests associated with object.
80 void render_kill_request(void* obj);
81 /**
82 * Get latest screen received from core.
84 framebuffer::raw& render_get_latest_screen();
85 void render_get_latest_screen_end();
86 private:
87 void do_screenshot(command::arg_filename a);
88 struct render_info
90 framebuffer::raw fbuf;
91 framebuffer::queue rq;
92 uint32_t hscl;
93 uint32_t vscl;
94 uint32_t lgap;
95 uint32_t rgap;
96 uint32_t tgap;
97 uint32_t bgap;
99 render_info buffer1;
100 render_info buffer2;
101 render_info buffer3;
102 triplebuffer::triplebuffer<render_info> buffering;
103 bool last_redraw_no_lua;
104 subtitle_commentary& subtitles;
105 settingvar::group& settings;
106 memwatch_set& mwatch;
107 keyboard::keyboard& keyboard;
108 emulator_dispatch& edispatch;
109 lua_state& lua2;
110 loaded_rom& rom;
111 status_updater& supdater;
112 command::group& cmd;
113 command::_fnptr<command::arg_filename> screenshot;
116 #endif