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 - sfUser

Pages: [1]
1
Graphics / Re: Letterbox effect using a view - not on position 0,0
« on: May 20, 2016, 08:44:43 pm »
I sat down and took the time to do the math and solved it.
Here it is for anyone interested.

gameViewPort - the viewport of the letterboxed view (usually the default views's / main view)
gameWindowSize - current game window size (ex: 1280x720)
gameBaseSize - base game window size (ex: 640x480)
viewPosition - position of the view to change (any view within the main view)
viewSize- sizeof the view to change (any view within the main view)

const auto& gameViewPort = //<insert letterboxed viewPort for reference>;

auto wndX = std::round(gameViewPort.left * gameWindowSize.x);
auto wndY = std::round(gameViewPort.top * gameWindowSize.y);
auto wndW = std::round(gameViewPort.width * gameWindowSize.x);
auto wndH = std::round(gameViewPort.height * gameWindowSize.y);

auto tmpX = (wndW * viewPosition.x) / gameBaseSize.x;
auto tmpY = (wndH * viewPosition.y) / gameBaseSize.y;
auto tmpW = (wndW * viewSize.x) / gameBaseSize.x;
auto tmpH = (wndH * viewSize.y) / gameBaseSize.y;

auto x = (wndX + tmpX) / gameWindowSize.x;
auto y = (wndY + tmpY) / gameWindowSize.y;
auto w = tmpW / gameWindowSize.x;
auto h = tmpH / gameWindowSize.y;

view.setViewport(sf::FloatRect(x, y, w, h));
 

2
Graphics / Re: Letterbox effect using a view - not on position 0,0
« on: May 18, 2016, 12:12:16 am »
I use views for displaying the map (the visible part) and for scrolling texts. None of these views occupy the whole screen.

3
Graphics / Re: Letterbox effect using a view - not on position 0,0
« on: May 16, 2016, 09:20:24 pm »
Sorry, my mistake. I rushed the post.

Still, the function doesn't work with views that not on 0, 0.

If anyone has done something similar, please share how.

4
Graphics / Letterbox effect using a view - not on position 0,0
« on: May 15, 2016, 12:45:41 pm »
Greetings,

Letterboxing a view when resized to keep the aspect ratio can be done as in the wiki example:
https://github.com/SFML/SFML/wiki/Source:-Letterbox-effect-using-a-view

However, this code assumes the view takes the whole screen and is at position 0, 0, as seen by these variables:
    float sizeX = 1;
    float sizeY = 1;
    float posX = 0;
    float posY = 0;

If I have a smaller view, such as a small map on the bottom right corner (therefore, a view not on 0,0 and with a size < window size),
what would be the changes to the code to make that work (it doesn't).

The best I could get was a function that added small increments as the window grew, which would shift it slightly to the right, bottom by changing the initial values (size, pos) to the viewport as expected on the normal screen:

        sizeX *= viewRatio / windowRatio;
        posX += (1 - sizeX) / 2.0;

Thank you. :)

5
Audio / Play parts of many soundBuffers as one audio
« on: January 31, 2016, 05:08:30 pm »
Hi there,

I would like to have a sound class that allows me to specify a certain number of soundBuffers and a specific duration on that sound buffer.

ex:

class Audio2 {
 // ((start time / stop time) /  buffer)
  std::vector<std::pair<std::pair<sf::Time, sf::time>, const sf::soundBuffer*>> buffers;
}

where the length of the audio would be the sum of the vector's time members  (difference between start and stop) and where soundbuffers could be repeated.

This would allow me to load 1/n sound buffers of dialogs and construct sentences using parts of those buffers.

So, If I had a buffer that played the sound of "hello" and another that played a sentence with the word "and" in the middle and a third that played "welcome", I could reproduce the sentence "Hello, and welcome" by adding 3 elements to the buffers with the soundBuffers of the tracks and a start and stop position in each buffer to play the part of the sound that corresponds to each word.

What would be the best approach I should take to implement this?
From what I saw, my best bet would probably be to implement this in SFML, to take advantage of private data that could facilitate this.

6
Here are the modified files (in comparison to the current git trunk) to be able to open using SFML's InputStream class.

I've tested on windows (vs2015).
Note: some files have the line endings converted to windows (were originally linux).

It is based on this SO post:
https://stackoverflow.com/questions/19785254/play-a-video-from-memorystream-using-ffmpeg

It doesn't appear to have memory leaks. The program I tested read a movie from a zip file using SFML's physFS class available in the SFML's wiki.

Feel free to incorporate this into sfeMovie, if you wish to, or modify the code to better reflect your coding conventions.

NOTE2: there is a warning converting from sf::Int64 to int in the read function (just remembered now).

7
Yes, but after building ffmpeg, i opened the generated solution and compiled sfeMovie + the sample project.
In fact, I already added openFromStream to sfeMovie and its working OK.
I'll refactor the code a bit and post it here for your consideration.

8
OK, so I was able to build everything.

The log you mentioned gave me an error which led me to open a visual studio 2013 command prompt and then open msys2_shell.bat. This way the msys2 shell lib paths are properly set (were missing).
Then, I ran the build_ffmpeg.sh windows 1
afterwards, some packages were missing from msys, namely diffutils and pkg-config
And that's it.

9
I get this error:

cl is unable to create an executable file.
If cl is a cross-compiler, use the --enable-cross-compile option.

which is common and documented on ffmpeg's website, however, cl is pointing to the right bin.
If i do "where cl" I get the proper path of vs 2013. I also deleted link as suggested on ffmpeg's website to avoid conflits, but I still fail here.

tar -C "/tmp" -xjf "/sfeMovie/sfeMovie-master/FFmpeg/ffmpeg-2.8.tar.bz2"
/tmp/ffmpeg-2.8/configure  --disable-programs --disable-doc --disable-network --disable-decoders --disable-muxers --disable-encoders --yasmexe="/msys32/usr/bin/yasm.exe" --enable-shared --disable-static  --enable-memalign-hack --toolchain=msvc

That's why I asked for a pre-built ffmpeg .lib that allows me to build sfeMovie + examples without building ffmpeg. I then tried ffmpeg's latest version (2.8.4) and got the same error.

10
Hi there,

I would like to add a OpenFromStream to sfeMovie, using something like this:
https://stackoverflow.com/questions/19785254/play-a-video-from-memorystream-using-ffmpeg
http://www.codeproject.com/Tips/489450/Creating-Custom-FFmpeg-IO-Context
Using SFML's InputStream interface.

I seems simple, so I was thinking of implementing it myself, so I downloaded the master branch from github and followed the guide to compile but I get an error compiling ffmpeg.

Can someone provide a link to a fully compiled CMAKE generated project for vs2013 or vs2015 with all the libs already built, so that I only need to compile my changes to the sfeMovie project, instead of the whole solution?

Thanks in advance.

11
General discussions / Re: Visual Studio 2015 cross-platform template
« on: August 15, 2015, 12:15:53 pm »
OK, I understand the reasons for the ANGLE/NuGet parts.
I'm not complaining, SFML was one of the easiest C++ projects I ever set up (most open source c++ projects are a pain to build).
In fact, that's one of my criteria for choosing open source libraries :)

The template thing is nice because it allows you to test/debug on MSVC/Clang/GCC all within visual studio, which will give you hints if you are using things not supported on all platforms/compilers. Also, you can test/remote debug android/iOS the proper way ;D

I still think it would be nice to include such template in the examples folder for a future release. I also don't have the iOS part, If i have the time, I will try to set up a simple project and put it here for reference.

12
General discussions / Visual Studio 2015 cross-platform template
« on: August 15, 2015, 11:03:12 am »
Hi there.

First of all, let me just thank the SFML community for the great project (been using it for a while).

As you probably already know, visual studio 2015 (and 2013?) allow us to create projects for various platforms.

I think it would be nice for you to have a template for visual studio to use SFML on Windows/Android/iOS similar to this one from Microsoft: http://blogs.msdn.com/b/shawnhar/archive/2015/07/29/visual-studio-template-for-cross-platform-opengl-development.aspx

I know WPhone/WinRT is not yet supported, but the initial template could have classic win32/Android/iOS templates instead. As a bonus, you could add WinRT support using ANGLE and OSX/Linux project templates as well.

Just something to consider for a next release. You could add it to the samples folder with a simple OpenGL hello world demo.

Also, will you ever offer SFML through NuGet? I know there is an unofficial version, but it's not official nor updated. You could create the template using nuget to get SFML.

Also, the comments in the forum about ANGLE are a bit old. SFML already works with Android/iOS, which use OpenGL ES 2, so using ANGLE for WP/WinRT shouldn't be such a hurdle now, right?

Thanks and keep up the good work :)

Pages: [1]
anything