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

Recent Posts

Pages: [1] 2 3 ... 10
1
General / Font Loading.
« Last post by o2ciri on Today at 01:43:25 am »
Hi,

I'm fairly new to SFML, so I might be missing something.
I've gone through a lot of information but nothing has helped.

After I load a font, the program just closes without any message.

I use SFML as a git submodule and build everything with CMake.

CMakeLists.txt:
cmake_minimum_required(VERSION 3.20)

project(Ironforge)

set(CMAKE_CXX_STANDARD 20)

set(BUILD_SHARED_LIBS FALSE)

add_subdirectory(dep/SFML)

add_executable(${PROJECT_NAME}
        src/main.cpp
        src/Application.cpp
        src/State/StateManager.cpp
        src/UI/Button.cpp
        src/UI/MenuTabBar.cpp
        src/WindowManager.cpp
)

target_include_directories(${PROJECT_NAME}
        PUBLIC
        ${CMAKE_CURRENT_SOURCE_DIR}/include
        ${CMAKE_CURRENT_SOURCE_DIR}/dep/SFML/include)

set(DEBUG_LIBS
        sfml-graphics-d)

set(RELEASE_LIBS
        sfml-graphics
)

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
    target_link_libraries(${PROJECT_NAME} PRIVATE ${DEBUG_LIBS})
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
    target_link_libraries(${PROJECT_NAME} PRIVATE ${RELEASE_LIBS})
endif ()
 

After building the project and checking all dependencies and libraries through VS project settings ALL is correct. see screenshots.

I load the font in a class, which is in separate files

.h

#ifndef APPLICATION_H
#define APPLICATION_H

#include "macro.h"
#include "WindowManager.h"

#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/System/String.hpp>
#include <SFML/Window/Event.hpp>
#include <SFML/Window/VideoMode.hpp>

#include "SFML/Graphics/Font.hpp"

class Application
{
public:
    Application() = delete;
    explicit Application(sf::VideoMode videoMode);
    ~Application();

    DISABLE_COPY_ASSIGN(Application);

    void run();

private:
    void handleEvent();
    void update(sf::Time dt);
    void render();

    sf::Font* font;

    sf::RenderWindow window;
};

#endif // APPLICATION_H
 

.cpp relative only
Application::Application(sf::VideoMode videoMode)
    : window(videoMode, APP_TITLE, sf::Style::None, sf::State::Fullscreen)
{
    WindowManager::getInstance().setWindow(&window);
    *font = sf::Font::loadFromFile("resources/fonts/Cthulhumbus.ttf").value();
}
 

The paths to the fonts are also specified correctly, because if you specify incorrectly in the console displays an error about it.

It's also worth pointing out that apart from fonts, everything loads fine, textures, etc.

Hope someone can help ;)
2
Audio / Re: sf::sound causes severe performance lag.
« Last post by Me-Myself-And-I on May 30, 2024, 11:30:26 pm »
That fixed it.Thanks
3
General discussions / Re: Virus alert during download
« Last post by eXpl0it3r on May 30, 2024, 11:05:15 pm »
It's a so called false-positive. Would be great if you could report it as such, hopefully someone at McAfee would then clear it.

If you don't want to disable your AV, you're best served by building SFML from source, e.g. by using the SFML CMake template.
4
General discussions / Virus alert during download
« Last post by dmeyer4@yahoo.com on May 30, 2024, 06:54:36 pm »
My McAfee AV won't let me download the "latest stable release" for 32-bit, says it contains a virus. Any solution for that? Thanks.
5
Audio / Re: sf::sound causes severe performance lag.
« Last post by fallahn on May 30, 2024, 05:11:08 pm »
Make sure you're only loading the buffer from file *once* then keeping it around, and not trying to load it every frame
6
General / Re: Keyboard big issue
« Last post by Rhubarb on May 30, 2024, 03:47:37 pm »
UPDATE:

I fixed the problem by modifying my function:

int isPressed(sf::Event event,sf::Keyboard::Key key){
    if (sf::Keyboard::isKeyPressed(key)&&function_done==0){
        function_done=1;
        return 0;
    };
    if(event.type == (sf::Event::KeyReleased)){
        if (event.key.code == key&&function_done==1){
            function_done=0;
        }else
            if (!(sf::Keyboard::isKeyPressed(key))){
                function_done=0;
            };
    };
    return 1;
};

So it fixed two problems:

now letters works
and now it works instantly because before you needed to input the key at least once before it works because the function was calling the keyrealsed event :)

thanks for the help also :)
7
Audio / sf::sound causes severe performance lag.
« Last post by Me-Myself-And-I on May 30, 2024, 03:46:49 pm »
I'm having trouble getting around this. If I play a simple sound it always makes the program lag. Is there something that i'm doing wrong with sf::Sound?

I have a simple script that happens only once.
                buffer[4].loadFromFile("ASSETS/thunder.wav");
                sound[4].setBuffer(buffer[4]);
                sound[4].play();
 
Its only an array of 10 sounds and an array of 10 buffers. Any clues as to why it causes a lag? More specifically, I notice a definite lag in graphics when this happens.
8
General / Re: Keyboard big issue
« Last post by Rhubarb on May 30, 2024, 08:56:48 am »
I'm using Xlib, x11 to be more precise
9
General / Re: Can't compile when trying to render text
« Last post by Culf on May 30, 2024, 12:47:46 am »
Thank you! I got it working with the MSVCRT-based MinGW version :D
10
SFML projects / Re: Tail Smash! - Arcade driving game
« Last post by eXpl0it3r on May 29, 2024, 11:32:24 pm »
That's a pretty cool write up! I especially liked the diagrams :)
Pages: [1] 2 3 ... 10