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

Author Topic: Blit from one sprite onto another  (Read 11700 times)

0 Members and 3 Guests are viewing this topic.

esrix

  • Newbie
  • *
  • Posts: 5
    • View Profile
Blit from one sprite onto another
« on: August 31, 2007, 02:59:09 pm »
I didn't see this anywhere in the documentation.  Is there a way to blit one sprite onto another?

Say I loaded two images and have two sprites that use those images respectively.  What would I have to do to get the first sprite to render onto second sprite and then display the second sprite onto the screen?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Blit from one sprite onto another
« Reply #1 on: August 31, 2007, 08:30:26 pm »
There is currently no way to do it, and I don't think it will be added.

Why would you need this ?
Laurent Gomila - SFML developer

esrix

  • Newbie
  • *
  • Posts: 5
    • View Profile
Blit from one sprite onto another
« Reply #2 on: September 01, 2007, 01:53:47 am »
Well, I was originally going to have a smaller sprite blit to a larger sprite and then rotate and blit the larger sprite on the screen.  However, I think I might be able to do it just by blitting the sprites to the screen after making the proper adjustments to their position.

gamecoder5

  • Newbie
  • *
  • Posts: 10
    • View Profile
Very important feature
« Reply #3 on: January 28, 2008, 09:54:43 pm »
This is something I need, I want to be able to run a blend mode sprite onto another sprite (multiply), then from there blend mode onto the screen surface.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Blit from one sprite onto another
« Reply #4 on: January 29, 2008, 02:34:15 am »
I see. Is there any problem using two sprites with the same position and rotation attributes ?
Laurent Gomila - SFML developer

gamecoder5

  • Newbie
  • *
  • Posts: 10
    • View Profile
Blit from one sprite onto another
« Reply #5 on: January 29, 2008, 04:06:00 pm »
I figured out a way to do it, haven't tested the performance of it, but using GetPixel/SetPixel to achieve the effect, guessing may be slow do to the getpixel part.

Scott.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Blit from one sprite onto another
« Reply #6 on: January 30, 2008, 02:25:27 am »
Yes, that's currently the only way to do it. And yes, that's quite slow ;)
Laurent Gomila - SFML developer

sebastian

  • Newbie
  • *
  • Posts: 1
    • View Profile
Blit from one sprite onto another
« Reply #7 on: January 31, 2008, 11:10:52 pm »
Hi i guess im into the same kind of thing (almost)
I would like to use SFML for some raycasting ala wolfenstein,
i tried the tecniq of drawing to a sprite, then drawing the sprite onto the screen, but this comes out way too slow even on my "highend" computer.

Guessing theres an easier way (i hope)??
Maybe a way to draw "directly" to the screen buffer or something like that....

gamecoder5

  • Newbie
  • *
  • Posts: 10
    • View Profile
Blit from one sprite onto another
« Reply #8 on: February 05, 2008, 02:52:36 am »
Yes, without this feature (ability to blit image to image quickly) its killing my ability to do the type of effects I want in my game, which was the whole reason I switched to sfml.

I'm surprised this feature isn't supported, its very useful.

Scott.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Blit from one sprite onto another
« Reply #9 on: February 05, 2008, 04:47:59 am »
Actually, these feature can be split in two things :
- Blit a part of an image onto another image --> this must be done with CPU and can be fast enough (just a loop with pixel copy)
- Render sprites, text or whatever to an image --> this must use OpenGL render-to-texture, which is badly supported on low-end hardware and can be expensive.

However, the second one is planned for later, and I could quickly implement the first one.
Laurent Gomila - SFML developer

gamecoder5

  • Newbie
  • *
  • Posts: 10
    • View Profile
Blit from one sprite onto another
« Reply #10 on: February 05, 2008, 02:41:24 pm »
I did a simple for loop for each x,y

for(int iy=0; iy < height; iy++)
{
   for(int ix=0; ix< width; ix++)
  {
      image->SetPixel(ix,iy,color);
   }
}


but way to slow, is there a much faster way , if so, could you please?

Thank you,

Scott.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Blit from one sprite onto another
« Reply #11 on: February 05, 2008, 03:25:04 pm »
Of course there is ;)
But you can't do it, it needs to be done internally wth a direct access to the pixels array.
Laurent Gomila - SFML developer

Lord Delvin

  • Jr. Member
  • **
  • Posts: 68
    • ICQ Messenger - 166781460
    • View Profile
Blit from one sprite onto another
« Reply #12 on: February 05, 2008, 08:52:54 pm »
Quote from: "Laurent"
But you can't do it, it needs to be done internally wth a direct access to the pixels array.


Hrrhrr. Licens allows us to do any improvements, wo want to and sometimes this is an option(looking at unicode support on linux ehrm:P)

gamecoder5

  • Newbie
  • *
  • Posts: 10
    • View Profile
Blit from one sprite onto another
« Reply #13 on: February 05, 2008, 10:35:35 pm »
Is it going to be done? Please?

Thanks,

Scott.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Blit from one sprite onto another
« Reply #14 on: February 06, 2008, 01:57:40 am »
Quote
Is it going to be done? Please?

Yes sir.

Quote
Hrrhrr. Licens allows us to do any improvements, wo want to and sometimes this is an option(looking at unicode support on linux ehrm:P)

Feel free to do any improvement, or just whatever you want with the source code :)
Laurent Gomila - SFML developer