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

Recent Posts

Pages: [1] 2 3 ... 10
1
General discussions / Re: window resize mouse position wrong
« Last post by eXpl0it3r on October 08, 2024, 01:27:47 pm »
Can you provide a simple example of what you expect should happen and what actually happens?

Plus the complete code that you're using.
From the posted code, I'm not sure what is actually being used now.
2
General discussions / Re: window resize mouse position wrong
« Last post by BitMaNip on October 08, 2024, 12:58:35 pm »
I tried the code as suggested and it still gives wrong values.

I have tried with and without using a view.

Can anyone suggest what I might be doing wrong or what to do that is right?
3
General / Re: SFML with GCC on MacOS
« Last post by eXpl0it3r on October 06, 2024, 10:07:45 pm »
GCC on macOS is causing issues with SFML, see https://github.com/SFML/SFML/issues/2790
We've added a failure, so people aren't trying and reporting the same issues over and over again.
If you have the patience, you can disable the check and see if you can find a workaround.

Is there a way to reinstall SFML with brew in a "GCC-14.2" or "Clang19" version?
Nope, you'll like need to rebuild SFML.

echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc
You can also shorten the first part to the following, which will be more compatible over time:
Code: [Select]
"$(brew --prefix llvm)/bin"
I had problems with FreeType which would not be recognized, even when installed via "brew install freetype". I had to link against the provided freetype file that comes with the SFML Source Code in the folder "extlibs". Also, despite find_package(...) being able to find SFML, the SFML Include Files were not available, thus i had to include them manually via "include_directories(...) in CMakeLists.txt.
As a non-macOS user, I'm also a bit unsure what's the correct way. I guess if you must, you could also specify the library directory to search for, instead of hardcoding the path.

After that, the program finally compiled. I can now use C++ Modules with SFML 3 RC on my MacOS System.
🥳
4
General discussions / Re: window resize mouse position wrong
« Last post by eXpl0it3r on October 06, 2024, 09:59:12 pm »
mapPixelToCoords has a second parameter, where you can pass in the view, see: https://www.sfml-dev.org/documentation/2.6.1/classsf_1_1RenderTarget.php#a2d3e9d7c4a1f5ea7e52b06f53e3011f9

Since you change the view and don't necessarily have it applied at the time you're requesting the mouse location, you'll get the wrong location reported.
5
General / Re: Build fails; 'undefined reference to..'
« Last post by konijn on October 06, 2024, 04:17:29 pm »
Example:
Code: [Select]
g++ main.o -o main -ilib/sfml/include -Llib/sfml/lib -lsfml-graphics -lsfml-window -lsfml-system

First time compiling C++ here, this helped. Just noting that it is
Code: [Select]
-Ilib not
Code: [Select]
-ilib
6
General discussions / window resize mouse position wrong
« Last post by BitMaNip on October 06, 2024, 03:56:39 pm »
Hi all

and thank you for any help in advance.

I create my window and view as follows:
window(sf::VideoMode(l_videoMode.x, l_videoMode.y), l_windowName, sf::Style::Close | sf::Style::Resize)

m_View.setSize(sf::Vector2f(window.getSize().x, window.getSize().y));
m_View.setCenter(window.getSize().x/2, window.getSize().y/2);

 

In the Update method of my window class I get the mouse position as follows:

m_winMousePos = sf::Mouse::getPosition(window);

//I have also tried the following
/*
//sf::Vector2i pixelPos = sf::Mouse::getPosition(window);
//sf::Vector2f worldPos = window.mapPixelToCoords(pixelPos);
/*

//The window resize event as sfml website
if (event.type == sf::Event::Resized)
{
        sf::FloatRect visibleArea(0, 0, event.size.width, event.size.height);
        window.setView(sf::View(visibleArea));
}

//My draw code:
void Window::Draw(const sf::Drawable& l_drawable)
{
        window.setView(m_View);

        window.draw(l_drawable);
}

When I maximise the window, the mouse coords are not correct and I cannot get what I am doing wrong.

Any pointers [no pun intended] would be a great help!

7
General / SFML with GCC on MacOS
« Last post by Grundkurs on October 06, 2024, 11:57:18 am »
I installed SFML on MacOS with
brew install sfml

a sample project compiles just fine with the default c++ compiler on MacOS which is Clang16 on my machine.
CMake's "find_package" works flawlessly and finds SFML. Great!
However, Clang 16 seems to not support C++20-Modules, so I installed Clang19 and GCC-14.2 via homebrew, which both do support Modules:
brew install llvm
brew install gcc

When i setup the Toolchain in Clion with these compilers i can run a hello-world example printing to std::cout without problems. However, the moment i include the SFML Libraries both Compilers give me a plethora of weird error messages.

I did the same thing with GCC-14.2 on Windows with the difference, that here i compiled SFML with that same GCC-14.2 Compiler and i can run the project using SFML and Modules on Windows.

So i assume that the installed version of SFML, that i got with brew, is not compatible with GCC-14.2  or Clang 19.
How would i proceed from here?
Is there a way to reinstall SFML with brew in a "GCC-14.2" or "Clang19" version? Or do i need to compile the SFML Source Code with one of these compilers and replace the files brew installed with the new files?
I cannot find anywhere information how to make brew installed libraries to work with other compilers. Maybe someone can give me a push in the right direction, thanks!

EDIT: I got it to compile after some detours.
1. I uninstalled the SFML version i got via brew with
brew uninstall sfml
2. I installed the newest llvm version (llvm 19) with brew:
brew install llvm
3. I added it to the path, so i could use the new compiler via the terminal

echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc

4. next i got the newest SFML version, compiling it with the new clang19 compiler and enabling shared libs and finally installed it:
git clone https://github.com/SFML/SFML.git
cd SFML
mkdir build && cd build
cmake .. -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DBUILD_SHARED_LIBS=ON
make
sudo make install
An interesting note: I was not allowed to compile it with GCC. CMake outright refused it with a message stating that SFML is only allowed to be compiled with clang on MacOS" or someting like that. Thats why i used Clang and not GCC for compiling SFML on MacOS.
All relevant SFML libraries were now being saved to /usr/local/lib
5. The CMakeLists.txt File looks like this:
cmake_minimum_required(VERSION 3.28)
project(myProject LANGUAGES CXX)

find_package(SFML COMPONENTS System Graphics)

set(SOURCES main.cpp)
include_directories(/Users/UserName/Documents/Programming/SFML/include)
add_executable(myProject ${SOURCES})
target_sources(myProject
        PUBLIC
        FILE_SET CXX_MODULES FILES
        Window.cppm
        Game.cppm
)
target_compile_features(myProject PRIVATE cxx_std_23)
target_link_libraries(myProject /Users/UserName/Documents/Programming/SFML/extlibs/libs-macos/Frameworks/freetype.framework/Versions/A/freetype SFML::System SFML::Graphics)
I had problems with FreeType which would not be recognized, even when installed via "brew install freetype". I had to link against the provided freetype file that comes with the SFML Source Code in the folder "extlibs". Also, despite find_package(...) being able to find SFML, the SFML Include Files were not available, thus i had to include them manually via "include_directories(...) in CMakeLists.txt. After that, the program finally compiled. I can now use C++ Modules with SFML 3 RC on my MacOS System.
8
Quote
Are you running wayland?
What's your window manager?

Gnome 46.5 on Wayland (Fedora 40 Workstation)
9
The download page states:

Quote
Unless you are using a newer version of Visual Studio, the compiler versions have to match 100%!
Here are links to the specific MinGW compiler versions used to build the provided packages:
WinLibs MSVCRT 13.1.0 (32-bit), WinLibs MSVCRT 13.1.0 (64-bit)

I use VS code and compiler:
C:\Windows\System32>g++ --version
g++ (Rev3, Built by MSYS2 project) 13.2.0

the downloaded SFML is:
 SFML 2.6.0 and GCC 13.1.0 MinGW (SEH) - 64-bit
Your compiler version 13.2.0 doesn't match exactly the compiler used to build the package (13.1.0). ;)

Download the compiler linked or rebuild SFML with your compiler.

Or the most recommended way is to get the SFML CMake template and for VS Code it's also recommended to install the CMake extension, which then build SFML and your application at the same time and you don't have to do any magic commands.
10
SFML just tells the X11 to change the resolution. Not sure what happens exactly on your system then. Maybe the window manager decides to pick a size that doesn't include your taskbar or similar.

Are you running wayland?
What's your window manager?
Pages: [1] 2 3 ... 10
anything