michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GLLIBRARYLOADER_H_ michael@0: #define GLLIBRARYLOADER_H_ michael@0: michael@0: #include michael@0: michael@0: #ifdef WIN32 michael@0: #include michael@0: #endif michael@0: michael@0: #include "GLDefs.h" michael@0: #include "nscore.h" michael@0: #include "prlink.h" michael@0: michael@0: namespace mozilla { michael@0: namespace gl { michael@0: michael@0: class GLLibraryLoader michael@0: { michael@0: public: michael@0: bool OpenLibrary(const char *library); michael@0: michael@0: typedef PRFuncPtr (GLAPIENTRY * PlatformLookupFunction) (const char *); michael@0: michael@0: enum { michael@0: MAX_SYMBOL_NAMES = 6, michael@0: MAX_SYMBOL_LENGTH = 128 michael@0: }; michael@0: michael@0: typedef struct { michael@0: PRFuncPtr *symPointer; michael@0: const char *symNames[MAX_SYMBOL_NAMES]; michael@0: } SymLoadStruct; michael@0: michael@0: bool LoadSymbols(SymLoadStruct *firstStruct, michael@0: bool tryplatform = false, michael@0: const char *prefix = nullptr, michael@0: bool warnOnFailure = true); michael@0: michael@0: /* michael@0: * Static version of the functions in this class michael@0: */ michael@0: static PRFuncPtr LookupSymbol(PRLibrary *lib, michael@0: const char *symname, michael@0: PlatformLookupFunction lookupFunction = nullptr); michael@0: static bool LoadSymbols(PRLibrary *lib, michael@0: SymLoadStruct *firstStruct, michael@0: PlatformLookupFunction lookupFunction = nullptr, michael@0: const char *prefix = nullptr, michael@0: bool warnOnFailure = true); michael@0: protected: michael@0: GLLibraryLoader() { michael@0: mLibrary = nullptr; michael@0: mLookupFunc = nullptr; michael@0: } michael@0: michael@0: PRLibrary *mLibrary; michael@0: PlatformLookupFunction mLookupFunc; michael@0: }; michael@0: michael@0: } /* namespace gl */ michael@0: } /* namespace mozilla */ michael@0: michael@0: #endif /* GLLIBRARYLOADER_H_ */