diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-07-25 20:06:09 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-07-25 20:12:42 +0200 |
commit | 517747b402b92558e98918db8d13b1ae6cf89cae (patch) | |
tree | 423b23afce9df8cc5367340046515caf9eee642c /src/openglgraphics.cpp | |
parent | dd5b4ccecd15be24fd7846e268fba3b400f73685 (diff) | |
download | mana-517747b402b92558e98918db8d13b1ae6cf89cae.tar.gz mana-517747b402b92558e98918db8d13b1ae6cf89cae.tar.bz2 mana-517747b402b92558e98918db8d13b1ae6cf89cae.tar.xz mana-517747b402b92558e98918db8d13b1ae6cf89cae.zip |
Added an option to reduce input lag
Always enabled at the moment.
Diffstat (limited to 'src/openglgraphics.cpp')
-rw-r--r-- | src/openglgraphics.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index 530b40b0..28fd47f6 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -46,7 +46,8 @@ GLuint OpenGLGraphics::mLastImage = 0; OpenGLGraphics::OpenGLGraphics(): mAlpha(false), mTexture(false), mColorAlpha(false), - mSync(false) + mSync(false), + mReduceInputLag(true) { mFloatTexArray = new GLfloat[vertexBufSize * 4]; mIntTexArray = new GLint[vertexBufSize * 4]; @@ -65,6 +66,11 @@ void OpenGLGraphics::setSync(bool sync) mSync = sync; } +void OpenGLGraphics::setReduceInputLag(bool reduceInputLag) +{ + mReduceInputLag = reduceInputLag; +} + bool OpenGLGraphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel) { logger->log("Setting video mode %dx%d %s", @@ -618,6 +624,19 @@ void OpenGLGraphics::drawRescaledImagePattern(Image *image, void OpenGLGraphics::updateScreen() { SDL_GL_SwapBuffers(); + + /* + * glFinish flushes all OpenGL commands and makes sure they have been + * executed before continuing. If we do not do this we allow the next + * frame to be prepared while the current one isn't even displaying yet, + * which can cause input lag that is especially noticable at mouse + * movement. + * + * The setting is optional since calling glFinish can reduce performance + * and increase CPU usage. + */ + if (mReduceInputLag) + glFinish(); } void OpenGLGraphics::_beginDraw() |