neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
sub_texture.hpp
Go to the documentation of this file.
1// sub_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>
23#include <optional>
26
27namespace neogfx
28{
29 class sub_texture : public reference_counted<i_sub_texture>
30 {
31 // construction
32 public:
33 sub_texture(texture_id aAtlasId, i_texture& aAtlasTexture, const rect& aAtlasLocation, const size& aExtents);
34 sub_texture(const i_sub_texture& aSubTexture);
35 sub_texture(const i_sub_texture& aSubTexture, const rect& aAtlasLocation);
37 // operations
38 public:
39 texture_id id() const final;
40 i_string const& uri() const final;
41 rect const& part() const final;
42 texture_type type() const final;
43 bool is_render_target() const final;
44 const i_render_target& as_render_target() const final;
46 const i_sub_texture& as_sub_texture() const final;
50 uint32_t samples() const final;
53 bool is_empty() const final;
54 size extents() const final;
55 size storage_extents() const final;
56 void set_pixels(const rect& aRect, const void* aPixelData, uint32_t aPackAlignment = 4u) final;
57 void set_pixels(const i_image& aImage) final;
58 void set_pixels(const i_image& aImage, const rect& aImagePart) final;
59 void set_pixel(const point& aPosition, const color& aColor) final;
60 color get_pixel(const point& aPosition) const final;
61 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 final;
62 public:
63 void bind(std::uint32_t aTextureUnit) const final;
64 void unbind() const final;
65 public:
66 intptr_t native_handle() const final;
67 i_texture& native_texture() const final;
68 public:
69 texture_id atlas_id() const final;
70 i_texture& atlas_texture() const final;
71 const rect& atlas_location() const final;
72 // attributes
73 private:
74 texture_id iAtlasId;
75 i_texture* iAtlasTexture;
76 rect iAtlasLocation;
77 size iStorageExtents;
78 size iExtents;
79 mutable std::map<std::tuple<texture_line_segment, rect, vec2, scalar>, vector<texture_line_segment>> iIntersectionResultCache;
80 };
81
83}
color get_pixel(const point &aPosition) const final
texture_data_type data_type() const final
bool is_render_target() const final
i_string const & uri() const final
i_texture & atlas_texture() const final
size storage_extents() const final
texture_id atlas_id() const final
sub_texture(const i_sub_texture &aSubTexture, const rect &aAtlasLocation)
i_texture & native_texture() const final
texture_data_format data_format() const final
void bind(std::uint32_t aTextureUnit) const final
texture_id id() const final
void set_pixels(const rect &aRect, const void *aPixelData, uint32_t aPackAlignment=4u) final
const i_render_target & as_render_target() const final
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 final
void unbind() const final
rect const & part() const final
bool is_empty() const final
size extents() const final
texture_type type() const final
uint32_t samples() const final
sub_texture(texture_id aAtlasId, i_texture &aAtlasTexture, const rect &aAtlasLocation, const size &aExtents)
const rect & atlas_location() const final
texture_sampling sampling() const final
intptr_t native_handle() const final
dimension dpi_scale_factor() const final
const i_sub_texture & as_sub_texture() const final
void set_pixel(const point &aPosition, const color &aColor) final
sub_texture(const i_sub_texture &aSubTexture)
default_geometry_value_type dimension
std::optional< sub_texture > optional_sub_texture
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
double scalar
Definition numerical.hpp:63
Definition plf_hive.h:79