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

Author Topic: Connect textures - create biggest one  (Read 2648 times)

0 Members and 1 Guest are viewing this topic.

MichX

  • Newbie
  • *
  • Posts: 9
    • View Profile
Connect textures - create biggest one
« on: September 23, 2014, 03:30:25 am »
Hi, I'd like to know is it possible to create a texture using other textures in SFML?
I mean i have some textures e.g. 15x15px and i need to create bigger texture 45x45px using smaller textures.
Of course i can use array[3][3], but it's not enough comfortable for me in my case. I want to create automatically new texture.
Is it possible?
Plz help me ;).
« Last Edit: September 23, 2014, 03:32:28 am by MichX »

AFS

  • Full Member
  • ***
  • Posts: 115
    • View Profile
Re: Connect textures - create biggest one
« Reply #1 on: September 23, 2014, 04:49:37 am »
You can do it using sf::RenderTexture, drawing all your sprites using each texture on it, and then using sf::RenderTexture::getTexture() to get the results as a texture and you can even save it to a file.

May I ask why do you want to do this instead of manually putting all your sprites on a big image manually?

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Connect textures - create biggest one
« Reply #2 on: September 23, 2014, 06:17:12 am »
If you are loading the 15x15 textures from somewhere (you probably are) and want the 45x45 texture instead then you can do it in two steps:
1. Load the 9 sf::Images (not sf::Textures) from your 9 files/streams/etc.
2. Combine them with code into one, which you load into sf::Texture with loadFromImage.
sf::Texture loadFromFile is just a shortcut that does above two steps (load image from file + load texture from image).
Back to C++ gamedev with SFML in May 2023

MichX

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Connect textures - create biggest one
« Reply #3 on: September 23, 2014, 03:04:50 pm »
Thanks a lot! I'll try this.
Quote
May I ask why do you want to do this instead of manually putting all your sprites on a big image manually?
The answear is include in Your question - because it's manual ;-).

 

anything