Movatterモバイル変換


[0]ホーム

URL:


Loading...
Searching...
No Matches
Texture.hpp
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2025 Laurent Gomila (laurent@sfml-dev.org)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#pragma once
26
28// Headers
31
34
36
38
39#include <filesystem>
40
41#include <cstddef>
42#include <cstdint>
43
44
45namespacesf
46{
47classInputStream;
48classWindow;
49classImage;
50
56{
57public:
67
73
80Texture(constTexture& copy);
81
87
92Texture(Texture&&) noexcept;
93
98Texture& operator=(Texture&&) noexcept;
99
114 explicitTexture(const std::filesystem::path& filename,bool sRgb = false);
115
137Texture(const std::filesystem::path& filename,bool sRgb, constIntRect& area);
138
154Texture(constvoid* data, std::size_t size,bool sRgb = false);
155
178Texture(constvoid* data, std::size_t size,bool sRgb, constIntRect& area);
179
194 explicitTexture(InputStream& stream,bool sRgb = false);
195
217Texture(InputStream& stream,bool sRgb, constIntRect& area);
218
233 explicitTexture(constImage& image,bool sRgb = false);
234
255Texture(constImage& image,bool sRgb, constIntRect& area);
256
266 explicitTexture(Vector2u size,bool sRgb = false);
267
279 [[nodiscard]]boolresize(Vector2u size,bool sRgb = false);
280
304 [[nodiscard]]boolloadFromFile(const std::filesystem::path& filename,bool sRgb = false, constIntRect& area = {});
305
330 [[nodiscard]]boolloadFromMemory(constvoid* data, std::size_t size,bool sRgb =false,constIntRect& area = {});
331
355 [[nodiscard]]boolloadFromStream(InputStream& stream,bool sRgb =false,constIntRect& area = {});
356
380 [[nodiscard]]boolloadFromImage(constImage& image,bool sRgb =false,constIntRect& area = {});
381
388 [[nodiscard]]Vector2ugetSize()const;
389
403 [[nodiscard]]ImagecopyToImage()const;
404
421voidupdate(const std::uint8_t* pixels);
422
441voidupdate(const std::uint8_t* pixels,Vector2u size,Vector2u dest);
442
462voidupdate(constTexture& texture);
463
478voidupdate(constTexture& texture,Vector2u dest);
479
499voidupdate(constImage& image);
500
515voidupdate(constImage& image,Vector2u dest);
516
536voidupdate(constWindow& window);
537
552voidupdate(constWindow& window,Vector2u dest);
553
568voidsetSmooth(bool smooth);
569
578 [[nodiscard]]boolisSmooth()const;
579
588 [[nodiscard]]boolisSrgb()const;
589
612voidsetRepeated(bool repeated);
613
622 [[nodiscard]]boolisRepeated()const;
623
647 [[nodiscard]]boolgenerateMipmap();
648
655voidswap(Texture& right)noexcept;
656
667 [[nodiscard]]unsignedintgetNativeHandle()const;
668
700staticvoidbind(constTexture* texture,CoordinateType coordinateType =CoordinateType::Normalized);
701
712 [[nodiscard]]staticunsignedintgetMaximumSize();
713
714private:
715friendclassText;
716friendclassRenderTexture;
717friendclassRenderTarget;
718
732 [[nodiscard]]staticunsignedint getValidSize(unsignedint size);
733
741void invalidateMipmap();
742
744// Member data
746Vector2u m_size;
747Vector2u m_actualSize;
748unsignedint m_texture{};
749bool m_isSmooth{};
750bool m_sRgb{};
751bool m_isRepeated{};
752mutablebool m_pixelsFlipped{};
753bool m_fboAttachment{};
754bool m_hasMipmap{};
755 std::uint64_t m_cacheId;
756};
757
765SFML_GRAPHICS_APIvoidswap(Texture& left,Texture& right)noexcept;
766
767}// namespace sf
768
769
#define SFML_GRAPHICS_API
GlResource()
Default constructor.
Class for loading, manipulating and saving images.
DefinitionImage.hpp:55
Abstract class for custom file input streams.
Image living on the graphics card that can be used for drawing.
DefinitionTexture.hpp:56
void update(const Image &image)
Update the texture from an image.
static unsigned int getMaximumSize()
Get the maximum texture size allowed.
void setSmooth(bool smooth)
Enable or disable the smooth filter.
friend class RenderTexture
DefinitionTexture.hpp:716
static void bind(const Texture *texture, CoordinateType coordinateType=CoordinateType::Normalized)
Bind a texture for rendering.
Texture()
Default constructor.
bool isSmooth() const
Tell whether the smooth filter is enabled or not.
void update(const std::uint8_t *pixels, Vector2u size, Vector2u dest)
Update a part of the texture from an array of pixels.
void update(const Texture &texture, Vector2u dest)
Update a part of this texture from another texture.
Texture(const Texture &copy)
Copy constructor.
Texture & operator=(const Texture &)
Copy assignment operator.
unsigned int getNativeHandle() const
Get the underlying OpenGL handle of the texture.
bool loadFromStream(InputStream &stream, bool sRgb=false, const IntRect &area={})
Load the texture from a custom stream.
bool generateMipmap()
Generate a mipmap using the current texture data.
Image copyToImage() const
Copy the texture pixels to an image.
Texture(Texture &&) noexcept
Move constructor.
~Texture()
Destructor.
bool loadFromFile(const std::filesystem::path &filename, bool sRgb=false, const IntRect &area={})
Load the texture from a file on disk.
bool isSrgb() const
Tell whether the texture source is converted from sRGB or not.
Vector2u getSize() const
Return the size of the texture.
void swap(Texture &right) noexcept
Swap the contents of this texture with those of another.
bool loadFromMemory(const void *data, std::size_t size, bool sRgb=false, const IntRect &area={})
Load the texture from a file in memory.
friend class RenderTarget
DefinitionTexture.hpp:717
void setRepeated(bool repeated)
Enable or disable repeating.
void update(const Window &window, Vector2u dest)
Update a part of the texture from the contents of a window.
void update(const Image &image, Vector2u dest)
Update a part of the texture from an image.
void update(const Window &window)
Update the texture from the contents of a window.
void update(const std::uint8_t *pixels)
Update the whole texture from an array of pixels.
friend class Text
DefinitionTexture.hpp:715
bool loadFromImage(const Image &image, bool sRgb=false, const IntRect &area={})
Load the texture from an image.
bool isRepeated() const
Tell whether the texture is repeated or not.
void update(const Texture &texture)
Update a part of this texture from another texture.
bool resize(Vector2u size, bool sRgb=false)
Resize the texture.
Window that serves as a target for OpenGL rendering.
CoordinateType
Types of texture coordinates that can be used for rendering.
@ Normalized
Texture coordinates in range [0 .. 1].
void swap(Texture &left, Texture &right) noexcept
Swap the contents of one texture with those of another.
Vector2< unsigned int > Vector2u
DefinitionVector2.hpp:209
Rect< int > IntRect
DefinitionRect.hpp:146

[8]ページ先頭

©2009-2025 Movatter.jp