-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): Follow spec for detecting adaptive VSync support (#6414)
* Fix Adaptive VSync detection. * Forgot to add the project files again. * Don't include glxew for macos. * Fix OpenGL ES build. * Some small improvements. * Enable adaptive vsync for OpenglES if it exists. * Apply suggestions from code review
- Loading branch information
Showing
16 changed files
with
100 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* opengl.cpp | ||
Copyright (c) 2014 by Michael Zahniser | ||
Endless Sky is free software: you can redistribute it and/or modify it under the | ||
terms of the GNU General Public License as published by the Free Software | ||
Foundation, either version 3 of the License, or (at your option) any later version. | ||
Endless Sky is distributed in the hope that it will be useful, but WITHOUT ANY | ||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
*/ | ||
|
||
#include "opengl.h" | ||
|
||
#if !defined(__APPLE__) && !defined(ES_GLES) | ||
#ifdef _WIN32 | ||
#include <GL/wglew.h> | ||
#else | ||
#include <GL/glxew.h> | ||
#endif | ||
#endif | ||
|
||
#include <cstring> | ||
|
||
namespace { | ||
bool HasOpenGLExtension(const char *name) { | ||
#ifndef __APPLE__ | ||
auto extensions = reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)); | ||
return strstr(extensions, name); | ||
#else | ||
bool value = false; | ||
GLint extensionCount = 0; | ||
glGetIntegerv(GL_NUM_EXTENSIONS, &extensionCount); | ||
for(GLint i = 0; i < extensionCount && !value; ++i) | ||
{ | ||
auto extension = reinterpret_cast<const char *>(glGetStringi(GL_EXTENSIONS, i)); | ||
value = (extension && strstr(extension, name)); | ||
} | ||
return value; | ||
#endif | ||
} | ||
} | ||
|
||
|
||
|
||
bool OpenGL::HasAdaptiveVSyncSupport() | ||
{ | ||
#ifdef __APPLE__ | ||
// macOS doesn't support Adaptive VSync for OpenGL. | ||
return false; | ||
#elif defined(ES_GLES) | ||
return HasOpenGLExtension("_swap_control_tear"); | ||
#elif defined(_WIN32) | ||
return WGL_EXT_swap_control_tear || HasOpenGLExtension("_swap_control_tear"); | ||
#else | ||
return GLX_EXT_swap_control_tear; | ||
#endif | ||
} | ||
|
||
|
||
|
||
bool OpenGL::HasSwizzleSupport() | ||
{ | ||
return HasOpenGLExtension("_texture_swizzle"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters