Make various instance stuff to take references to other instance objs
[lsnes.git] / include / core / framebuffer.hpp
blob73450d9a61a6b628d38e71171ad5ba8bdd7bb564
1 #ifndef _framebuffer__hpp__included__
2 #define _framebuffer__hpp__included__
4 #include "core/window.hpp"
5 #include "library/framebuffer.hpp"
6 #include "library/triplebuffer.hpp"
8 #include <stdexcept>
10 class subtitle_commentary;
11 class memwatch_set;
12 namespace settingvar
14 class group;
16 namespace keyboard
18 class keyboard;
21 /**
22 * Emulator frame buffer.
24 class emu_framebuffer
26 public:
27 emu_framebuffer(subtitle_commentary& _subtitles, settingvar::group& _settings, memwatch_set& _mwatch,
28 keyboard::keyboard& _keyboard);
29 /**
30 * The main framebuffer.
32 framebuffer::raw main_framebuffer;
33 /**
34 * Special screen: "SYSTEM STATE CORRUPT".
36 static framebuffer::raw screen_corrupt;
37 /**
38 * The main screen to draw on.
40 framebuffer::fb<false> main_screen;
41 /**
42 * Initialize special screens.
44 * throws std::bad_alloc: Not enough memory.
46 static void init_special_screens() throw(std::bad_alloc);
47 /**
48 * Copy framebuffer to backing store, running Lua hooks if any.
50 void redraw_framebuffer(framebuffer::raw& torender, bool no_lua = false, bool spontaneous = false);
51 /**
52 * Redraw the framebuffer, reusing contents from last redraw. Runs lua hooks if last redraw ran them.
54 void redraw_framebuffer();
55 /**
56 * Return last complete framebuffer.
58 framebuffer::raw get_framebuffer() throw(std::bad_alloc);
59 /**
60 * Render framebuffer to main screen.
62 void render_framebuffer();
63 /**
64 * Get the size of current framebuffer.
66 std::pair<uint32_t, uint32_t> get_framebuffer_size();
67 /**
68 * Take a screenshot to specified file.
70 void take_screenshot(const std::string& file) throw(std::bad_alloc, std::runtime_error);
71 /**
72 * Kill pending requests associated with object.
74 void render_kill_request(void* obj);
75 /**
76 * Get latest screen received from core.
78 framebuffer::raw& render_get_latest_screen();
79 void render_get_latest_screen_end();
80 private:
81 struct render_info
83 framebuffer::raw fbuf;
84 framebuffer::queue rq;
85 uint32_t hscl;
86 uint32_t vscl;
87 uint32_t lgap;
88 uint32_t rgap;
89 uint32_t tgap;
90 uint32_t bgap;
92 render_info buffer1;
93 render_info buffer2;
94 render_info buffer3;
95 triplebuffer::triplebuffer<render_info> buffering;
96 bool last_redraw_no_lua;
97 subtitle_commentary& subtitles;
98 settingvar::group& settings;
99 memwatch_set& mwatch;
100 keyboard::keyboard& keyboard;
103 #endif