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

Author Topic: The new graphics API in SFML 2  (Read 80033 times)

0 Members and 2 Guests are viewing this topic.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
The new graphics API in SFML 2
« Reply #90 on: September 23, 2011, 04:05:41 pm »
Quote
Perhaps incorporating the word 'crop' would be more descriptive, that's what is used in image editing programs to describe essentially the same function as SubRect.

Can "crop" be used as a noun? I thought it was only a verb, with no corresponding noun.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
The new graphics API in SFML 2
« Reply #91 on: September 23, 2011, 04:14:53 pm »
It can, but I spontaneously think of cereals when I hear it :)
And "crops" is probably more widespread, at least according to my experience...

It actually isn't expressive at all, one has to know the term to understand it. That's why I prefer something like TextureArea (or TextureRect?).
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Lo-X

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
    • My personal website, with CV, portfolio and projects
The new graphics API in SFML 2
« Reply #92 on: September 23, 2011, 05:25:34 pm »
That make me think... It is possible to add a method sf::Drawable::GetCollisionRect(sf::View&) ? which return a rect but already with proper coordinates ? Not too difficult to do it actually but, I ask... :p

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
The new graphics API in SFML 2
« Reply #93 on: September 23, 2011, 05:34:28 pm »
sf::Drawable will disappear. And what would the view argument be used for? Collisions are usually computed in global coordinates, while views are used only for displaying things in a target. Moreover, a rectangle in global coordinates can be rotated, which SFML doesn't support.
Laurent Gomila - SFML developer

Mikademus

  • Newbie
  • *
  • Posts: 31
    • View Profile
The new graphics API in SFML 2
« Reply #94 on: September 23, 2011, 07:07:53 pm »
"sf::Drawable will disappear"

That will have a rather huge impact on my codebase. Currently there are functions that works along this way:

Code: [Select]

void func( RenderTarget &rTarget )
{
Drawable *pDrawable = 0;

switch (something)
{
   case st1: pDrawable = &mySprite; break;
   case st2: pDrawable = &myCircle; break;
   case st3: pDrawable = &myRectagle; break;
}

pDrawable->SetPosition( myPos );
pDrawable->SetRotation( myRot );
pDrawable->SetColor( myCol );

rTarget.Draw( pDrawable );
}


How will the removal of th Drawable interface affect my code?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
The new graphics API in SFML 2
« Reply #95 on: September 23, 2011, 07:14:32 pm »
Laurent also said:
Quote from: "Laurent"
I think I'll create a Drawable base class, but it would only define a virtual Draw function, so that people can write window.Draw(object)
I understand his latest statement in the way that sf::Drawable disappears in its current state (with all the transformations).

And in general, templates are a possible alternative to dynamic polymorphism.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
The new graphics API in SFML 2
« Reply #96 on: September 23, 2011, 07:16:27 pm »
Quote
That will have a rather huge impact on my codebase

I know, and you're not the only one ;)
The current API is too limited so it needs a complete redesign. I'll try to keep high-level classes as close to their current version as possible, but abstractions such as sf::Drawable won't work anymore.

So your function would be a little more verbose, but depending what you want to achieve their may be better strategies with the new API.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
The new graphics API in SFML 2
« Reply #97 on: September 23, 2011, 07:20:22 pm »
Quote from: "Laurent"
The current API is too limited so it needs a complete redesign. I'll try to keep high-level classes as close to their current version as possible, but abstractions such as sf::Drawable won't work anymore.
Now you confuse me :D

I don't expect a definitive statement, but do you currently tend to provide a sf::Drawable class (just as drawing interface) or rather not? If not, how are objects drawn? sprite.Draw(window)? Personally, I'd like a sf::Drawable class for those abstraction reasons.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
The new graphics API in SFML 2
« Reply #98 on: September 23, 2011, 07:26:22 pm »
Quote from: "Laurent"
I was thinking about renaming "SubRect" in sf::Sprite. Would "TextureArea" or TextureRegion" be better?
TextureArea sounds better than TextureRegion because region doesn't always have fixed boundaries.
SFML / OS X developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
The new graphics API in SFML 2
« Reply #99 on: September 23, 2011, 07:29:00 pm »
Sorry for the confusion :D

I'm sticking with the latest conclusions:
Code: [Select]
class Drawable
{
private :

    friend class RenderTarget;

    virtual void Draw(RenderTarget&) = 0;
};

class Transformable
{
    position / rotation / scale / origin
};

class Sprite : public Drawable, public Transformable
{
    texture, texture area, color
};
Laurent Gomila - SFML developer

gsaurus

  • Sr. Member
  • ****
  • Posts: 262
    • View Profile
    • Evolution Engine
The new graphics API in SFML 2
« Reply #100 on: September 23, 2011, 08:01:39 pm »
Quote from: "Hiura"
TextureArea sounds better than TextureRegion because region doesn't always have fixed boundaries.

Area also does not suggest a rectangular area. Maybe TextureRect
Pluma - Plug-in Management Framework

Mikademus

  • Newbie
  • *
  • Posts: 31
    • View Profile
The new graphics API in SFML 2
« Reply #101 on: September 23, 2011, 09:10:23 pm »
SourcePixels

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
The new graphics API in SFML 2
« Reply #102 on: September 23, 2011, 09:36:23 pm »
Quote from: "Laurent"
I'm sticking with the latest conclusions:
Okay, I already thought about an own Drawable wrapper that would store high-level objects via type erasure to allow abstraction nevertheless :P

Quote from: "Laurent"
Code: [Select]
class Drawable
{
private :

    friend class RenderTarget;

    virtual void Draw(RenderTarget&) = 0;
};
So, Draw() actually replaces the old Render()?

Quote from: "Hiura"
Quote from: "Laurent"
I was thinking about renaming "SubRect" in sf::Sprite. Would "TextureArea" or TextureRegion" be better?
TextureArea sounds better than TextureRegion because region doesn't always have fixed boundaries.
And TextureRect sounds better than TextureArea because it indicates a rectangular area. Plus, it is closer to the existing term SubRect, making code porting easier.

Quote from: "Mikademus"
SourcePixels
Not good in my opinion, since the sub-rectangle doesn't store any pixels.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Mikademus

  • Newbie
  • *
  • Posts: 31
    • View Profile
The new graphics API in SFML 2
« Reply #103 on: September 23, 2011, 10:17:29 pm »
Quote from: "Nexus"
Quote from: "Mikademus"
SourcePixels
Not good in my opinion, since the sub-rectangle doesn't store any pixels.

SourcePixelRect
SourcePixelArea

You can't get more descriptive and explanatory than that.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
The new graphics API in SFML 2
« Reply #104 on: September 23, 2011, 10:54:10 pm »
Well, if we have sf::Texture it's more consistent to have TextureSomething than SourcePixelSomething.

Now about the "something"-part, like Nexus said "rect" seems to fit the job for sprites as they are rectangular. But what about shapes ? If shapes also have texture ( ? ) then rect doesn't fit and having two different names can be confusing. So if they have texture then "area" seems better to me, otherwise I agree with TextureRect.
SFML / OS X developer

 

anything