![]() This means that a pixel must be composed of 8 bits red, green, blue and alpha channels – just like a sf::Color. Like sf::Image, sf::Texture can handle a unique internal representation of pixels, which is RGBA 32 bits. Therefore, if you need to read the texture's pixels (like for pixel-perfect collisions), it is recommended to store the collision information separately, for example in an array of booleans. And they cannot be accessed individually. Since they live in the graphics card memory, the pixels of a texture cannot be accessed without a slow copy first. However, if you want to perform some modifications on the pixels before creating the final texture, you can load your file to a sf::Image, do whatever you need with the pixels, and then call Texture::loadFromImage. The necessary shortcuts are defined so that you don't need an image first for the most common cases. Sf::Texture makes it easy to convert from/to sf::Image, but keep in mind that these calls require transfers between the graphics card and the central memory, therefore they are slow operations.Ī texture can be loaded from an image, but also directly from a file/memory/stream. A texture cannot be manipulated as freely as a sf::Image, you need to prepare the pixels first and then upload them to the texture in a single operation (see Texture::update). Sf::Texture stores pixels that can be drawn, with a sprite for example.Ī texture lives in the graphics card memory, therefore it is very fast to draw a texture to a render target, or copy a render target to a texture (the graphics card can access both directly).īeing stored in the graphics card memory has some drawbacks. Image living on the graphics card that can be used for drawing. Make sure that a valid OpenGL context exists in the current thread. More.īind (const Texture *texture, CoordinateType coordinateType= Normalized) Tell whether the texture is repeated or not. Tell whether the smooth filter is enabled or not. More.Įnable or disable the smooth filter. Update a part of the texture from the contents of a window. Update (const Window &window, unsigned int x, unsigned int y) Update the texture from the contents of a window. Update a part of the texture from an image. Update (const Image &image, unsigned int x, unsigned int y) Update a part of the texture from an array of pixels. Update (const Uint8 *pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y) / // / No additional check is performed on the size of the pixel // / array, passing invalid arguments will lead to an undefined // / behavior. Update the whole texture from an array of pixels. // / The a pixel array is assumed to have the same size as // / the a area rectangle, and to contain 32-bits RGBA pixels. LoadFromImage (const Image &image, const IntRect &area= IntRect())Ĭopy the texture pixels to an image. ![]() LoadFromStream ( sf::InputStream &stream, const IntRect &area= IntRect()) LoadFromMemory (const void *data, std::size_t size, const IntRect &area= IntRect()) LoadFromFile (const std::string &filename, const IntRect &area= IntRect()) More.Ĭreate (unsigned int width, unsigned int height) ![]() Types of texture coordinates that can be used for rendering. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |