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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Laurent

Pages: 1 2 [3] 4 5 6
31
General discussions / The new graphics API in SFML 2
« on: September 11, 2011, 10:40:16 pm »
Hi

I'm currently out of inspiration for the new graphics API. So I thought it would be a good idea to share what I've done so far, and use your feedback to complete this task :)

I decided to start with the lowest level. I needed something flexible enough so that people stop complaining about performances or limitations, but still easy to use; and as a bonus, something that will allow me to drop deprecated functions so that SFML can be ported to pure OpenGL (ES) 2 architectures.

The result is something very close to how OpenGL works, and it contains the 5 ingredients required by modern rendering architectures:

Textures
sf::Texture is left unchanged.

Shaders
sf::Shader is left unchanged, but it will later be upgraded to support vertex shaders.

Transforms
They will be handled by a new class, sf::Transform. Internally a transform is a 3x3 matrix, but its public API provides the usual functions: Translate, Rotate, Scale, Combine (with other matrix), TransformPoint, GetInverse, and some operator overloads.
So, transformations are now completely separated from drawables, and are much more flexible.

Geometry
Geometry is no longer hidden behind high-level classes, it is now directly exposed.
Vertices are defined with a new class, sf::Point. It's very simple, it contains 3 public members (Position, Color, TexCoords) as well as a bunch of constructors to easily construct points with 1, 2 or 3 of these attributes.
On top of that there's a sf::Mesh class (its name can change if you have better ideas), which is a thin layer on top of OpenGL vertex arrays. It is also quite simple: it combines a dynamic array of sf::Point (Resize, operator[], Append, ...) with a primitive type which defines how the points must be interpreted as geometrical primitives when they are rendered (for example it can be Points, Lines, Triangles, Quads, ...).

Renderer
All these things are put together in the sf::RenderTarget class (the same as now, the base of RenderWindow and RenderTexture), with the following functions:
- SetView(sf::View)
- SetTransform(sf::Transform)
- SetTexture(const sf::Texture*)
- SetShader(const sf::Shader*)
- SetBlendMode(sf::BlendMode)
- Draw(sf::Mesh)

Here is a typical example, a tiled map:
Code: [Select]
const int size = 32;

// load the texture containing all the tiles
sf::Texture tileset;
tileset.LoadFromFile("tileset.png");

// create the map
sf::Mesh map(sf::Quads, width * height * 4);
for (int x = 0; x < width; ++x)
    for (int y = 0; y < height; ++y)
    {
        int current = (x + y * width) * 4;

        // define the position of the 4 points of the current tile
        map[current + 0].Position = sf::Vector2f((x + 0) * size, (y + 0) * size);
        map[current + 1].Position = sf::Vector2f((x + 0) * size, (y + 1) * size);
        map[current + 2].Position = sf::Vector2f((x + 1) * size, (y + 1) * size);
        map[current + 3].Position = sf::Vector2f((x + 1) * size, (y + 0) * size);

        // define the texture coordinates of the 4 points of the current tile
        int tx = /* X index of the tile in the tileset */;
        int ty = /* Y index of the tile in the tileset */;
        map[current + 0].TexCoords = sf::Vector2i((tx + 0) * size, (ty + 0) * size);
        map[current + 1].TexCoords = sf::Vector2i((tx + 0) * size, (ty + 1) * size);
        map[current + 2].TexCoords = sf::Vector2i((tx + 1) * size, (ty + 1) * size);
        map[current + 3].TexCoords = sf::Vector2i((tx + 1) * size, (ty + 0) * size);
    }

// let's scale and translate the whole map
sf::Transform mapTransform;
mapTransform.Scale(2, 2);
mapTransform.Translate(500, 400);

...

// draw the map
window.SetTexture(&tileset);
window.SetTransform(mapTransform);
window.Draw(map);


Building the map is a little more verbose than with sprites, but the whole map is now a single 2D entity and it can be drawn with a single call (which is very fast -- no need for tricks such as manual clipping or pre-rendering to a texture).

That's it for the new low-level API. Hopefully, users who required more flexibility and/or performances will be happy with it.
But it's not enough: it's very low-level, a lot of SFML users enjoy the simplicity of the high-level classes and I don't want to force them to use these classes.

I can easily implement the old sf::Text, sf::Sprite and sf::Shape classes on top of this new API. But it would probably not be a good idea. These classes were required in the old API because they were the only way to draw things on screen. But now that we have a low-level layer that can do almost everything, these classes would exist only for convenience. Therefore, maybe we can think of something different. And we must also decide how these classes would mix with the low-level layer: do they define and use their own transform, or the one that is set with SetTransform? Should they inherit a base class, that would allow to write "window.Draw(sprite)"? Or rather define a Draw function in all of them so that we would write "sprite.Draw(window)"?

I actually have a lot more pending questions and problems, but let's see what you think about this ;)

Don't hesitate to comment the low-level API, suggest features or modifications, propose ideas for the high-level classes, etc. But please don't focus on details (except class names), here we are talking about general concepts.

PS: sorry for those who, after reading the title, thought that the new API was already written and pushed :lol:

32
General / ===== Read before posting =====
« on: August 12, 2011, 02:22:45 pm »
Hi :)

This thread gathers some simple rules to follow before posting.

They will help you to:
- identify the problem more clearly (and sometimes solve it!) before posting
- write a helpful and relevant help message
- have more answers
- avoid the same questions again and again (what's your OS? what's the error message? can you post a minimal code?) and get the relevant answers faster

33
General discussions / sf::Texture implemented in SFML 2
« on: August 06, 2011, 11:30:53 pm »
Hi :)

I've finally managed to work on the old task of splitting sf::Image into two separate classes: sf::Image (with less features) and a new sf::Texture class.

Here is a list of modifications, and I let you read the doc for more detailed information:
- sf::Texture replaces sf::Image almost everywhere (sf::Image is now used only for pixels manipulation, not for drawing)
- sf::Sprite now takes a sf::Texture (Set/GetImage are now Set/GetTexture)
- There's no more sf::Sprite::GetPixel (see below)
- sf::RenderImage is not sf::RenderTexture
- sf::RenderWindow::Capture is back
- I also added sf::Image::FlipHorizontally and FlipVertically

The only drawback of this modification is that you can't retrieve pixels from a texture, and thus from a sprite, anymore. For pixel-perfect collision detection you must now store the collision data yourself (which allows more optimizations, by the way).

I've probably forgotten a few things, so don't hesitate to ask question :)

34
Here:

- https://github.com/SFML/CSFML

- https://github.com/SFML/SFML.Net



There's only one branch, master, which matches the master branch of the SFML repository. This means that CSFML 1.6 and SFML.Net 1.6 are not available on their repository (but we don't care since the 1.x branch has not evolved after the 1.6 release).



SFML.Net is self-contained but CSFML still requires SFML headers and libs to be installed somewhere. I don't add them to the repository as an extlib, it would require too many precompiled versions (x86/x64, vc++/mingw, 2005/2008/2010, 3.x/4.x, ...).



Both bindings now have their own task tracker on github. Everything else remains available on the main website/forum, nothing's changed.

35
General discussions / New global inputs in SFML 2
« on: July 05, 2011, 11:19:34 pm »
Hi

I've totally broken the sf::Input class. It has disappeared and is replaced with three new static classes: sf::Keyboard, sf::Joystick and sf::Mouse. These are now connected directly to the OS functions, and thus are no longer connected to a particular window.

The consequence is that there's no more bug related to focus, etc.

I've added a few features to joysticks: you can check their connection state, via sf::Joystick::IsConnected or the new JoystickConnected / JoystickDisconnected events.

I've also renamed/reorganized a few things.

I've implemented sf::Window::GetCursorPosition.

Special note on sf::Mouse::GetPosition: to be useful, it doesn't return the position in desktop coordinates, but rather in coordinates relative to the current focus window (the one which has the mouse cursor over it).

The OS X implementation is not done yet, but it will be updated by Hiura as soon as he can.

The C, .Net bindings and the online doc are up-to-date.

Have fun :)

36
General discussions / A new logo for SFML
« on: June 02, 2011, 10:57:03 am »
Hi

When SFML was born a few years ago (I don't remember how many :lol:), I quickly "created" a logo for it, with a set of free icons found on the internet and a random font.

So I was thinking, maybe we can do better now :)

I'm not an expert at drawing logos, but I'm sure there are talented people on this forum. So if you want to give it a try, feel free to design a new logo and post it here.

There are only two conditions:
- the logo has to be under a very permissive license
- it must be compatible with the green and blue theme of the website

37
Hi

A major API break today: I changed all times to be Uint32 number of milliseconds instead of float number of seconds.

It may potentially break a lot of code, so... good luck for updating :mrgreen:

Here is a list of what is modified by this update:
- sf::Clock::GetElapsedTime
- sf::Window/RenderWindow::GetFrameTime
- sf::SoundBuffer/Music::GetDuration
- sf::SoundStream/Sound/Music::Set/GetPlayingOffset
- sf::SoundStream::OnSeek
- timeouts in sf::Http/Ftp/TcpSocket/IpAddress/SocketSelector

As a bonus, I also added the sf::Int64 and sf::Uint64 types.

38
General discussions / Task tracker
« on: April 15, 2011, 08:05:15 am »
Hi

I'd like you guys to follow this simple rule for the task tracker: please don't rush on it if the last commit broke something. It happens a lot, and it's usually fixed within a few hours or days. Sometimes it's work in progress that needs testing, sometimes it's just me that forgot something or made a stupid mistake.

This kind of issue is best discussed here on the forum, it doesn't deserve a ticket on the task tracker.

Thank you.

39
General discussions / New wiki
« on: April 01, 2011, 06:08:39 pm »
The new wiki is ready on github.

Of course it's empty, I only copied the "home" and "rules" pages :lol:

The old wiki will still be reachable at its original address until everything is copied to the new one.

I also removed the french part, now it's english only.

40
General discussions / New task tracker
« on: March 27, 2011, 09:07:28 pm »
The new task tracker is online:
https://github.com/SFML/SFML/issues

I chose not to add the old tasks, I'm restarting from zero now.

So, how does it work:
- login to github
- go to the SFML task tracker page
- click "Create issue"
- fill the title and description; labels must be added by an admin (me)
- I'll inspect every new tasks, and comment/reject it if necessary
- you can also vote for tasks that you like

So... feel free to add tasks for bug reports or features requests.

41
General discussions / SVN closed
« on: March 26, 2011, 11:29:33 am »
The SVN repository is now officially closed. From the sourceforge admin panel, it was not clear what exactly this means; you can maybe still update, but hopefully not commit anymore :)

-> Hiura: you'll have to create an account on github so that I can add you to the project team. If you need help on Git or anything just let me know.

-> Bindings maintainers: the best solution would be to create a separate repository for each binding; let me know what you think about it, what you'd like to do, etc.

I don't know if the snapshots links on the website still work, I'll redirect them to github as soon as possible.

42
General discussions / Github repository
« on: March 25, 2011, 09:44:49 am »
Hi

I've created the github repository and uploaded the latest SVN revision:
https://github.com/SFML/SFML

Important
- "trunk" is now branch "sfml1" on Git
- "branches/sfml2" is now "master" on Git

I'll probably need some time to finalize everything, setup the wiki and task tracker etc. so please use everything as read-only for now (ie. don't add/modify anything).

I'll let you know when everything's ready.

As long as the SVN repository is there you can still commit to it, I'll sync the latest modifications after I close it, so that nothing is lost.

43
General discussions / ATI fix
« on: March 21, 2011, 08:11:36 am »
Yes... finally... it's there :D

The other good news is that sf::Context is not necessary anymore in threads. And it was not transformed to sf::GraphicsContext or whatever, I managed to simply get rid of it.

Note that this is a first step, now there might be bugs to fix. My next task is to make sf::RenderImage more robust (and cleaner internally), it has too many bugs and maybe more now with the ATI fix.

Note: I tried to adapt the Linux and OS X code as well but couldn't compile, so let me know if there's something stupid that needs to be fixed.

44
General discussions / My plans for the website tools
« on: March 18, 2011, 01:19:53 pm »
Hi

In my process of upgrading/changing everything before SFML 2 is out, today I've decided which tools I'm going to use. Just let me know what you think about it ;)

* forum : SMF 2.0 RC5
* code repository : switching from SVN to GIT, and from sourceforge.net to github
* task tracker : the one provided by github
* wiki : the one provided by github

In case you're scared by so many changes:
- I can export the current forum to the new one without losing anything
- I can export the current SVN repository to the new one without losing anything
- I can export the current tasks to the new tracker manually, there's not much to do :D
- I will probably not be able to import the wiki however, so I think I'll need a little help for that

I keep it short, just ask questions if you want or leave your comments ;)

45
General discussions / [SFML 2] I need your help for the ATI fix
« on: March 01, 2011, 09:02:22 pm »
Hi

The fix is finally implemented, it's a shame it took me so long because the code is really really straight-forward. Well, it involves a major design modification that I don't really like, that's why it was not implemented before. So it's not a magic fix, it's a new design that allows SFML to get rid of this bug.

But anyway. This API change adds a new class, which is in fact nothing more than sf::Context. But now it is required in the main thread as well (unless you create a render target first). And I need you to... find a name for it :D

I don't like sf::Context because it's not meaningful at all. It refers to an implementation detail that most users (especially beginners) won't understand. This class must be used to enable graphics calls in a thread -- so I guess its name should refer to the Initializer/Thread/Graphics words. I really have no idea, so please help me ;)

Here is an example:
Code: [Select]
void func()
{
    sf::???? ???;

    sf::Image image;
    image.LoadFromFile("...");
    ...
}

int main()
{
    sf::??? ???;

    sf::Thread t(&func);
    t.Launch();

    sf::RenderWindow window;
    ...

    return 0;
}


After we all agree on a perfect name, I'll commit the fix, let you test, and try to boost my motivation to release SFML 2 soon. Even if it means dropping the changes I wanted to make on the drawable system.

I'll clean the task tracker as well, and *really* start to use it: I'll put there all the remaining tasks for SFML 2 (the real ones), all bugs, suggestions, etc. that were collected in my private text-file-todo-list.

Pages: 1 2 [3] 4 5 6