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

Recent Posts

Pages: [1] 2 3 ... 10
1
General / Re: Can't compile "SFML Works" example project on m1 Mac
« Last post by Mikeygoldman1 on September 18, 2021, 03:04:18 pm »
Are there other options to get SFML to work on MacBook Air M1 without using CMAKE. I am a beginner in C++, so any help would be appreciated.
2
Audio / Re: Getting the actual volume of a sound/music
« Last post by WilliamKappler on September 17, 2021, 11:40:50 am »
Understandable. I'll just use that formula to get (approximate?) it on my end. Should be good enough. Thanks!
3
Audio / Re: Getting the actual volume of a sound/music
« Last post by eXpl0it3r on September 17, 2021, 09:37:39 am »
There's no way to retrieve it.
SFML uses OpenAL underneath which will do the calculation. Not sure if OpenAL even reports the current "volume".
4
Window / Re: Using SFML as a child window without access to Event Loop
« Last post by burn.it.all.down on September 17, 2021, 05:51:28 am »
For those interested, I've managed to get SFML working pretty well whenever there's not direct access to an event loop AND whenever you have to create a native Win32 child window first that SFML then consumes. Some gotchas:

1. SFML takes over whatever data you've stored in SetWindowsLongPtr GWLP_USERDATA with its own sf::priv::WindowImplWin32, which you don't have public access to.

2. SFML doesn't trigger any events on WM_TIMER, so you'll need to SetTimer() with your own callback in order to create your own event loop. You'll need to map the child HWND used with SetTimer to your class due to issue 1.

3. Don't create the win32 child window using CW_USEDEFAULT for width and height because it'll return 0, which makes SFML scale things oddly. Know your starting window size in advance, if possible, by getting it from another API or using GetWindowRect. Somebody with more SFML experience may know how to scale properly once your original size is set to zero and then you call sf::Window::setSize( { >0, >0 } ).

4. Don't mistakenly call sf::Window::create() AFTER other adjustments, such as setSize, setActive because you haven't actually created anything yet and you'll bang your head

5. You must call SetFocus( getSystemHandle() ) directly on timer callback or else keyboard events won't be available. The sf::priv::WindowImplWin32::requestFocus() calls SetForegroundWindow() when on the same process thread or flashes a window notification but there's nothing in the API that calls SetFocus on your behalf

There was a lot of trial and error and I still had to perform quite a bit of native API wrapping. Originally, I was hoping to be able to have SFML create a child window automatically for me by giving it a parent window handle. Maybe I'm the only dope who wants this use case though.
5
Audio / [SOLVED] Getting the actual volume of a sound/music
« Last post by WilliamKappler on September 17, 2021, 02:04:13 am »
I have a use where I need to know the actual, post-attenuation (for 3D sounds) volume of sounds/music. It seems that, according to the API docs, there is no such function; there are only ways to get the various parameters that determine the attenuated volume. Is there some functionality I am missing to get the actual volume, post attenuation?

For instance, I set the sound volume to 0.5, but it's attenuated to half of that based on distance, I would want to know it is now 0.25.

The way the sound is attenuated is documented and I could reproduce it on my program's end, but it would of course be better if I could just ask SFML. That would cover the possibility of the formula changing in the future.
6
Graphics / Re: Drawing sf::Text results in a crash"writing_system_class" was nullptr
« Last post by theo on September 16, 2021, 01:38:22 pm »
Got it working, though my method is a bit hacky.

  • Downloaded the sources of freetype 2.10.4
  • opened the provided visual studio solution (builds\windows\vc2010 (yes this one works on vs2019 too)
  • built it for the desired configuration
  • now VS builds a dll named freetype.dll. I renamed it to freetyped.dll (debug version). Hovering in windows confirms that it is version 2.10.4.
  • copied it to vcpkg\installed\x64-windows\bin (overwrite existing file)
  • now it works. It seems that 2.10.4 and 2.11.0 are binary compatible.

Stackoverflow says that you have to edit header files. This is not necessary anymore. Just choose dll in the solution properties.

Hopefully they fix that bug soon. I do wonder however how they could miss this with any kind of testing on windows (not an entirely insignificant platform).
7
Graphics / Re: Drawing sf::Text results in a crash"writing_system_class" was nullptr
« Last post by theo on September 16, 2021, 11:07:14 am »
stupid mistake: in vcpkg.json:

"overrides":[{"name":"sfml", "version":"2.10.0"}] -> "overrides":[{"name":"freetype", "version":"2.10.0"}]

But it doesn't make a difference, it still builds freetype 2.11.0
8
Graphics / Re: problem with sf::Text getGlobalBounds() / getLocalBounds()
« Last post by theo on September 16, 2021, 10:44:42 am »
9
Graphics / Re: Drawing sf::Text results in a crash"writing_system_class" was nullptr
« Last post by theo on September 16, 2021, 10:43:15 am »
May I ask how you did this? For me it won't work.
I edited the vcpkg.json in the ports\sfml dir to
(click to show/hide)

I got the value of builtin-baseline by doing
git rev-parse HEAD

This didn't do anything for me: it still grabbed freetype version 2.11.0.

Then I edited vcpkg\versions\baseline.json and changed the baseline of freetype to 2.10.0 and I edited the vcpkg.json of freetype to also take 2.10.0:
"version-semver": "2.10.0",

Now it SAYS that it takes 2.10.0. And vcpkg list says 2.10.0 for freetype. But the dll version is STILL 2.11.0 and drawing an sf::Text STILL crashes in freetype.

Maybe the easier way is to compile sfml with cmake and copy the freetype dll into the vcpkg\bin dir
10
Window / Re: Project with responsive window for different resolutions
« Last post by Daniel on September 15, 2021, 06:12:54 pm »
Thank you for your response! I will try to implement this feature according to that tutorial.
Pages: [1] 2 3 ... 10