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 - miotatsu

Pages: [1]
1
Window / Re: vsync always on?
« on: October 22, 2014, 12:56:33 am »
Alright, thanks for the help :P

2
Window / Re: vsync always on?
« on: October 22, 2014, 12:17:23 am »
As in this?
////////////////////////////////////////////////////////////
void GlxContext::setVerticalSyncEnabled(bool enabled)
{
    const GLubyte* name = reinterpret_cast<const GLubyte*>("glXSwapIntervalSGI");
    PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = reinterpret_cast<PFNGLXSWAPINTERVALSGIPROC>(glXGetProcAddress(name));
    assert(glXSwapIntervalSGI);
    if (glXSwapIntervalSGI)
        glXSwapIntervalSGI(enabled ? 1 : 0);
}

The assertion did not trip with my test program.

Just to be extra sure, I added some std::cout's to both code paths.
[mio@c7 sandbox]$ clang++ -std=c++14 -g test.cpp -lsfml-graphics -lsfml-window -lsfml-system
[mio@c7 sandbox]$ ./a.out
glXSwapIntervalSGI valid
glXSwapIntervalSGI valid

3
Window / Re: vsync always on?
« on: October 21, 2014, 11:02:08 pm »
Sorry for the late response, but changing "glXSwapIntervalSGI" to "glXSwapIntervalMESA" does indeed "fix" the problem.

4
Window / Re: vsync always on?
« on: October 21, 2014, 01:10:24 am »
Try changing "glXSwapIntervalSGI" in this line to "glXSwapIntervalMESA" or "glXSwapIntervalEXT" and build SFML and see if it works. Make sure to get rid of all traces of SFML that are currently on your system before doing this. If this "fix" works, it smells like another case of a broken driver.

Will try this later tonight :)

So, as he is on Intel graphics, he needs to edit /etc/X11/xorg.conf.
Find the Driver "intel" line, and in that section, add
Option "SwapbuffersWait" "false".

With this, the problem is reversed. vsync is off, but SFML is unable to turn it on.
Edit: Not exactly reversed, as the SDL example was unable to turn it on too.

5
Window / Re: vsync always on?
« on: October 20, 2014, 11:14:44 pm »
Try running vblank_mode=0 before calling your executable. So:
vblank_mode=0 ./myexecutable

This worked. If nothing else, that trick would be sufficient to test my applications without vsync, but I'm still left wondering why turning off vsync does not work for me from SFML itself.

6
Window / Re: vsync always on?
« on: October 20, 2014, 01:22:03 pm »
Well this is embarassing  ;D
Turns out setVerticalSyncEnabled(false) does the trick.
I had been simply commenting out setVerticalSyncEnabled(true), as I expected it to default off.
I'm surprised I didn't try that, thank you for the help. >.<;


edit: nevermind, I had the display call commented out. setVerticalSyncEnabled(false) does not turn off vsync for me!

7
Window / Re: vsync always on?
« on: October 20, 2014, 12:33:00 pm »
Can you paste the full output of the glxinfo command here for us please?
(click to show/hide)

8
Window / vsync always on?
« on: October 20, 2014, 10:01:09 am »
I have been playing around with game loops and physics. The other day, I added some debug statements to see how much time each frame of my game loop was taking. As expected, the results were in the 16ms range. However, I tried disabling vsync, and these results did not change. Clearly vsync was still occuring.

My system is as follows:

    $ inxi -SMG
    System: Host: c7 Kernel: 3.16.4-1-ARCH x86_64 (64 bit) Desktop: i3 4.8 Distro: Arch Linux
    Machine: System: Google product: Parrot v: 1.0
    Mobo: N/A model: N/A Bios: coreboot v: 4.0-4744-gac16405-dirty date: 10/23/2013
    Graphics: Card: Intel 2nd Generation Core Processor Family Integrated Graphics Controller
    Display Server: X.Org 1.16.1 driver: intel Resolution: 1366x768@60.02hz
    GLX Renderer: Mesa DRI Intel Sandybridge Mobile GLX Version: 3.0 Mesa 10.3.1

The SFML vsync test case is given below:
#include <chrono>
#include <iostream>
#include "SFML/Graphics.hpp"

int main()
{
    auto* window = new sf::RenderWindow(sf::VideoMode(640, 480), "test",
        sf::Style::Titlebar | sf::Style::Close);
    window->setVerticalSyncEnabled(true);
    auto firstTime = std::chrono::high_resolution_clock::now();
    while(window->isOpen())
    {
        //print frame timing
        {
            auto secondTime = std::chrono::high_resolution_clock::now();
            using dMsecs = std::chrono::duration<double, std::chrono::milliseconds::period>;
            auto elapsed = dMsecs(secondTime - firstTime);
            firstTime = secondTime;
            std::cout << elapsed.count() << '\n';
        }
        //event handler
        {
            sf::Event e;
            while(window->pollEvent(e))
            {
                if(e.type == sf::Event::EventType::Closed)
                    window->close();
            }
        }
        //render
        {
            window->clear();
            window->display();
        }
    }
}

I have another test case written with SDL2 for comparison:
#include <chrono>
#include <iostream>
#include "SDL2/SDL.h"

int main()
{
    SDL_Init(SDL_INIT_VIDEO);
    SDL_Window* window = SDL_CreateWindow("test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN);
    SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC );
    auto firstTime = std::chrono::high_resolution_clock::now();
    auto quit = false;
    while(!quit)
    {
        //print frame timing
        {
            auto secondTime = std::chrono::high_resolution_clock::now();
            using dMsecs = std::chrono::duration<double, std::chrono::milliseconds::period>;
            auto elapsed = dMsecs(secondTime - firstTime);
            firstTime = secondTime;
            std::cout << elapsed.count() << '\n';
        }
        //event handler
        {
            SDL_Event e;
            while(SDL_PollEvent(&e))
            {
                if(e.type == SDL_QUIT) quit = true;
            }
        }
        //render
        {
            SDL_RenderClear(renderer);
            SDL_RenderPresent(renderer);
        }
    }
}

SFML sample output, vsync on:
(click to show/hide)

SFML sample output, vsync off:
(click to show/hide)

SFML, window->display() commented out:
(click to show/hide)

SDL2, vsync on:
(click to show/hide)

SDL2, vsync off:
(click to show/hide)

If this is a driver issue, I don't understand why other libraries have vsync implementations that behave correctly on my system?
What is the difference in implementation between the two libraries causing this differing behaviour, and can it be resolved? How would I go about getting the correct behaviour with SFML?

Pages: [1]