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

Author Topic: Draw on an Image?  (Read 3566 times)

0 Members and 1 Guest are viewing this topic.

Apprauuuu

  • Newbie
  • *
  • Posts: 2
    • View Profile
Draw on an Image?
« on: October 15, 2008, 07:53:28 pm »
Hi!
I have a tilemap and doesn't want to run through the complete map and draw each tile each frame. So I wanted to make an extra Image where I just draw the tiles at the beginning, so I just can draw this image each frame.
But how can I draw on the ImageBuffer??
I tried to create an Image with the function image.Create(w, h, color) but what i have to after that??
I hope you can help me  :D

Wizzard

  • Full Member
  • ***
  • Posts: 213
    • View Profile
Draw on an Image?
« Reply #1 on: October 15, 2008, 08:56:06 pm »
This is not possible yet, but is planned for SFML. However, there is still a way to do tiles without the use of this feature. Using a sprite sheet image for a tile set, make a sprite container in which has all it's sprite's images set to the sprite sheet image. Then, for each individual sprite in the container, set the sub-rectangle of the sprite to the part of the sprite sheet image you want. After this initialization, loop through the container each frame, drawing the individual sprites. If done right, this will allow you create complex maps from reusable sprites.

Apprauuuu

  • Newbie
  • *
  • Posts: 2
    • View Profile
Draw on an Image?
« Reply #2 on: October 16, 2008, 10:35:55 pm »
Hmm but this runs a bit slow when I draw 2000 tiles per frame -.-
Am I able to use this function with OpenGl itself and include it into the program??

T.T.H.

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Draw on an Image?
« Reply #3 on: October 16, 2008, 10:55:40 pm »
For your info: drawing around 2500 tiles all being 256 x 256 pixel in size plus some more stuff on a 600 x 600 pixel screen I still reach frame rates around 60 FPS on my PC (AMD 2000+, ATI Radeon 9800 Pro, Win2000, VC++2005, Release Mode).

Wizzard

  • Full Member
  • ***
  • Posts: 213
    • View Profile
Draw on an Image?
« Reply #4 on: October 17, 2008, 09:47:23 pm »
Quote from: "Apprauuuu"
Hmm but this runs a bit slow when I draw 2000 tiles per frame -.-
Am I able to use this function with OpenGl itself and include it into the program??

You can use OpenGL with the graphics package, but it'll slow down the speed of the Draw member of RenderWindow.
This means that you will speed up your tile rendering performance, but slow down the rendering performance of everything else.
However, SFML is faster at rendering sprites than most APIs like it; perhaps you are doing something wrong.

zarka

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
Draw on an Image?
« Reply #5 on: October 18, 2008, 11:08:32 am »
Quote from: "Wizzard"
Quote from: "Apprauuuu"
Hmm but this runs a bit slow when I draw 2000 tiles per frame -.-
Am I able to use this function with OpenGl itself and include it into the program??

You can use OpenGL with the graphics package, but it'll slow down the speed of the Draw member of RenderWindow.
This means that you will speed up your tile rendering performance, but slow down the rendering performance of everything else.
However, SFML is faster at rendering sprites than most APIs like it; perhaps you are doing something wrong.


It doesn't have to be.. if you inherit a class from sf::Drawable you can render it using OpenGL without having to preserve SFMLs states. that is what i did with my particle system and it works quite well :)
//Zzzarka

 

anything