Commit f22c6b13 by Geoff Lang

Store WGL extensions in FunctionsWGL.

Add helpers for checking which extensions are available instead of discarding the extension strings after function loading. BUG=angleproject:1144 Change-Id: Ie3d209cd5f6f116bbedaa618a59a4c2d7ddda4d6 Reviewed-on: https://chromium-review.googlesource.com/296360Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 1ea9aaad
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include "libANGLE/renderer/gl/wgl/FunctionsWGL.h" #include "libANGLE/renderer/gl/wgl/FunctionsWGL.h"
#include "common/string_utils.h"
namespace rx namespace rx
{ {
...@@ -30,12 +32,15 @@ static void GetWGLProcAddress(HMODULE glModule, PFNWGLGETPROCADDRESSPROC getProc ...@@ -30,12 +32,15 @@ static void GetWGLProcAddress(HMODULE glModule, PFNWGLGETPROCADDRESSPROC getProc
} }
template <typename T> template <typename T>
static void GetWGLExtensionProcAddress(HMODULE glModule, PFNWGLGETPROCADDRESSPROC getProcAddressWGL, static void GetWGLExtensionProcAddress(HMODULE glModule,
const std::string &extensions, const std::string &extensionName, PFNWGLGETPROCADDRESSPROC getProcAddressWGL,
const std::string &procName, T *outProcAddress) const std::vector<std::string> &extensions,
const std::string &extensionName,
const std::string &procName,
T *outProcAddress)
{ {
T proc = nullptr; T proc = nullptr;
if (extensions.find(extensionName) != std::string::npos) if (std::find(extensions.begin(), extensions.end(), extensionName) != extensions.end())
{ {
GetWGLProcAddress(glModule, getProcAddressWGL, procName, &proc); GetWGLProcAddress(glModule, getProcAddressWGL, procName, &proc);
} }
...@@ -112,15 +117,16 @@ void FunctionsWGL::initialize(HMODULE glModule, HDC context) ...@@ -112,15 +117,16 @@ void FunctionsWGL::initialize(HMODULE glModule, HDC context)
GetWGLProcAddress(glModule, getProcAddress, "wglGetExtensionsStringEXT", &getExtensionStringEXT); GetWGLProcAddress(glModule, getProcAddress, "wglGetExtensionsStringEXT", &getExtensionStringEXT);
GetWGLProcAddress(glModule, getProcAddress, "wglGetExtensionsStringARB", &getExtensionStringARB); GetWGLProcAddress(glModule, getProcAddress, "wglGetExtensionsStringARB", &getExtensionStringARB);
std::string extensions = ""; std::string extensionString = "";
if (getExtensionStringEXT) if (getExtensionStringEXT)
{ {
extensions = getExtensionStringEXT(); extensionString = getExtensionStringEXT();
} }
else if (getExtensionStringARB && context) else if (getExtensionStringARB && context)
{ {
extensions = getExtensionStringARB(context); extensionString = getExtensionStringARB(context);
} }
angle::SplitStringAlongWhitespace(extensionString, &extensions);
// Load the wgl extension functions by checking if the context supports the extension first // Load the wgl extension functions by checking if the context supports the extension first
...@@ -148,4 +154,8 @@ void FunctionsWGL::initialize(HMODULE glModule, HDC context) ...@@ -148,4 +154,8 @@ void FunctionsWGL::initialize(HMODULE glModule, HDC context)
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_ARB_render_texture", "wglSetPbufferAttribARB", &setPbufferAttribARB); GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_ARB_render_texture", "wglSetPbufferAttribARB", &setPbufferAttribARB);
} }
bool FunctionsWGL::hasExtension(const std::string &ext) const
{
return std::find(extensions.begin(), extensions.end(), ext) != extensions.end();
}
} }
...@@ -20,6 +20,10 @@ class FunctionsWGL : angle::NonCopyable ...@@ -20,6 +20,10 @@ class FunctionsWGL : angle::NonCopyable
// Loads all available wgl functions, may be called multiple times // Loads all available wgl functions, may be called multiple times
void initialize(HMODULE glModule, HDC context); void initialize(HMODULE glModule, HDC context);
// Extension information
std::vector<std::string> extensions;
bool hasExtension(const std::string &ext) const;
// Base WGL functions // Base WGL functions
PFNWGLCOPYCONTEXTPROC copyContext; PFNWGLCOPYCONTEXTPROC copyContext;
PFNWGLCREATECONTEXTPROC createContext; PFNWGLCREATECONTEXTPROC createContext;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment