SFML community forums

General => General discussions => Topic started by: Trol on January 31, 2012, 03:51:55 pm

Title: SFML 2.0
Post by: Trol on January 31, 2012, 03:51:55 pm
Hello i have a question about sfml elements : P
why in sfml 2.0 Sprite don't have GetPixel function and SetImage?

same with sf::texture don't have createmaskfromcolor but sf::image got?

and i think in sf::Keyboard can will be useful GetKeyCode funtion it make textbox easier to create :D

sorry for my english but my english isn't pretty good
Title: SFML 2.0
Post by: Laurent on January 31, 2012, 04:06:02 pm
Quote
why in sfml 2.0 Sprite don't have GetPixel function and SetImage?

Sprites now use textures, not images. GetPixel is not possible anymore since textures don't keep a copy of their pixels.

Quote
same with sf::texture don't have createmaskfromcolor but sf::image got?

A texture lives in the graphics card memory, therefore it is not possible to directly change the pixels. You have to use a sf::Image, and update your texture from this image. Typically, to create a mask from a color, you'll call:
- Image::LoadFromFile
- Image::CreateMaskFromColor
- Texture::LoadFromImage

Read the doc and the dedicated forum thread if you want to understand the texture/image separation.

Quote
and i think in sf::Keyboard can will be useful GetKeyCode funtion it make textbox easier to create

It wouldn't make sense. Use the sf::TextEntered event.