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

Pages: [1] 2 3 ... 653
Audio / Re: No sound is played but in debug mode is played
« on: April 22, 2021, 03:31:06 pm »
One thing with using std::vector is that any push_back can cause a reallocation of all elements and change in memory address, which for sf::SoundBuffers will break the connection to the sf::Sound and for sf::Sound the playback will be stopped.

My personally recommendation is to use a std::map or std::unordered_map for the sound buffers (see also the resource holder implementation) and then use a std::deque for the sf::Sound. That way you can push_back new sounds to play and pop_front sounds that finished playing (assuming they're all of about the same short play time).

General / Re: makefile error?
« on: April 21, 2021, 06:49:11 pm »
You use -I instead of -l (lower-case L)

Graphics / Re: Using SFML should I care about texture binds?
« on: April 21, 2021, 05:52:27 pm »
If you use pure-SFML you don't really have to think about binds in that way, as SFML will handle it transparently.

When drawing a VertexArray you need to pass the wanted texture as RenderState to the draw function.
I can't really tell you how the number of textures or size of textures affect your application, best to create custom fitted benchmarks for the use case you intend and check whether it fits your perfromance goal.

Texture atlases are always recommended, because you can then batch more in one vertex array draw call and texture switches aren't necessarily free. Of course with 30GB of texture data, you can't fit that in one texture...

Your GPU won't allow you to have a 20000x20000 texture.
SFML won't display things that are outside the view, but they are still sent to the GPU, which then determines what is and isn't shown. So you do have to take care of what data is sent to the GPU to stay within the availalbe bandwidth.

General / Re: Weirdly slow event loop
« on: April 21, 2021, 05:38:47 pm »
Sounds much more like a coding issue then.

I suggest to create a minimal example or use like SFML's pong example and see if you can reproduce it with that.
If not, then it's more likely an issue in your own code.

General / Re: Weirdly slow event loop
« on: April 21, 2021, 01:58:13 pm »
How do you determine "slowness"?

General / Re: Weirdly slow event loop
« on: April 21, 2021, 08:34:11 am »
What GPU driver are you using?
Do you have the proper driver for your mouse installed?
Do you have any weird joystick/gamepad like controllers plugged in that have a broken driver?

Audio / Re: No sound is played but in debug mode is played
« on: April 21, 2021, 08:32:30 am »
Either your posted code doesn't match what you've implemented or this line shouldn't compile.


getSoundBuffers() returns a vector, so you can't be accessing a property called soundBuffers.

Hard to say now, what your actual code is, but if getSoundBuffers really does return a std::vector<sf::SoundBuffer>, you're always return a copy of the the whole vector, which then only exists temporarily and will be deleted after the call to play() is finished.
So the temporary sound buffer copy gets destroyed, before it's actually played.

To fix this, you'd need to return a reference to the sound buffer.

Additionally, I highly recommend to not misuse the singleton pattern for glorified globals. Instead use dependency injection, meaning to pass the resource manager and sound play via constructor to as few classes as possible.

General / Re: makefile error?
« on: April 21, 2021, 08:18:36 am »
On the make file line with LIBS= you need to list the SFML libraries to be linked

General / Re: How to make a game loop and draw the fps on the screen?
« on: April 19, 2021, 09:25:32 pm »
With the current setup, you need to get the value from clock.restart() and divide it by 1.f / deltaTime.
Then you can use std::to_string(fps) to convert it to a string, which you can then draw with a sf::Text object after loading an sf::Font object.

If this is all a bit much, then I recommend to keep reading on, you'll eventually learn most of this in the book.

Btw. I believe the processEvents should only exist once in your code.

General / Re: makefile error?
« on: April 19, 2021, 05:20:59 pm »
Looks like you're not linking SFML.
How does the complete line with LIBS = ... look like?

General / Re: ld.exe cannot find -lsfml-graphics-d
« on: April 16, 2021, 10:45:34 pm »
Same question applies, did you actually add the library path?

Graphics / Re: Overlaying two textures
« on: April 16, 2021, 10:07:02 pm »
What do you mean "save transparency"?

The situation is that your "transparent" color that you use to clean the window, isn't just transparent, but it's actually black with an alpha set to 0.
So when you alpha blend your textures, it will blend with the black color, thus you get the black strokes.

If you render it with blend none, then it's applied 1:1. This of course doesn't necessarily work for overlaying multiple textures, as you do want to alpha blend then.

Graphics / Re: Overlaying two textures
« on: April 16, 2021, 02:38:05 pm »
I think if you render the first texture with BlendMode::None it shouldn't mix with the black but transparent background.

I am however unsure what you need to pick for the second texture.

Feature requests / Re: (CMake) Make BUILD_SHARED_LIBS=OFF by default
« on: April 16, 2021, 12:45:50 am »
When you say, SFML's CMake sets it to ON, do you mean implicitly by using the SHARED keyword? Because there's no explicit setting of the mentioned variable.

Feature requests / Re: (CMake) Make BUILD_SHARED_LIBS=OFF by default
« on: April 14, 2021, 12:56:50 pm »
Aha, I guess I was confused by the formulation of the initial question ;D

So you'd essentially want to add something along the lines of: set(BUILD_SHARED_LIBS ON CACHE BOOL)

Is that correct?

Pages: [1] 2 3 ... 653