- nom
- Texture
Public Types | |
| typedef std::shared_ptr< Texture > | SharedPtr |
Public Member Functions | |
| Texture (void) | |
| Default constructor. | |
| ~Texture (void) | |
| Lazy destructor. | |
| Texture (const Texture &other) | |
| Copy constructor. | |
| bool | initialize (SDL_SURFACE::RawPtr video_buffer) |
| bool | initialize (int32 width, int32 height, uint32 format, uint32 flags) |
| Texture::SharedPtr | clone (void) const |
| Texture & | operator= (const Texture &other) |
| Copy assignment operator. | |
| const Point2i & | position (void) const |
| const Coords & | bounds (void) const |
| SDL_TEXTURE::RawPtr | texture (void) const |
| Get the video memory surface of the Texture object. | |
| bool | valid (void) const |
| Is this object initialized – not nullptr? | |
| int | access (void) const |
| void | set_position (const Point2i &pos) |
| void | set_bounds (const Coords &clip) |
| int32 | width (void) const |
| int32 | height (void) const |
| int | pitch (void) const |
| void * | pixels (void) const |
| uint8 | bytes_per_pixel (void) const |
| uint32 | pixel_format (void) const |
| uint8 | bits_per_pixel (void) const |
| const SDL_BlendMode | blend_mode (void) const |
| Obtain the blending mode used for texture copies. | |
| bool | locked (void) const |
| Query memory lock status. | |
| const Color & | colorkey (void) const |
| bool | lock (void) |
| bool | lock (const Coords &lock_coords) |
| void | unlock (void) |
| bool | load (const std::string &filename, uint32 flags, bool use_cache=false) |
| bool | update (const void *pixels, uint16 pitch, const Coords &update_area) |
| Upload texture copy with new pixel data. | |
| void | draw (SDL_RENDERER::RawPtr target) const |
| void | draw (const Window &target) const |
| void | draw (SDL_RENDERER::RawPtr target, const double angle) const |
| void | draw (const Window &target, const double angle) const |
| bool | set_alpha (uint8 opacity) |
| uint32 | pixel (int32 x, int32 y) |
| bool | resize (enum ResizeAlgorithm scaling_algorithm) |
| bool | resize (const Point2f &scale_factor) |
| int32 | getResizeScaleFactor (enum ResizeAlgorithm scaling_algorithm) |
| bool | set_blend_mode (const SDL_BlendMode blend) |
| Set a new blending mode for this texture. | |
| bool | set_colorkey (const Color &colorkey) |
Private Attributes | |
| SDL_TEXTURE::SharedPtr | texture_ |
| void * | pixels_ |
| int | pitch_ |
| Texture's pixel pitch; these are only available when a Texture is locked. | |
| Point2i | position_ |
| Holds surface position (X, Y) | |
| Coords | bounds_ |
| Holds surface offsets (clipping area: X, Y, width & height) | |
| Color | colorkey_ |
| Cached upon use of the set_colorkey method for use by external classes. | |
Definition at line 67 of file Texture.hpp.
| int nom::Texture::access | ( | void | ) | const |
Query texture access type
Definition at line 169 of file Texture.cpp.
| uint8 nom::Texture::bits_per_pixel | ( | void | ) | const |
Calculate this object's bits per pixel (color depth)
Definition at line 248 of file Texture.cpp.
| uint8 nom::Texture::bytes_per_pixel | ( | void | ) | const |
Definition at line 261 of file Texture.cpp.
| Texture::SharedPtr nom::Texture::clone | ( | void | ) | const |
Return a std::shared_ptr copy of this instance
Definition at line 141 of file Texture.cpp.
| const Color & nom::Texture::colorkey | ( | void | ) | const |
Obtain the set color key for this image
Definition at line 299 of file Texture.cpp.
| void nom::Texture::draw | ( | SDL_RENDERER::RawPtr | target | ) | const |
Draw a nom::Texture to a SDL_Renderer target
| SDL_Renderer |
Definition at line 422 of file Texture.cpp.
| void nom::Texture::draw | ( | const Window & | target | ) | const |
Draw a nom::Texture to a nom::Window target
| nom::Window |
Definition at line 459 of file Texture.cpp.
| void nom::Texture::draw | ( | SDL_RENDERER::RawPtr | target, |
| const double | angle | ||
| ) | const |
Draw a rotated nom::Texture to a rendering target
| target | Pointer to SDL_Renderer context |
| angle | Rotation angle in degrees |
Definition at line 464 of file Texture.cpp.
| void nom::Texture::draw | ( | const Window & | target, |
| const double | angle | ||
| ) | const |
Draw a rotated nom::Texture on a nom::Window
| target | Reference to an active nom::Window |
| angle | Rotation angle in degrees |
Definition at line 501 of file Texture.cpp.
| int32 nom::Texture::getResizeScaleFactor | ( | enum ResizeAlgorithm | scaling_algorithm | ) |
Return the correct scaling factor of the chosen algorithm
Definition at line 836 of file Texture.cpp.
| int32 nom::Texture::height | ( | void | ) | const |
Obtain height, in pixels, of texture
Definition at line 225 of file Texture.cpp.
| bool nom::Texture::initialize | ( | SDL_SURFACE::RawPtr | video_buffer | ) |
Constructor variant for creating a fresh, empty video surface. You should be sure to read over the details gory details scattered throughout the documentation for SDL.
The SDL_SWSURFACE flag is passed by default if an argument is not specified – this is optimal for writing to the video memory buffer directly (pixel manipulation).
As per libSDL docs, this must be called only after video initialization; (SDL_SetVideoMode).
See http://sdl.beuc.net/sdl.wiki/SDL_CreateRGBSurface Construct a video surface object using the data from an existing surface; you can think of this as a copy method. As with the previous method, you ought to read over the technicalities that the SDL library documentation covers.
You remain the owner of the pointer leading to your existing data and therefore are responsible for memory management.
See http://sdl.beuc.net/sdl.wiki/SDL_CreateRGBSurfaceFrom Initialize object with SDL1 video surface
The new texture created will be of type 'SDL_TEXTUREACCESS_STATIC'
Definition at line 97 of file Texture.cpp.
| bool nom::Texture::initialize | ( | int32 | width, |
| int32 | height, | ||
| uint32 | format, | ||
| uint32 | flags | ||
| ) |
Initialize object with new specified parameters ...
Definition at line 123 of file Texture.cpp.
| bool nom::Texture::load | ( | const std::string & | filename, |
| uint32 | flags, | ||
| bool | use_cache = false |
||
| ) |
Load an image into memory from a file
| filename | File path you wish to load into memory as a valid bitmap / texture (think: supported image file types). |
| flags | [...TO BE WRITTEN...] |
| use_cache | Whether or not to use an internal object cache feature of nomlib. Defaults to off. |
Definition at line 353 of file Texture.cpp.
| bool nom::Texture::lock | ( | void | ) |
Lock a portion of the texture for write-only pixel access.
Texture must be created with SDL_TEXTUREACCESS_STREAMING.
Definition at line 304 of file Texture.cpp.
| bool nom::Texture::lock | ( | const Coords & | lock_coords | ) |
Lock a portion of this texture for write-only pixel access.
Texture must be created with SDL_TEXTUREACCESS_STREAMING.
| lock_coords | The area encompassing the area to lock for write access. |
Definition at line 321 of file Texture.cpp.
| uint32 nom::Texture::pixel | ( | int32 | x, |
| int32 | y | ||
| ) |
Pixel reading – supports 8-bit, 15/16-bit, 24-bit & 32-bit color modes
Returns -1 on error
You are responsible for locking & unlocking of the Texture before-hand
Definition at line 519 of file Texture.cpp.
| bool nom::Texture::resize | ( | enum ResizeAlgorithm | scaling_algorithm | ) |
Resize the video surface with the chosen rescaling algorithm.
See the ResizeAlgorithm enum for available rescaling algorithms
Definition at line 559 of file Texture.cpp.
| bool nom::Texture::resize | ( | const Point2f & | scale_factor | ) |
Definition at line 732 of file Texture.cpp.
| bool nom::Texture::set_colorkey | ( | const Color & | colorkey | ) |
Set a new color key
| colorkey | nom::Color object representing the RGB pixel to be marked transparent. |
(This method requires locking the texture; use wisely!).
Definition at line 870 of file Texture.cpp.
| void nom::Texture::set_position | ( | const Point2i & | pos | ) |
Reset the video surface object with another video surface object.
Definition at line 201 of file Texture.cpp.
| void nom::Texture::unlock | ( | void | ) |
Unlock this texture, thereby uploading any applicable changes to video memory.
Definition at line 340 of file Texture.cpp.
| int32 nom::Texture::width | ( | void | ) | const |
Obtain width, in pixels, of texture
Definition at line 212 of file Texture.cpp.
|
private |
Texture's pixels; these are only available when a Texture is locked and is intended for writing to.
Definition at line 296 of file Texture.hpp.