Mir
as_render_target.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2015 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17  */
18 
19 #ifndef MIR_EXAMPLES_AS_RENDER_TARGET_H_
20 #define MIR_EXAMPLES_AS_RENDER_TARGET_H_
21 
24 
25 #include <stdexcept>
26 
27 namespace mir
28 {
29 namespace examples
30 {
31 
32 inline auto as_render_target(graphics::DisplayBuffer& display_buffer)
33 {
34  auto const render_target =
35  dynamic_cast<renderer::gl::RenderTarget*>(display_buffer.native_display_buffer());
36  if (!render_target)
37  throw std::logic_error{"DisplayBuffer doesn't support GL rendering"};
38  return render_target;
39 }
40 
41 }
42 }
43 
44 #endif
Definition: as_render_target.h:27
Interface to an output framebuffer.
Definition: display_buffer.h:47
auto as_render_target(graphics::DisplayBuffer &display_buffer)
Definition: as_render_target.h:32
virtual NativeDisplayBuffer * native_display_buffer()=0
Returns a pointer to the native display buffer object backing this display buffer.
Definition: render_target.h:29

Copyright © 2012-2016 Canonical Ltd.
Generated on Wed May 10 10:41:27 UTC 2017