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.


Topics - JinLisek

Pages: [1]
1
Window / "Empty" Window is slow
« on: August 29, 2018, 07:09:25 pm »
Hello,

I created a new Window, with nothing drawn on it. The problem is that, when I move the window it moves sluggishly.
Problem occurs on Linux (Archlinux/Manjaro), my device has 2 graphics cards: integrated (intel hd 4000) and dedicated (NVidia GT650m).

I tested the same code on another device, also Linux Manjaro. I think that device has only 1 integrated card though. My program worked there and when I moved the window it was snappy and responsive.

EDIT: Also, note that other windows (for example Firefox) on my system work just fine. But when I run my program, moving them is slow too.

Code below, don't mind class name - it was only a test.

main.cpp:
int main()
{
    KeyboardInput keyInput {};
    keyInput.beginWaitingOnInput();

    return 0;
}
 

KeyboardInput.cpp:
#include "SFML/Window/Keyboard.hpp"
#include "SFML/Window.hpp"

void getUserInput()
{
    sf::Window window(sf::VideoMode(800, 600), "Window Title");

    while(window.isOpen()) //to be moved elsewhere
    {
        sf::Event event;

        while(window.pollEvent(event))
        {
            if(event.type == sf::Event::Closed)
                window.close();
        }

        window.display();
    }

    while(true) //to be used later
    {
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
        {
            Game::gameState = GameState::Quit;
            break;
        }
    }
}

KeyboardInput::~KeyboardInput()
{
    if(inputThread.joinable())
        inputThread.join();
}

void KeyboardInput::beginWaitingOnInput()
{
    inputThread = std::thread{getUserInput};
}
 


What could be a problem here?

2
General / Deprecated auto_ptr in AudioDevice and CMake configuration
« on: August 01, 2018, 09:05:25 am »
Hello,

I'm new to the forum (and using forums in general), so be gentle, please. ;) And nice to meet you!

I've just started using SFML today. What I want to do is to compile SFML, along my game, within CMake project.

I think, I've correctly compiled and linked SFML, because below code works as expected:
sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)

Before I begin to describe the issue, I'll just say that I've tried to search for an answer, but to no avail. I've found this https://en.sfml-dev.org/forums/index.php?topic=21110.0, but I haven't found my answer there. I've also read CMake Tutorial for compiling SFML, but it doesn't work for me, as I don't want to compile just SFML, but whole project (and SFML is a part of it). SFML I use is taken directly from github (at tag 2.5.0) and added to my project as git submodule.

My problem is that I get a warning while compiling AudioDevice.cpp:
../deps/sfml/src/SFML/Audio/AudioDevice.cpp:110:10: warning: &#8216;template<class> class std::auto_ptr&#8217; is deprecated [-Wdeprecated-declarations]
     std::auto_ptr<AudioDevice> device;
 

From the knowledge I've gathered so far, it seems the issue is with my project using different compiler than compiler used to compile SFML. However, I don't think that's possible, as my project compiles SFML (so the compiler should be the same).

Below are my CMake files, but only those that I think matter. I also removed lines which include different libraries etc.

My sfml.cmake:
set(SFML_DIR "deps/sfml/"
    CACHE PATH "The path to the SFML framework.")

add_subdirectory(${SFML_DIR} ${CMAKE_BINARY_DIR}/sfml)
include_directories(SYSTEM ${SFML_DIR}/sfml/include
                           ${SFML_DIR}/sfml/include)
 

My main CMakeLists.txt:
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)

project("Snake With A Twist")

list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)

include(sfml)

add_subdirectory(app)
 

My app CMakeLists.txt:
add_executable(SnakeWithATwist main.cpp)

target_link_libraries(SnakeWithATwist
    PRIVATE sfml-window
)

target_compile_options(SnakeWithATwist PRIVATE -Wall -Wextra -Werror)

target_compile_features(SnakeWithATwist PRIVATE cxx_std_14)
 

If you want a deeper look, here is my project: https://github.com/JinLisek/SimpleSnakeGame

The correction is probably easy, but since my CMake experience is not that big, I just can't wrap my head around it. Any help is welcome and I'll be very grateful for all answers!

Pages: [1]
anything