Results 1 to 3 of 3

Thread: Rendering jitter

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2010

    Rendering jitter


    I'm new to OpenGL and I'm trying to build a simple rendering engine on Linux(Ubuntu) in C/C++.
    When running however, I experience jittering/flickering. Every half a second the image is not vertically aligned any more. I first thought this is because of the lack of vertical synchronization, so I implemented a simple frame limiter:

    Code :
    	while (!m_doExit) {
    		m_oldTime = m_currTime;
    		// frame limiter
    		m_currTime = getTimeOfDayInMillisecs();
    		while (m_currTime - m_oldTime < 1000/DEFAULT_MAX_FPS) {
    			usleep((m_currTime - m_oldTime)*1000/DEFAULT_MAX_FPS);
    			m_currTime = getTimeOfDayInMillisecs();

    Where DEFAULT_MAX_FPS is set to 60 per default. With this code I get like 61 to 62 fps.
    However it seems that OpenGL doesn't like the sleeping in the code, when I'm removing the frame limiter everything works fine (though I get senselessly 1200 FPS).
    Is there any better method in reducing cpu load without getting the jitter effect?
    I'm not a big fan of the 'sleeping' method either, as the system can't catch mouse/keyboard events in that time anyway...

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jun 2009

    Re: Rendering jitter

    You need to enable vertical synchronization (vsync). You can do this using glXSwapIntervalSGI - just beware that this is a GLX extension that you must query with glXGetProcAddress.
    [The Open Toolkit library: C# OpenGL 4.4, OpenGL ES 3.1, OpenAL 1.1 for Mono/.Net]

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2010

    Re: Rendering jitter

    Thank you very much Stephen!

    I'll try this in a second.
    Will my previous frame limiter implementation be worthless? In other words will OpenGL block in its functions or will 'just' the display be updated 60 times per seconds?

    EDIT: I managed to get vertical synchronization working by looking at this tutorial:

    Though I'd recommend checking for swapInterval validity before calling on systems which do not support this extension.

Similar Threads

  1. Replies: 5
    Last Post: 05-25-2018, 06:55 PM
  2. Convert Java SW rendering to OpenGL HW rendering?
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-12-2004, 10:24 AM
  3. Replies: 5
    Last Post: 06-17-2004, 11:51 AM
  4. using basic opengl rendering results for software rendering
    By divide in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 01-04-2004, 06:23 AM
  5. Faster 'jitter'?
    By Thaellin in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 01-11-2001, 06:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean