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

Author Topic: Paint  (Read 4255 times)

0 Members and 1 Guest are viewing this topic.

troopson

  • Newbie
  • *
  • Posts: 30
    • View Profile
Paint
« on: June 14, 2011, 07:32:27 pm »
I'm trying to make a Paint application.
How do i draw shapes/lines to a buffer like Image ? I can't paint everything directly to the window because when i resize/move etc the window it all dissapears. I wanted to do something like draw everything to an image and in main loop draw the image. How do i do that in sfml?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Paint
« Reply #1 on: June 14, 2011, 08:02:40 pm »
You can't draw to an image with SFML 1.6.

Quote
I can't paint everything directly to the window because when i resize/move etc the window it all dissapears.

???
Maybe we should try to solve this problem instead ;)
It looks like you're only painting things once, whereas they should be painted in an infinite loop that clears/draws/displays.
Laurent Gomila - SFML developer

troopson

  • Newbie
  • *
  • Posts: 30
    • View Profile
Paint
« Reply #2 on: June 14, 2011, 10:44:03 pm »
"It looks like you're only painting things once, whereas they should be painted in an infinite loop that clears/draws/displays."

well... u want me to draw 923592592 lines and remember it all ?Any other ideas?:P

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Paint
« Reply #3 on: June 14, 2011, 10:57:39 pm »
Quote
well... u want me to draw 923592592 lines and remember it all ?Any other ideas?

How do you implement undo/redo ? ;)

Anyway, you should switch to SFML 2. Drawing to an image is the only other solution, and it is not available in SFML 1.
Laurent Gomila - SFML developer

David

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Paint
« Reply #4 on: June 15, 2011, 03:54:07 am »
Quote from: "Laurent"
Quote
well... u want me to draw 923592592 lines and remember it all ?Any other ideas?

How do you implement undo/redo ? ;)

Anyway, you should switch to SFML 2. Drawing to an image is the only other solution, and it is not available in SFML 1.


What do you mean by drawing to an image?

You can make a pixel-sized image and create a dynamic array so you'll be able to undo/redo and save. If the pixels aren't limited to the FPS (maybe you can make it a triple digit number, I haven't tested this out), it should work out. You can also create a funky algorithm that creates a line made up of more pixels if there happens to be a gap between them

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Paint
« Reply #5 on: June 15, 2011, 06:59:11 am »
Quote
What do you mean by drawing to an image?

I mean this
Code: [Select]
sf::Image image;
sf::Sprite sprite;
image.Draw(sprite);

(it's not like this in SFML 2 but it's more obvious this way)
Laurent Gomila - SFML developer

AlexRAwesome

  • Newbie
  • *
  • Posts: 10
    • View Profile
Paint
« Reply #6 on: June 15, 2011, 12:48:37 pm »
Quote from: "Laurent"
Quote
What do you mean by drawing to an image?

I mean this
Code: [Select]
sf::Image image;
sf::Sprite sprite;
image.Draw(sprite);

(it's not like this in SFML 2 but it's more obvious this way)


It kinda looks like you're drawing nothing because "sprite" does not have an image set
Just starting SFML

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Paint
« Reply #7 on: June 15, 2011, 12:57:01 pm »
Quote
It kinda looks like you're drawing nothing because "sprite" does not have an image set

Did you actually read the previous messages before answering? :lol:

This piece of code was just an example to show what rendering to an image means. It's not supposed to do anything useful...
Laurent Gomila - SFML developer

troopson

  • Newbie
  • *
  • Posts: 30
    • View Profile
Paint
« Reply #8 on: June 15, 2011, 04:16:42 pm »
i dont want to write code which draws a line/circle/stuff (know its not so hard);p

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Paint
« Reply #9 on: June 15, 2011, 04:23:45 pm »
Quote from: "troopson"
i dont want to write code which draws a line/circle/stuff
But you want to write Paint?

What's wrong with the solutions given in this thread?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything