neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
texture.hpp
Go to the documentation of this file.
1// 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 <vector>
24#include <optional>
25#include <neogfx/gfx/color.hpp>
28
29namespace neogfx
30{
31 class i_image;
32 class i_native_texture;
33
34 class texture : public reference_counted<i_texture>
35 {
36 // construction
37 public:
40 texture(const i_texture& aTexture);
43 texture(const i_sub_texture& aSubTexture);
45 // operations
46 public:
47 texture_id id() const final;
48 i_string const& uri() const final;
49 rect const& part() const final;
50 texture_type type() const final;
51 bool is_render_target() const final;
52 const i_render_target& as_render_target() const final;
54 const i_sub_texture& as_sub_texture() const final;
58 uint32_t samples() const final;
61 bool is_empty() const final;
62 size extents() const final;
63 size storage_extents() const final;
64 void set_pixels(const rect& aRect, const void* aPixelData, uint32_t aPackAlignment = 4u) final;
65 void set_pixels(const i_image& aImage) final;
66 void set_pixels(const i_image& aImage, const rect& aImagePart) final;
67 void set_pixel(const point& aPosition, const color& aColor) final;
68 color get_pixel(const point& aPosition) const final;
69 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;
70 public:
71 void bind(std::uint32_t aTextureUnit) const final;
72 void unbind() const final;
73 public:
74 intptr_t native_handle() const final;
75 i_texture& native_texture() const final;
76 // attributes
77 private:
78 ref_ptr<i_texture> iNativeTexture;
79 optional_sub_texture iSubTexture;
80 };
81
83}
size extents() const final
texture_id id() const final
bool is_empty() 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
dimension dpi_scale_factor() const final
const i_sub_texture & as_sub_texture() const final
uint32_t samples() const final
texture(const i_image &aImage, const rect &aImagePart, texture_data_format aDataFormat=texture_data_format::RGBA, texture_data_type aDataType=texture_data_type::UnsignedByte)
void unbind() const final
void bind(std::uint32_t aTextureUnit) const final
void set_pixel(const point &aPosition, const color &aColor) final
color get_pixel(const point &aPosition) const final
texture(const neogfx::size &aExtents, dimension aDpiScaleFactor=1.0, texture_sampling aSampling=texture_sampling::NormalMipmap, texture_data_format aDataFormat=texture_data_format::RGBA, texture_data_type aDataType=texture_data_type::UnsignedByte, neogfx::color_space aColorSpace=neogfx::color_space::sRGB, const optional_color &aColor=optional_color{})
rect const & part() const final
texture_data_format data_format() const final
texture_sampling sampling() const final
texture_type type() const final
texture(const i_texture &aTexture)
void set_pixels(const rect &aRect, const void *aPixelData, uint32_t aPackAlignment=4u) final
texture(const i_image &aImage, texture_data_format aDataFormat=texture_data_format::RGBA, texture_data_type aDataType=texture_data_type::UnsignedByte)
i_string const & uri() const final
size storage_extents() const final
i_texture & native_texture() const final
const i_render_target & as_render_target() const final
bool is_render_target() const final
intptr_t native_handle() const final
texture_data_type data_type() const final
texture(const i_sub_texture &aSubTexture)
default_geometry_value_type dimension
std::optional< sub_texture > optional_sub_texture
std::optional< texture > optional_texture
Definition texture.hpp:82
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