diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-20 22:08:54 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-20 22:08:54 +0000 |
commit | 4bedba77d40df5fa5f1e00f5918123ee8711ca76 (patch) | |
tree | 0d34ff8aac44eaf1281fbcbdbe38867cb2a35f19 /third_party | |
parent | 163cf4a0682a5e32f9db5e413dab296f17027015 (diff) | |
download | chromium_src-4bedba77d40df5fa5f1e00f5918123ee8711ca76.zip chromium_src-4bedba77d40df5fa5f1e00f5918123ee8711ca76.tar.gz chromium_src-4bedba77d40df5fa5f1e00f5918123ee8711ca76.tar.bz2 |
Added OSMesa based GLContext.
- Renders 3D using Mesa offscreen software renderer.
- Will be used to run 3D tests on bots that do not support native OpenGL.
- Extended glew library to use the osmesa shared library instead of the regular OpenGL one if it is in the search path.
- Only works on Windows with this changelist, though other platforms will continue to use native OpenGL.
- Added a stub GLContext implementation for use in unit tests.
Review URL: http://codereview.chromium.org/1629029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45093 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
-rw-r--r-- | third_party/glew/include/GL/glew.h | 3 | ||||
-rw-r--r-- | third_party/glew/include/GL/osmew.h | 51 | ||||
-rw-r--r-- | third_party/glew/src/glew.c | 36 |
3 files changed, 88 insertions, 2 deletions
diff --git a/third_party/glew/include/GL/glew.h b/third_party/glew/include/GL/glew.h index 90438a7..34183a9 100644 --- a/third_party/glew/include/GL/glew.h +++ b/third_party/glew/include/GL/glew.h @@ -12863,6 +12863,8 @@ GLEW_VAR_EXPORT GLboolean __GLEW_WIN_swap_hint; }; /* GLEWContextStruct */ #endif /* GLEW_MX */ +typedef void* (GLAPIENTRY * PFNOSMESAGETPROCADDRESSPROC) (const GLubyte* name); + /* ------------------------------------------------------------------------- */ /* error codes */ @@ -12898,6 +12900,7 @@ GLEWAPI GLboolean glewContextIsSupported (GLEWContext* ctx, const char* name); #else /* GLEW_MX */ +void osmewContextInit (); GLEWAPI GLenum glewInit (); GLEWAPI GLenum glewInitGL2Hack (); GLEWAPI GLboolean glewIsSupported (const char* name); diff --git a/third_party/glew/include/GL/osmew.h b/third_party/glew/include/GL/osmew.h new file mode 100644 index 0000000..4816694 --- /dev/null +++ b/third_party/glew/include/GL/osmew.h @@ -0,0 +1,51 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef __osmew_h__ +#define __osmew_h__ +#define __OSMEW_H__ + +#include <GL/glew.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(GLAPIENTRY) +#if defined(_WIN32) +#define GLAPIENTRY __stdcall +#else +#define GLAPIENTRY +#endif +#endif + +#define OSMEW_GET_FUN(x) x + +// Subset of OSMesa functions. + +typedef struct osmesa_context *OSMesaContext; +typedef OSMesaContext (GLAPIENTRY * PFNOSMESACREATECONTEXTPROC) (GLenum format, OSMesaContext sharelist); +typedef void (GLAPIENTRY * PFNOSMESADESTROYCONTEXTPROC) (OSMesaContext ctx); +typedef GLboolean (GLAPIENTRY * PFNOSMESAMAKECURRENTPROC) (OSMesaContext ctx, void* buffer, GLenum type, GLsizei width, GLsizei height); +typedef OSMesaContext (GLAPIENTRY * PFNOSMESAGETCURRENTCONTEXTPROC) (void); + +#define OSMesaCreateContext OSMEW_GET_FUN(__osmesaCreateContext) +#define OSMesaDestroyContext OSMEW_GET_FUN(__osmesaDestroyContext) +#define OSMesaMakeCurrent OSMEW_GET_FUN(__osmesaMakeCurrent) +#define OSMesaGetCurrentContext OSMEW_GET_FUN(__osmesaGetCurrentContext) + +extern PFNOSMESACREATECONTEXTPROC __osmesaCreateContext; +extern PFNOSMESADESTROYCONTEXTPROC __osmesaDestroyContext; +extern PFNOSMESAMAKECURRENTPROC __osmesaMakeCurrent; +extern PFNOSMESAGETCURRENTCONTEXTPROC __osmesaGetCurrentContext; + +void osmewInit (); + +#undef GLAPIENTRY + +#ifdef __cplusplus +} +#endif + +#endif /* __osmew_h__ */ diff --git a/third_party/glew/src/glew.c b/third_party/glew/src/glew.c index d987695..a9fe3a5 100644 --- a/third_party/glew/src/glew.c +++ b/third_party/glew/src/glew.c @@ -36,6 +36,8 @@ # include <GL/glxew.h> #endif +#include <GL/osmew.h> + /* * Define glewGetContext and related helper macros. */ @@ -75,16 +77,28 @@ 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 PFNOSMESAGETPROCADDRESSPROC osmesaGetProcAddress = NULL; void* proc = NULL; if (NULL == oglImage) { - oglImage = LoadLibraryA("opengl32.dll"); + oglImage = LoadLibraryA("osmesa.dll"); + if (NULL == oglImage) { + oglImage = LoadLibraryA("opengl32.dll"); + } + else { + osmesaGetProcAddress = (PFNOSMESAGETPROCADDRESSPROC) GetProcAddress(oglImage, "_OSMesaGetProcAddress@4"); + } } if (NULL != oglImage) { proc = (void*) GetProcAddress(oglImage, (LPCSTR) name); } if (NULL == proc) { - proc = wglGetProcAddress((LPCSTR) name); + if (osmesaGetProcAddress) { + proc = osmesaGetProcAddress(name); + } + else { + proc = wglGetProcAddress((LPCSTR) name); + } } return proc; } @@ -9887,6 +9901,22 @@ const GLubyte* glewGetString (GLenum name) GLboolean glewExperimental = GL_FALSE; #if !defined(GLEW_MX) +
+// Subset of OSMesa functions.
+PFNOSMESACREATECONTEXTPROC __osmesaCreateContext = NULL;
+PFNOSMESADESTROYCONTEXTPROC __osmesaDestroyContext = NULL;
+PFNOSMESAMAKECURRENTPROC __osmesaMakeCurrent = NULL;
+PFNOSMESAGETCURRENTCONTEXTPROC __osmesaGetCurrentContext = NULL;
+ +void osmewInit (void) +{ + // Attempt to get OSMesa entry points on all platforms. Must get OSMesaGetProcAddress first so future calls to + // glewGetProcAddress use it. + __osmesaCreateContext = (PFNOSMESACREATECONTEXTPROC)glewGetProcAddress((const GLubyte*)"OSMesaCreateContext"); + __osmesaDestroyContext = (PFNOSMESADESTROYCONTEXTPROC)glewGetProcAddress((const GLubyte*)"OSMesaDestroyContext"); + __osmesaMakeCurrent = (PFNOSMESAMAKECURRENTPROC)glewGetProcAddress((const GLubyte*)"OSMesaMakeCurrent"); + __osmesaGetCurrentContext = (PFNOSMESAGETCURRENTCONTEXTPROC)glewGetProcAddress((const GLubyte*)"OSMesaGetCurrentContext"); +} #if defined(_WIN32) extern GLenum wglewContextInit (void); @@ -9899,6 +9929,8 @@ GLenum glewInit () GLenum r; if ( (r = glewContextInit()) ) return r; #if defined(_WIN32) + // TODO(apatrick): Do this on other platforms. + osmewInit(); return wglewContextInit(); #elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) /* _UNIX */ return glxewContextInit(); |