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.


Messages - JinLisek

Pages: [1]
1
Window / Re: "Empty" Window is slow
« on: September 06, 2018, 10:18:06 am »
Oh, that makes sense. Thank you. :)

2
Window / Re: "Empty" Window is slow
« on: September 04, 2018, 08:08:59 am »
Try calling window.setFramerateLimit(60) or window.setVerticalSyncEnabled(true).

But not both!!

I tried both of suggested improvements (separately) and both of them work - now when I move the window it no longer lags.

So... Why is that on one PC it's needed to work properly and on another PC it's not needed? Is it because of drivers (I think I've messed up updating drivers on the first one). Or something else?

Shouldn't the user (instead of developer) choose whether to use frame limiting and/or vertical sync?

It's also a good idea to create and process the window's events from the main thread.
(think how bored your main thread must be!)

I tried moving window to main thread, but it didn't change anything (no improvement whatsoever). :(

3
Window / Re: "Empty" Window is slow
« on: August 30, 2018, 07:04:30 am »
But on another device (which is probably less powerful) the programs runs without problems. How do I render slower? Do I limit frame rates or yield thread and wait for X (what is X then?)? Also, note that I create a window in a new thread, not main.

The code is also shown in tutorials, so I really don't think it's fault of wrong code. Probably environmental issues, but I'd like to know how to possibly fix them.

4
General / Re: Deprecated auto_ptr in AudioDevice and CMake configuration
« on: August 29, 2018, 07:17:52 pm »
Refresh, since nobody answered and the question asked by Elias Daler above is quite interesting, at least for me.

Now, that you mention it, I guess I'll try compiling my project with C++17.

5
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?

6
General / Re: Deprecated auto_ptr in AudioDevice and CMake configuration
« on: August 02, 2018, 04:21:01 pm »
Thank you! That worked for me. :)

I didn't know that SFML uses C++ 98, but my pull request was canceled, so now I know. ;D

I'll just put set_target_properties for sfml-audio, because other modules compile just fine in C++ 11. :)

7
General / Re: Deprecated auto_ptr in AudioDevice and CMake configuration
« on: August 01, 2018, 08:01:46 pm »
You're right about it compiling. However, as I always try to do something better, if it's possible, I'd like to keep the project clean of warnings.

I'm not sure how CMake configures SFML. I've added -Werror to my main target, SnakeWithATwist, like this:
target_compile_options(SnakeWithATwist PRIVATE -Wall -Wextra -Werror)
 

But target SnakeWithATwist depends on SFML:
target_link_libraries(SnakeWithATwist PRIVATE sfml-window)
 

Shouldn't CMake also apply -Werror to sfml-window then?

And is it possible to somehow get rid of the warning? Well, I could locally just change auto_ptr to unique_ptr, if it doesn't take too much effort. Or is there some other way?

EDIT: After all, it was trivial to change auto_ptr to unique_ptr. Is it possible to apply the change to SFML repo? I know it's called pull request, but I don't know how to do that and if it's possible with SFML.

EDIT 2: I've created a pull request here: https://github.com/SFML/SFML/pull/1463
I think the topic can be closed. :)

8
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]