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

Recent Posts

Pages: 1 ... 7 8 [9] 10
81
I have the same problem with 2.6.x:

$ ./cmake.bat

C:\Users\dougy\OneDrive\Attachments\Documents\BJT\src>"C:\Program Files\CMake\bin\cmake.exe" -D CMAKE_BUILD_TYPE=Release -G "MinGW Makefiles" -D CMAKE_MAKE_PROGRAM:PATH="C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/mingw32-make" -D CMAKE_CXX_COMPILER="gcc" -D CMAKE_CXX_FLAGS="-std=gnu++17"
CMake Warning:
  No source or binary directory provided.  Both will be assumed to be the
  same as the current working directory, but note that this warning will
  become a fatal error in future CMake releases.


-- The C compiler identification is GNU 13.1.0
-- The CXX compiler identification is GNU 13.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/mingw32/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/mingw32/bin/gcc.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:6 (find_package):
  Could not find a configuration file for package "SFML" that is compatible
  with requested version "2.6.2".

  The following configuration files were considered but not accepted:

    C:/SFML-2.6.2/lib/cmake/SFML/SFMLConfig.cmake, version: 2.6.2 (64bit)



-- Configuring incomplete, errors occurred!
82
Audio / Re: Wrong openFromFile Mangling
« Last post by fulfowi on March 26, 2025, 12:29:34 am »
Now I get:
$ ./cmake.bat

C:\Users\dougy\OneDrive\Attachments\Documents\BJT\src>"C:\Program Files\CMake\bin\cmake.exe" -D CMAKE_BUILD_TYPE=Release -G "MinGW Makefiles" -D CMAKE_MAKE_PROGRAM:PATH="C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/mingw32-make" -D CMAKE_CXX_COMPILER="gcc" -D CMAKE_CXX_FLAGS="-std=gnu++17"
CMake Warning:
  No source or binary directory provided.  Both will be assumed to be the
  same as the current working directory, but note that this warning will
  become a fatal error in future CMake releases.


-- The C compiler identification is GNU 13.1.0
-- The CXX compiler identification is GNU 13.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/mingw32/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/mingw32/bin/gcc.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:6 (find_package):
  Could not find a configuration file for package "SFML" that is compatible
  with requested version "2.6.2".

  The following configuration files were considered but not accepted:


    C:/SFML-2.6.2/lib/cmake/SFML/SFMLConfig.cmake, version: 2.6.2 (64bit)



-- Configuring incomplete, errors occurred!
83
General / Re: sf::Sprite undefined / no default value
« Last post by eXpl0it3r on March 24, 2025, 04:30:00 pm »
sf::Sprite no longer has a default constructor.

Two migration paths are:
  • Use std::optional<sf::Sprite> if you still need an uninitialized sprite
  • Pass the needed texture to the sprite

For the second option, Ii your class holds a sf::Sprite instance, you'll need to initialize it in the initialization list. I would also then make sure, that you're passing the texture into class as well and to not load the texture in the constructor after the initialization list.

For your code, I'd probably pick the first option.

class Game {
// ...
std::optional<sf::Sprite> m_mushroom;
// ...
};
84
Audio / Re: Wrong openFromFile Mangling
« Last post by eXpl0it3r on March 24, 2025, 01:24:39 pm »
Make sure to download the ones linked on the download page!
85
General / Re: Visual Studio Default Settings being reset
« Last post by eXpl0it3r on March 24, 2025, 10:12:24 am »
The settings are stored in your project file (kind of the whole point of having a project file).

In theory you could just copy that and start renaming things. Which is essentially what a template does, just a bit better supported.

Another alternative is to use CMake, which VS 2022 natively supports, and then you can just copy around the  CMake code or start with the SFML CMake Template.
86
Audio / Re: Wrong openFromFile Mangling
« Last post by fulfowi on March 23, 2025, 11:29:30 pm »
Thanks! I'll DL 13.1.
87
General / sf::Sprite undefined / no default value
« Last post by gwendyn on March 23, 2025, 04:02:49 pm »
Hi,
im pretty new to sfml. i want to get used to classes and i follow the book "LearnByExample". Since its an older book the syntax is flawed.

Trying to follow the examples in the book i want to follow spliting everything into different classes. But how to initiate the sprite? if i anounce sf::sprite sprite in header i get an error for it not having a default value. and if i dont anounce it its not defined for the other functions.

Header:
#pragma once
#include <SFML/Graphics.hpp>
#include "Window.h"

class Game {
public:
        Game();
        ~Game();

        void HandleInput();
        void Update();
        void Render();
        void GetWindow();
       

private:
        sf::Texture m_mushroomTexture;
        //sf::Sprite m_mushroom;
        void MoveMushroom();
        Window m_window;
        sf::Vector2f m_increment;

#include "Game.h"
#include <SFML/Graphics.hpp>

Game::Game() : m_window("Chapter 2", { 800, 600 }) {

   m_mushroomTexture.loadFromFile("resources/smw_mushroom.png");
   sf::Sprite m_mushroom(m_mushroomTexture);
   sf::Vector2u size = m_mushroomTexture.getSize();
   m_mushroom.setOrigin({size.x / 2, size.y / 2});
   m_increment = sf::Vector2f{ 4, 4 };
}

Game::~Game()
{
}

void Game::HandleInput()
{
}

void Game::Update() {
   m_window.Update();
   MoveMushroom();
}

void Game::Render() {
   m_window.BeginDraw();  
   m_window.Draw(m_mushroom);      //undefine
   m_window.EndDraw();      
}

void Game::GetWindow()
{
}

void Game::MoveMushroom() {
   sf::Vector2u l_windSize = m_window.GetWindowSize();
   sf::Vector2u l_textSize = m_mushroomTexture.getSize();

   if ((m_mushroom.getPosition().x > l_windSize.x - l_textSize.x && m_increment.x > 0) ||      //undefined
      (m_mushroom.getPosition().x < 0 && m_increment.x < 0)) {
      m_increment.x = -m_increment.x;
   }
   if (m_mushroom.getPosition().y > l_windSize.y - l_textSize.y && m_increment.y > 0 ||
      m_mushroom.getPosition().y < l_windSize.y && m_increment.y < 0){
      m_increment.y = -m_increment.y;
   }
   m_mushroom.move(m_increment);
}

Can someone help me or lead me to something which explains that? since sfml3 is pretty new i have trouble finding examples to look at.

edit: maybe i can create a vector or an object and just attach the sprite late?
88
Audio / Re: Wrong openFromFile Mangling
« Last post by kojack on March 23, 2025, 07:18:55 am »
Are you using downloaded binaries of SFML?
The downloads are for MinGW 13.1, but your error message says you are using MinGW 11.2. The version numbers must match exactly.

You could either change your compiler to 13.1, or build SFML yourself using 11.2.
89
General / Re: Visual Studio Default Settings being reset
« Last post by kojack on March 23, 2025, 07:11:02 am »
This is normal. Project settings only exist for the project you set them on, any new project will start off from scratch again.

You can make your own Visual Studio project templates, although it's been around 4 years since I've done that so don't remember the details. But when I did, I had a template that set up everything ready for my SFML based game engine.
90
Audio / Wrong openFromFile Mangling
« Last post by fulfowi on March 22, 2025, 11:37:20 pm »
I'm able to link all my SFML audio calls expect for openFromFile.  I get the following error:

C:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/dougy/OneDrive/Attachments/Documents/BJT/src/BlackJackTutorManager.cpp:26: undefined reference to `__imp__ZN2sf5Music12openFromFileERKSs'

The closest match I could find is:
dougy@DougyDrumzLT /cygdrive/c/SFML-2.6.2/lib
$ nm libsfml-audio*.a | grep __imp__ZN2sf5Music12openFromFile
0000000000000000 I __imp__ZN2sf5Music12openFromFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
0000000000000000 I __imp__ZN2sf5Music12openFromFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE

Attached is my CMakeLists.txt.

Please advise.
Pages: 1 ... 7 8 [9] 10
anything