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

Recent Posts

Pages: [1] 2 3 ... 10
1
After a bit of experimenting, that solution partially worked. I figured it out so I'm going to mark the thread as solved, but for anyone who runs into this issue:

Resetting the window view is NOT enough to solve this on its own. The flow of code should be something like this:
if (event.type == sf::Event::Resized) {
        window.setView(sf::View(sf::Vector2f(window.getSize().x/2.f,window.getSize().y/2.f), sf::Vector2f(window.getSize().x, window.getSize().y)));
        for (auto& i : sprites) {
            i.setPosition(/*new position */);
        }
       
    }
You must adjust every drawn object/sprite's position after you change the sf::View, otherwise each drawn object is stuck with an arbitrary sf::View based on the time it was drawn before/after the resizing of the window.
2
General discussions / Re: Scroll Wheel
« Last post by eXpl0it3r on May 22, 2024, 10:38:53 pm »
Have you tried the sf::Event::MouseWheelScrolled event? See the tutorial.

Or are you saying that your mouse has more than one scroll wheel?

As for buttons, SFML also supports two extra mouse buttons.
3
General / Re: Can you integrate allegro into an sfml window?
« Last post by Me-Myself-And-I on May 22, 2024, 09:23:06 pm »
I don't think that's the problem.
The header files are not listed in the cmake file.
# Project: Project1
# Makefile created by Dev-C++ 5.11

CPP      = g++.exe
CC       = gcc.exe
WINDRES  = windres.exe
OBJ      = main.o VideoTexture.o
LINKOBJ  = main.o VideoTexture.o
LIBS     = -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib32" -L"C:/SFML-2.4.0/lib" -static-libgcc -lsfml-graphics -lsfml-network -lsfml-audio  -lsfml-system -lsfml-window -m32
INCS     = -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include"
CXXINCS  = -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++" -I"C:/SFML-2.4.0/include"
BIN      = Project1.exe
CXXFLAGS = $(CXXINCS) -m32 -std=c++11
CFLAGS   = $(INCS) -m32 -std=c++11
RM       = rm.exe -f

.PHONY: all all-before all-after clean clean-custom

all: all-before $(BIN) all-after

clean: clean-custom
        ${RM} $(OBJ) $(BIN)

$(BIN): $(OBJ)
        $(CPP) $(LINKOBJ) -o $(BIN) $(LIBS)

main.o: main.cpp
        $(CPP) -c main.cpp -o main.o $(CXXFLAGS)

VideoTexture.o: VideoTexture.cpp
        $(CPP) -c VideoTexture.cpp -o VideoTexture.o $(CXXFLAGS)
4
General / I need help with this
« Last post by Yosef on May 22, 2024, 08:03:37 pm »
I'm developing a pool game using SFML and Box2D, and I'm currently facing an issue with creating the cue ball outline when the player aims. I have three rays that are cast: two black ones and one white one. How can I determine the position of the outline of the cue ball using the shortest of these rays as the player aims. I am using the ray cast function of box2d.

I have attached picture of the outline for further reference

5
General discussions / Scroll Wheel
« Last post by clampflower on May 22, 2024, 05:23:19 pm »
Hi All,

Apologies, as I am fairly new to this game.  I have been programming in C++ / SFML for a while now (months) but got stuck on mouse wheels. How do I use SFML to detect which way a vertical mouse wheel has been scrolled? I am using a Logitech mouse that has a pile of buttons and wheels but the main vertical wheel is the one that I want to detect.

I have been playing Forge of Empires and this scroll wheel controls the zoom function of the map, which is great and so I know this is doable. Would very much appreciate any help.

Many thanks

Moon.
6
General / Re: Can you integrate allegro into an sfml window?
« Last post by fallahn on May 22, 2024, 05:22:14 pm »
It depends on you compiler/toolchain setup.

For example Visual Studio lists 2 folders in its source tree "Header Files" and "Source Files". Only the files which are included in the "Source Files" folder are sent for compilation. It's at this point any header files which are #include 'd in the *.cpp files are pulled in by the compiler for compilation. (Well, kinda, they're put in place by the preprocessor just before compilation).

On the other hand *.hpp files listed in the "Header Files" section are ignored, except for when they're explicitly #include 'd in a *.cpp file. If you try adding an *.hpp file to the "Source Files" folder, Visual Studio will try to compile it directly which may or may not be what you want (probably not in most cases, and definitely not in this specific case).

Other toolchain/compiler setups are similar: you list the source files (*.c and *.cpp) you want to compile, followed by the directories containing the header files. That way the compiler will only pull in any header files for compilation as is needed.

So what I mean is - make sure the *.hpp files are not being added to the list of files to be compiled, either by accidentally adding them to the "Source Files" folder in Vidual Studio, or by any other means with a different compiler.
7
Audio / Re: (SOLVED)Music not playing even though its loaded.
« Last post by Me-Myself-And-I on May 22, 2024, 04:43:29 pm »
Sorry for reopening this topic after I closed it. I just wanted to say, I found the solution and it had nothing to do with the window. I figured out that I had too many soundbuffers ,and sounds  for music to play anything. I guess I hit the limit and caused sf::Music to be silent.
8
General / Re: Can you integrate allegro into an sfml window?
« Last post by Me-Myself-And-I on May 22, 2024, 04:18:20 pm »
This might sound dumb but... how exactly do you do that? :P I don't think I've ever heard of excluding header files from compilation when the cpp file is using them. Neither have I found any documentation on how to do that.
9
The view controls how the scene is mapped onto the window. But when a window resizes, the view isn't modified. So you'll need to generate a new view. For example:
                                if (event.type == sf::Event::Resized)
                                {
                                        sf::Vector2u size = g_window.getSize();
                                        g_window.setView(sf::View(sf::Vector2f(size.x / 2.0f, size.y / 2.0f), sf::Vector2f(size.x, size.y)));
                                }
 
10
SFML development / Re: Font/Text Direction
« Last post by eXpl0it3r on May 22, 2024, 09:52:07 am »
I believe SFML's font would need to adjust a lot more than just providing the horizontal advance when trying to support non-horizontal layouts.

Meaning, I'm not against changing this, just questioning if that's actually helpful.

Also I found this page and the graphics helpful to understand the terminology.



I wonder if that advance is ever used in normal LTR text too or just for column writing systems. FT docs don't say. sf::Text and sf::Font are also a bit iffy for RTL text (technically you can reverse your string before inputting it but that's a bit of a hack to make RTL be just LTR backwards), and has 0 shaping needed for cursive scripts (like HarfBuzz has).
Eventually, we'll be integrating HarfBuzz, but we'd first have to solve the dependency issue.
Pages: [1] 2 3 ... 10
anything