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.


Messages - jjjaime

Pages: [1]
1
General / Re: Shape deformed after resizing the window
« on: April 01, 2013, 05:14:09 pm »
Thanks. It works. I've used the following code:

if (event.type == sf::Event::Resized) {
      window.setView(sf::View(sf::FloatRect(0, 0, event.size.width, event.size.height)));
}
 

I will look into the View class. However, I cannot understand why it is required. I guess that the normal situation should be that the whole window corresponds to a view unless it is modified by the developer.

2
General / Shape deformed after resizing the window
« on: April 01, 2013, 02:55:30 pm »
I've created a very simple app that renders a square with size 200:

sf::RectangleShape rectangle;
rectangle.setSize(sf::Vector2f(200, 200));
rectangle.setFillColor(sf::Color::Magenta);
rectangle.setPosition(10, 10);
window.draw(rectangle);
 

The square is rendered correctly. However, when the window is resized, the square is deformed into a rectangle and the size is reduced or increased according to the size of the window. Perhaps it's my misunderstanding and size and position are related to the window size? Is that correct? How could I create a shape with a specific size (and the same in height and width)?

I'm using the SFML v2.0 available at http://www.sfml-dev.org/download.php (not the latest version in Git).

3
General / Re: [SOLVED] High CPU consumption (SFML 2.0 in MacOSX)
« on: March 30, 2013, 12:16:32 pm »
The music file is nice_music.ogg (the one provided by the SFML template for XCode). However, I've tested the same with other file formats: mp3 is not supported and wav offers the same bad results.

My tests have been done with a MacBook Pro, the system is up-to-date and I'm not sure if it's a driver problem. The tests have been done by generating an archive file (in XCode), that creates the app (I guess with all the possible optimizations).

Googling with coreaudiod, it looks like there's a problem with this process (that it was even worse in the past). So I guess SFML is not to blame.

4
General / Re: High CPU consumption (SFML 2.0 in MacOSX)
« on: March 29, 2013, 11:05:29 am »
I close this post because the main part of the problem (except the music part) was already solved.

5
General / Re: High CPU consumption (SFML 2.0 in MacOSX)
« on: March 29, 2013, 11:04:00 am »
In this case, I disagree with you. I haven't said that the CPU was idle. Other programs were already opened (e.g. XCode4, many tabs of Chrome, ...). I've just compared the low CPU usages of those processes, that actually are doing much more than the SFML basic application (generated with the XCode template and modified to include some performance improvements).

If Chrome process ranges from 1.4 to 2.3 %CPU, why the sound process ranges from 9 to 10 %CPU  with and without music? For me, that's actually a performance problem. Finally, with some tuning, I could get reasonable values for the rest of the application, except the music part.

6
General / Re: High CPU consumption (SFML 2.0 in MacOSX)
« on: March 28, 2013, 09:11:43 pm »
I'm afraid that the main performance problem is the music. With music enabled, the coreaudiod process uses 9%. Disabling music, this process uses insignificant CPU and the app uses half CPU. Perhaps it is a problem related with my laptop configuration.

7
General / Re: High CPU consumption (SFML 2.0 in MacOSX)
« on: March 28, 2013, 07:21:11 pm »
I don't want to build an app GUI with SFML. I agree that SFML does not target it. However SFML should not target only games (it's not the project description: "simple and fast multimedia library")

However, if you build a turn-based game, it is possible that the interface is frozen during game AI or while user is thinking. Repainting something that has not changed is inefficient. If your game has a lot of AI, then perhaps you are dedicating some valuable resources to repainting when they are not actually necessary. I understand that this is not a stopper for majority of "games", but I'd say that it should be convenient to include this feature.

Imagine that you build an application that plays music/radio while rendering some beautiful photos or 3D animations. Perhaps the user could use this app most of the time in background mode, and the app would use a lot of CPU when the game does not require rendering (is in background). It could also happen that users hide their games in background during work time  :P

Anyway, I don't have any special idea to build with SFML yet. I'm just interested in animation and was looking into this library. My first impression is good although I miss that feature.

8
General / Re: High CPU consumption (SFML 2.0 in MacOSX)
« on: March 28, 2013, 05:42:54 pm »
Thanks Laurent.
Using either setVerticalSyncEnabled or setFramerateLimit, the rate limit is set to 60. With this approach, the CPU is reduced considerably:
- Window Server process: 5%
- SFMLApp: 5%
- coreaudiod: 9%

However I consider it's still too high for a frozen image that does not require any update.

What I've also confirmed is that using the isDirty bool trick to know when to update the view (window.display()) is even much worse. Using isDirty, setVerticalSyncEnabled/setFramerateLimit do not take effect and the frame rate reaches almost 10000 fps. The window might not be refresh with this frequency, but the frequency of the event loop is too high and the CPU reaches 100%. I guess that there's a direct link between window.display() and the frameratelimit. Is it correct?

Is there a chance to avoid updating the window when there's no change to render? Or to update a fragment of the window?

It's also very high the CPU used by the audio, isn't it? As I said, the CPU usage is constant although the music has stopped playing.

9
General / [SOLVED] High CPU consumption (SFML 2.0 in MacOSX)
« on: March 28, 2013, 02:27:16 pm »
I've just started playing with this framework and it looks clean and simple. The default application created with XCode template for SFML 2.0 includes just a background image and music. It is a fairly simple app.

However, the window.isOpen() loop is executing continually, updating the window, even though the window has not change at all. Is this a correct approach? The CPU consumption is too high for such an application:
- Window Server process: 20%
- SFMLApp: 16%
- coreaudiod: 7%

It is about 43% of CPU consumption (e.g. Google Chrome is consuming about 1.6% for each tab).

I've also modified the previous app to include a sprite moving with a key stroke. To about updating the window when there was no change in the scene, I've added a isDirty bool variable. It made things even worse because the window.isOpen() loop is executing continually and reachs about 100% of CPU.

After changing the code a bit to sleep (100 ms) when isDirty was false, the CPU consumption was more acceptable:
- Window Server process: 0.8%
- SFMLApp: 2.7%
- coreaudiod: 7%

What is the correct approach to handle the event loop? I've seen that all the tutorials follow the same pattern but I don't think it's very efficient. Perhaps a callback approach could improve this performance issues.

Is it normal to redraw the whole window?

Why does the audio reach 7% of CPU even though there is no more music?

10
General / Re: Compiling SFML 2.0 Program on OSX
« on: March 28, 2013, 02:06:19 pm »
I had the very same problem yesterday  :)

It is related to the include directory. It looks like the latest version of XCode has changed a bit the default include directories.

I installed the latest XCode templates available at:
https://github.com/SFML/SFML/tree/master/tools/xcode/templates

I also had to install the FreeType framework (available at: http://www.kyngchaos.com/software/frameworks).

Pages: [1]
anything