How to enable VSync synchronization in processing 2.x?

南楼画角 提交于 2019-12-04 16:57:23

Turns out, frameRate() in PJOGL actually runs setSwapInterval() though with some strange logic regarding the value set (github). A workaround for this is:

void setup()
{
    setup(500, 500, P2D);
    frameRate(-1);                                      // set unlimited frame rate
    ((PJOGL)PGraphicsOpenGL.pgl).gl.setSwapInterval(1); // enable waiting for vsync
                                                        // before swapping back/front buffers
}

EDIT:

For Processing 3, I use the following:

import java.awt.*;
import javax.media.opengl.glu.GLU;

void setup()
{
    frameRate(-1);
    beginPGL();
    GLU.getCurrentGL().getGL2().setSwapInterval(1);
    endPGL();
}

EDIT 2:

For Processing 3.2, the following seems to work:

void setup()
{
  fullScreen(P3D);
  frameRate(1000);
  PJOGL pgl = (PJOGL)beginPGL();
  pgl.gl.setSwapInterval(1);
  endPGL();
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!