neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_texture.hpp
Go to the documentation of this file.
1// i_texture.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#include <neogfx/gfx/color.hpp>
26#include <neogfx/game/i_ecs.hpp>
27
28namespace neogfx
29{
31
32 class i_render_target;
33 class i_native_texture;
34
35 enum class texture_type : uint32_t
36 {
37 Texture,
39 };
40
41 enum class texture_sampling : uint32_t
42 {
43 Normal,
45 Nearest,
46 Scaled,
47 Data,
53 };
54
55 enum class texture_data_format : uint32_t
56 {
57 // todo: add remaining GL texture data formats
58 RGBA = 0x01,
59 Red = 0x02,
60 SubPixel = 0x03
61 };
62
63 enum class texture_data_type : uint32_t
64 {
65 // todo: add remaining GL texture data types
67 Float
68 };
69
70 class i_sub_texture;
71 class i_image;
72
74 {
77
78 auto operator<=>(texture_line_segment const&) const = default;
79
81 };
82
84 {
85 public:
86 struct texture_empty : std::logic_error { texture_empty() : std::logic_error("neogfx::i_texture::texture_empty") {} };
87 struct not_sub_texture : std::logic_error { not_sub_texture() : std::logic_error("neogfx::i_texture::not_sub_texture") {} };
88 public:
90 public:
91 virtual ~i_texture() = default;
92 public:
93 virtual texture_id id() const = 0;
94 virtual i_string const& uri() const = 0;
95 virtual rect const& part() const = 0;
96 virtual texture_type type() const = 0;
97 virtual bool is_render_target() const = 0;
98 virtual const i_render_target& as_render_target() const = 0;
100 virtual const i_sub_texture& as_sub_texture() const = 0;
101 virtual dimension dpi_scale_factor() const = 0;
102 virtual neogfx::color_space color_space() const = 0;
103 virtual texture_sampling sampling() const = 0;
104 virtual uint32_t samples() const = 0;
105 virtual texture_data_format data_format() const = 0;
106 virtual texture_data_type data_type() const = 0;
107 virtual bool is_empty() const = 0;
108 virtual size extents() const = 0;
109 virtual size storage_extents() const = 0;
110 virtual void set_pixels(const rect& aRect, const void* aPixelData, uint32_t aPackAlignment = 4u) = 0;
111 virtual void set_pixels(const i_image& aImage) = 0;
112 virtual void set_pixels(const i_image& aImage, const rect& aImagePart) = 0;
113 virtual void set_pixel(const point& aPosition, const color& aColor) = 0;
114 virtual color get_pixel(const point& aPosition) const = 0;
115 virtual i_vector<texture_line_segment> const& intersection(texture_line_segment const& aLine, rect const& aBoundingBox, vec2 const& aSampleSize = { 1.0, 1.0 }, scalar aTolerance = 0.0) const = 0;
116 public:
117 virtual void bind(std::uint32_t aTextureUnit) const = 0;
118 virtual void unbind() const = 0;
119 public:
120 virtual intptr_t native_handle() const = 0;
121 virtual i_texture& native_texture() const = 0;
122 };
123}
virtual neogfx::color_space color_space() const =0
virtual void set_pixels(const rect &aRect, const void *aPixelData, uint32_t aPackAlignment=4u)=0
virtual void set_pixel(const point &aPosition, const color &aColor)=0
virtual void set_pixels(const i_image &aImage)=0
virtual const i_sub_texture & as_sub_texture() const =0
virtual void unbind() const =0
virtual uint32_t samples() const =0
virtual color get_pixel(const point &aPosition) const =0
virtual texture_data_format data_format() const =0
virtual intptr_t native_handle() const =0
virtual texture_id id() const =0
virtual void bind(std::uint32_t aTextureUnit) const =0
virtual bool is_render_target() const =0
virtual ~i_texture()=default
i_texture abstract_type
Definition i_texture.hpp:89
virtual const i_render_target & as_render_target() const =0
virtual bool is_empty() const =0
virtual i_string const & uri() const =0
virtual size storage_extents() const =0
virtual rect const & part() const =0
virtual dimension dpi_scale_factor() const =0
virtual texture_data_type data_type() const =0
virtual texture_type type() const =0
virtual texture_sampling sampling() const =0
virtual size extents() const =0
virtual i_render_target & as_render_target()=0
virtual i_vector< texture_line_segment > const & intersection(texture_line_segment const &aLine, rect const &aBoundingBox, vec2 const &aSampleSize={ 1.0, 1.0 }, scalar aTolerance=0.0) const =0
virtual i_texture & native_texture() const =0
virtual void set_pixels(const i_image &aImage, const rect &aImagePart)=0
default_geometry_value_type dimension
game::id_t texture_id
Definition i_texture.hpp:30
texture_data_type
Definition i_texture.hpp:64
texture_data_format
Definition i_texture.hpp:56
texture_sampling
Definition i_texture.hpp:42
neolib::cookie id_t
Definition ecs_ids.hpp:48
double scalar
Definition numerical.hpp:63
auto operator<=>(texture_line_segment const &) const =default