neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_render_target.hpp
Go to the documentation of this file.
1// i_render_target.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2015, 2020 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
25
26namespace neogfx
27{
28 class i_texture;
29 class i_rendering_context;
30
32 {
33 Surface,
35 };
36
37 typedef int pixel_format_t; // todo: enum?
38
40 {
41 public:
42 declare_event(target_activating)
43 declare_event(target_activated)
44 declare_event(target_deactivating)
45 declare_event(target_deactivated)
46 public:
47 struct failed_to_create_framebuffer : std::runtime_error { failed_to_create_framebuffer(std::string const& aReason) : std::runtime_error("neogfx::i_render_target::failed_to_create_framebuffer: Failed to create frame buffer, reason: " + aReason) {} };
48 struct already_active : std::logic_error { already_active() : std::logic_error("neogfx::i_render_target::already_active") {} };
49 struct not_active : std::logic_error { not_active() : std::logic_error("neogfx::i_render_target::not_active") {} };
50 struct logical_coordinates_not_specified : std::logic_error { logical_coordinates_not_specified() : std::logic_error("neogfx::i_render_target::logical_coordinates_not_specified") {} };
51 public:
52 virtual render_target_type target_type() const = 0;
53 virtual void* target_handle() const = 0;
54 virtual void* target_device_handle() const = 0;
55 virtual pixel_format_t pixel_format() const = 0;
56 virtual const i_texture& target_texture() const = 0;
57 virtual point target_origin() const = 0;
58 virtual size target_extents() const = 0;
59 public:
63 virtual void set_logical_coordinates(const neogfx::logical_coordinates& aCoordinates) = 0;
64 public:
65 virtual rect_i32 viewport() const = 0;
66 virtual rect_i32 set_viewport(const rect_i32& aViewport) const = 0;
67 public:
68 virtual bool target_active() const = 0;
69 virtual void activate_target() const = 0;
70 virtual void deactivate_target() const = 0;
71 public:
72 virtual neogfx::color_space color_space() const = 0;
73 virtual color read_pixel(const point& aPosition) const = 0;
74 public:
75 virtual std::unique_ptr<i_rendering_context> create_graphics_context(blending_mode aBlendingMode = blending_mode::Default) const = 0; // todo: use ref_ptr
76 };
77
79 {
80 public:
83 scoped_render_target(const i_rendering_context& aRenderingContext);
85 private:
86 const i_render_target* iRenderTarget;
87 const i_render_target* iPreviouslyActivatedTarget;
88 };
89}
virtual void set_logical_coordinates(const neogfx::logical_coordinates &aCoordinates)=0
virtual void set_logical_coordinate_system(neogfx::logical_coordinate_system aSystem)=0
virtual neogfx::color_space color_space() const =0
virtual void activate_target() const =0
virtual std::unique_ptr< i_rendering_context > create_graphics_context(blending_mode aBlendingMode=blending_mode::Default) const =0
virtual size target_extents() const =0
virtual rect_i32 viewport() const =0
virtual pixel_format_t pixel_format() const =0
virtual color read_pixel(const point &aPosition) const =0
virtual void * target_device_handle() const =0
virtual point target_origin() const =0
virtual const i_texture & target_texture() const =0
virtual neogfx::logical_coordinates logical_coordinates() const =0
virtual void * target_handle() const =0
virtual neogfx::logical_coordinate_system logical_coordinate_system() const =0
virtual void deactivate_target() const =0
virtual bool target_active() const =0
virtual rect_i32 set_viewport(const rect_i32 &aViewport) const =0
virtual render_target_type target_type() const =0
scoped_render_target(const i_rendering_context &aRenderingContext)
scoped_render_target(const i_render_target &aRenderTarget)
logical_coordinate_system
basic_rect< int32_t > rect_i32
#define declare_event(declName,...)
Definition i_event.hpp:305