I really hope i can get help with this issue. It has plagued me for weeks now and its so fundamental to my program.
I have written a very simple program (below) in an attempt at using the Gaffer on Games timestep functionality to achieve smooth animation.
The problem i keep running into is a terrible stuttering effect, it jumps around all the time and is not smooth. Yet i have had people say everything is just fine on their PC. I have two PCs of similar hardware that this happens on.
I have tried using OpenTK and saw the same issue, SlimDX did not do this. I hoped SFML would be my savior. If i set the exe to disable Desktop Composition, the animation is much more smooth than before.
using System;using SFML;using SFML.Graphics;using SFML.Window;using Tao.OpenGl;namespace sample_opengl
{ static class Program
{ static RenderWindow Window
; static float prevPos
= 0
.0f
; static float nextPos
= 0
.0f
; static float speed
= -5
.0f
; static void Main
() { Window
= new RenderWindow
(new VideoMode
(800,
600),
"SFML.Net OpenGL", Styles
.Close); Window
.UseVerticalSync(true); Window
.Closed += new EventHandler
(OnClosed
); Window
.KeyPressed += new EventHandler
<KeyEventArgs
>(OnKeyPressed
); Gl
.glMatrixMode(Gl
.GL_PROJECTION); Gl
.glLoadIdentity(); Glu
.gluOrtho2D(-400,
400,
-300,
300); Gl
.glMatrixMode(Gl
.GL_MODELVIEW); Gl
.glLoadIdentity(); float frameTime
= 0
.0f
; float dt
= 0
.03f
; float accumulator
= 0
.0f
; float alpha
= 0
.0f
; while (Window
.IsOpened()) { Window
.DispatchEvents(); frameTime
= Window
.GetFrameTime(); if (frameTime
> 0
.25f
) { frameTime
= 0
.25f
; } accumulator
+= frameTime
; while (accumulator
>= dt
) { accumulator
-= dt
; Update
(dt
); } alpha
= accumulator
/ dt
; Render
(alpha
); } } static void Update
(float dt
) { prevPos
= nextPos
; nextPos
+= speed
; if (nextPos
> 300 || nextPos
< -400) { speed
*= -1; } } static void Render
(float alpha
) { Window
.Clear(); Gl
.glPushMatrix(); Gl
.glTranslatef(nextPos
* alpha
+ prevPos
* ( 1
.0f
- alpha
), 0
.0f, 0
.0f
); Gl
.glBegin(Gl
.GL_QUADS); { Gl
.glVertex2f(0,
0); Gl
.glVertex2f(100,
0); Gl
.glVertex2f(100,
-100); Gl
.glVertex2f(0,
-100); } Gl
.glEnd(); Gl
.glPopMatrix(); Window
.Display(); } static void OnClosed
(object sender, EventArgs e
) { RenderWindow window
= (RenderWindow
)sender
; window
.Close(); } static void OnKeyPressed
(object sender, KeyEventArgs e
) { RenderWindow window
= (RenderWindow
)sender
; if (e
.Code == KeyCode
.Escape) window
.Close(); } }} I have been doing ALOT of searching on this issue and seen similar posts, all of which end simply by saying...disable Desktop Composition :p That is not really an answer. I also came across discussion of a pixel format descriptor PFD_SUPPORT_COMPOSITION and wondered if this is missing in same way, i dunno im grasping at anything at this point. Can anyone help me out?