diff options
author | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-30 18:52:27 +0000 |
---|---|---|
committer | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-30 18:52:27 +0000 |
commit | 7a812dd64695773879bddea05188328e4fc846ff (patch) | |
tree | 44e7f842209cee1ceb67ea74b1145eb1ddcdcac4 /third_party | |
parent | 3b4bac6a6a0f62250bc04124b611074be53d8530 (diff) | |
download | chromium_src-7a812dd64695773879bddea05188328e4fc846ff.zip chromium_src-7a812dd64695773879bddea05188328e4fc846ff.tar.gz chromium_src-7a812dd64695773879bddea05188328e4fc846ff.tar.bz2 |
Added support to GLEW for dynamically looking up the core WGL entry
points to avoid the need to link against opengl32.lib. Added
_ATL_NO_OPENGL #define in build/common.gypi to prevent link directive
from forcibly pulling in opengl32.lib for any Chrome code using ATL.
Once upstream code in WebKit is changed to use the new wglew entry
points and remove opengl32.lib from the link line, chrome.dll will no
longer depend on opengl32.dll.
BUG=45586
TEST=ran WebGL with --in-process-webgl
Review URL: http://codereview.chromium.org/2856022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51277 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
-rw-r--r-- | third_party/glew/README.chromium | 3 | ||||
-rw-r--r-- | third_party/glew/include/GL/wglew.h | 48 | ||||
-rw-r--r-- | third_party/glew/src/glew.c | 54 |
3 files changed, 104 insertions, 1 deletions
diff --git a/third_party/glew/README.chromium b/third_party/glew/README.chromium index 9a1ebe9..0266369 100644 --- a/third_party/glew/README.chromium +++ b/third_party/glew/README.chromium @@ -26,5 +26,8 @@ Compared to the original distribution: - Fixed the order of #include guards around _glewInit_GLX_VERSION_1_1 in glew.c when GLEW_MX is defined. + - For the case where GLEW_MX is not defined, added a wglewInit() and + support for dynamically looking up even the core WGL entry points. + Originally obtained from http://glew.sourceforge.net/ . The LICENSE.txt from that distribution has been preserved here. diff --git a/third_party/glew/include/GL/wglew.h b/third_party/glew/include/GL/wglew.h index 2eaad36..700bf50 100644 --- a/third_party/glew/include/GL/wglew.h +++ b/third_party/glew/include/GL/wglew.h @@ -87,6 +87,42 @@ extern "C" { #endif +/* ------------------------------- Core WGL -------------------------------- */ + +/* This section supports dynamic lookup of the core WGL entry points + under different names. It is not supported for GLEW_MX. */ + +#ifndef GLEW_MX + +#ifndef WGL_core_wgl +#define WGL_core_wgl 1 + +typedef BOOL (WINAPI * PFNWGLCOPYCONTEXTPROC)(HGLRC, HGLRC, UINT); +typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTPROC)(HDC); +typedef HGLRC (WINAPI * PFNWGLCREATELAYERCONTEXTPROC)(HDC, int); +typedef BOOL (WINAPI * PFNWGLDELETECONTEXTPROC)(HGLRC); +typedef HGLRC (WINAPI * PFNWGLGETCURRENTCONTEXTPROC)(VOID); +typedef HDC (WINAPI * PFNWGLGETCURRENTDCPROC)(VOID); +typedef PROC (WINAPI * PFNWGLGETPROCADDRESSPROC)(LPCSTR); +typedef BOOL (WINAPI * PFNWGLMAKECURRENTPROC)(HDC, HGLRC); +typedef BOOL (WINAPI * PFNWGLSHARELISTSPROC)(HGLRC, HGLRC); +typedef BOOL (WINAPI * PFNSWAPBUFFERSPROC)(HDC); + +#define wglewCopyContext WGLEW_GET_FUN(__wglewCopyContext) +#define wglewCreateContext WGLEW_GET_FUN(__wglewCreateContext) +#define wglewCreateLayerContext WGLEW_GET_FUN(__wglewCreateLayerContext) +#define wglewDeleteContext WGLEW_GET_FUN(__wglewDeleteContext) +#define wglewGetCurrentContext WGLEW_GET_FUN(__wglewGetCurrentContext) +#define wglewGetCurrentDC WGLEW_GET_FUN(__wglewGetCurrentDC) +#define wglewGetProcAddress WGLEW_GET_FUN(__wglewGetProcAddress) +#define wglewMakeCurrent WGLEW_GET_FUN(__wglewMakeCurrent) +#define wglewShareLists WGLEW_GET_FUN(__wglewShareLists) +#define wglewSwapBuffers WGLEW_GET_FUN(__wglewSwapBuffers) + +#endif /* WGL_core_wgl */ + +#endif /* !GLEW_MX */ + /* -------------------------- WGL_3DFX_multisample ------------------------- */ #ifndef WGL_3DFX_multisample @@ -967,6 +1003,17 @@ struct WGLEWContextStruct { #endif /* GLEW_MX */ +WGLEW_EXPORT PFNWGLCOPYCONTEXTPROC __wglewCopyContext; +WGLEW_EXPORT PFNWGLCREATECONTEXTPROC __wglewCreateContext; +WGLEW_EXPORT PFNWGLCREATELAYERCONTEXTPROC __wglewCreateLayerContext; +WGLEW_EXPORT PFNWGLDELETECONTEXTPROC __wglewDeleteContext; +WGLEW_EXPORT PFNWGLGETCURRENTCONTEXTPROC __wglewGetCurrentContext; +WGLEW_EXPORT PFNWGLGETCURRENTDCPROC __wglewGetCurrentDC; +WGLEW_EXPORT PFNWGLGETPROCADDRESSPROC __wglewGetProcAddress; +WGLEW_EXPORT PFNWGLMAKECURRENTPROC __wglewMakeCurrent; +WGLEW_EXPORT PFNWGLSHARELISTSPROC __wglewShareLists; +WGLEW_EXPORT PFNSWAPBUFFERSPROC __wglewSwapBuffers; + WGLEW_EXPORT PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL; WGLEW_EXPORT PFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB; @@ -1150,6 +1197,7 @@ GLEWAPI GLboolean wglewContextIsSupported (WGLEWContext* ctx, const char* name); #define WGLEW_GET_VAR(x) (*(const GLboolean*)&x) #define WGLEW_GET_FUN(x) x +GLEWAPI GLboolean wglewInit(); GLEWAPI GLboolean wglewIsSupported (const char* name); #endif /* GLEW_MX */ diff --git a/third_party/glew/src/glew.c b/third_party/glew/src/glew.c index 9a16717..8d89d8a 100644 --- a/third_party/glew/src/glew.c +++ b/third_party/glew/src/glew.c @@ -72,11 +72,35 @@ #endif /* GLEW_MX */ #ifdef _WIN32 + +#ifndef GLEW_MX +void* WinGetProcAddress(const GLubyte* name); + +GLboolean wglewInit() +{ + GLboolean r = GL_FALSE; + + r = ((wglewCopyContext = (PFNWGLCOPYCONTEXTPROC)WinGetProcAddress((const GLubyte*)"wglCopyContext")) == NULL) || r; + r = ((wglewCreateContext = (PFNWGLCREATECONTEXTPROC)WinGetProcAddress((const GLubyte*)"wglCreateContext")) == NULL) || r; + r = ((wglewCreateLayerContext = (PFNWGLCREATELAYERCONTEXTPROC)WinGetProcAddress((const GLubyte*)"wglCreateLayerContext")) == NULL) || r; + r = ((wglewDeleteContext = (PFNWGLDELETECONTEXTPROC)WinGetProcAddress((const GLubyte*)"wglDeleteContext")) == NULL) || r; + r = ((wglewGetCurrentContext = (PFNWGLGETCURRENTCONTEXTPROC)WinGetProcAddress((const GLubyte*)"wglGetCurrentContext")) == NULL) || r; + r = ((wglewGetCurrentDC = (PFNWGLGETCURRENTDCPROC)WinGetProcAddress((const GLubyte*)"wglGetCurrentDC")) == NULL) || r; + r = ((wglewGetProcAddress = (PFNWGLGETPROCADDRESSPROC)WinGetProcAddress((const GLubyte*)"wglGetProcAddress")) == NULL) || r; + r = ((wglewMakeCurrent = (PFNWGLMAKECURRENTPROC)WinGetProcAddress((const GLubyte*)"wglMakeCurrent")) == NULL) || r; + r = ((wglewShareLists = (PFNWGLSHARELISTSPROC)WinGetProcAddress((const GLubyte*)"wglShareLists")) == NULL) || r; + r = ((wglewSwapBuffers = (PFNSWAPBUFFERSPROC)WinGetProcAddress((const GLubyte*)"SwapBuffers")) == NULL) || r; + + return !r; +} +#endif /* !GLEW_MX */ + void* WinGetProcAddress(const GLubyte* name) { /* Need to use GetProcAddress to bootstrap things now that we are dynamically looking up OpenGL 1.1 entry points as well. */ static HMODULE oglImage = NULL; + static HMODULE gdi32Image = NULL; // For SwapBuffers. static PFNOSMESAGETPROCADDRESSPROC osmesaGetProcAddress = NULL; void* proc = NULL; @@ -84,6 +108,12 @@ void* WinGetProcAddress(const GLubyte* name) oglImage = LoadLibraryA("osmesa.dll"); if (NULL == oglImage) { oglImage = LoadLibraryA("opengl32.dll"); +#ifndef GLEW_MX + if (NULL != oglImage) { + gdi32Image = LoadLibraryA("gdi32.dll"); + wglewInit(); + } +#endif /* !GLEW_MX */ } else { osmesaGetProcAddress = (PFNOSMESAGETPROCADDRESSPROC) GetProcAddress(oglImage, "OSMesaGetProcAddress"); @@ -91,14 +121,25 @@ void* WinGetProcAddress(const GLubyte* name) } if (NULL != oglImage) { proc = (void*) GetProcAddress(oglImage, (LPCSTR) name); +#ifndef GLEW_MX + if (NULL == proc) { + proc = (void*) GetProcAddress(gdi32Image, (LPCSTR) name); + } +#endif } if (NULL == proc) { if (osmesaGetProcAddress) { proc = osmesaGetProcAddress(name); } +#ifdef GLEW_MX else { proc = wglGetProcAddress((LPCSTR) name); } +#else + else if (wglewGetProcAddress) { + proc = wglewGetProcAddress((LPCSTR) name); + } +#endif } return proc; } @@ -8077,6 +8118,17 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) #if !defined(GLEW_MX) +PFNWGLCOPYCONTEXTPROC __wglewCopyContext = NULL; +PFNWGLCREATECONTEXTPROC __wglewCreateContext = NULL; +PFNWGLCREATELAYERCONTEXTPROC __wglewCreateLayerContext = NULL; +PFNWGLDELETECONTEXTPROC __wglewDeleteContext = NULL; +PFNWGLGETCURRENTCONTEXTPROC __wglewGetCurrentContext = NULL; +PFNWGLGETCURRENTDCPROC __wglewGetCurrentDC = NULL; +PFNWGLGETPROCADDRESSPROC __wglewGetProcAddress = NULL; +PFNWGLMAKECURRENTPROC __wglewMakeCurrent = NULL; +PFNWGLSHARELISTSPROC __wglewShareLists = NULL; +PFNSWAPBUFFERSPROC __wglewSwapBuffers = NULL; + PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL = NULL; PFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB = NULL; @@ -8714,7 +8766,7 @@ GLboolean wglewGetExtension (const char* name) else p = (GLubyte*)_wglewGetExtensionsStringEXT(); else - p = (GLubyte*)_wglewGetExtensionsStringARB(wglGetCurrentDC()); + p = (GLubyte*)_wglewGetExtensionsStringARB(wglewGetCurrentDC()); if (0 == p) return GL_FALSE; end = p + _glewStrLen(p); while (p < end) |