-1

vsync is switched on and off with glfwSwapInterval(1) or glfwSwapInterval(0)

single viewport is glClear --> glViewport(0, 0, win_w,win_h) --> drawscene() --> glfwSwapBuffers in the rendering loop

double viewport is glClear --> glViewport(0, 0, win_w/2,win_h) --> drawscene() --> glViewport(win_w/2, 0, win_w/2,win_h) --> drawscene() -->glfwSwapBuffers in the rendering loop

My scene single viewport with no vsync --> 140 fps

My scene double viewport with no vsync --> 70 fps (as expected since it is drawing the same scene twice)

My scene single viewport with vsync --> 60 fps (as expected because my monitor refresh rate is 60Hz)

My scene double viewport with vsync --> 30 fps (??? I am expecting 60 fps here because it is achieving 70 > 60 fps without vsync, is there any extra GLFW function that I have to call?)

user3667089
  • 2,996
  • 5
  • 30
  • 56
  • Please let me know why I am getting the down vote on this question, so I will be able to fix it to meet your standards, thanks. – user3667089 Apr 21 '15 at 16:28

1 Answers1

1

Maybe the problem is that you put glFinish or the swap buffer command at the end of each rendering call. This imply that the rendering engine will stop until all drawing commands are performed. It may explain way you're going so slow.

I think you must put only one at the end of the two rendering call.

Mouze
  • 706
  • 5
  • 10
  • Yes I only put one. If I do glClear --> glViewport(0, 0, win_w/2,win_h) --> drawscene() -->glfwSwapBuffers--> glViewport(win_w/2, 0, win_w/2,win_h) --> drawscene() -->glfwSwapBuffers for the double viewport case, I still get only 30 fps with massive flickering – user3667089 Apr 21 '15 at 08:31
  • 1
    Have you checked the glFinish call is only one per frame? For the flickering, are you using glScissor()? – Mouze Apr 21 '15 at 08:35
  • 1
    Look at here: http://gamedev.stackexchange.com/questions/40704/what-is-the-purpose-of-glscissor – Mouze Apr 21 '15 at 08:38
  • I am not using glScissor(). I am not calling glFinish either as I assume it is embedded in glfwSwapBuffers somehow. I tried glClear --> glViewport(0, 0, win_w/2,win_h) --> drawscene() -->glFinish--> glViewport(win_w/2, 0, win_w/2,win_h) --> drawscene() -->glfwSwapBuffers for the double viewport case, no flickering but still 30 fps – user3667089 Apr 21 '15 at 08:43
  • 1
    Try to execute 3 renderings, with 3 viewports, and see if the speed decreases further. If so, there is something that vsynched in the drawscene code () – Mouze Apr 21 '15 at 09:00
  • For 3 viewports, without vsync --> 45 fps, with vsync --> 30fps, in the drawscene code it's just a few glDrawElements call. How would vsync affect it? – user3667089 Apr 21 '15 at 16:25