Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML 2.0  (Read 5416 times)

0 Members and 1 Guest are viewing this topic.

Trol

  • Newbie
  • *
  • Posts: 3
    • View Profile
SFML 2.0
« 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2.0
« Reply #1 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.
Laurent Gomila - SFML developer