michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- 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 michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "GLContextTypes.h" michael@0: #include michael@0: michael@0: struct PRLibrary; michael@0: michael@0: namespace mozilla { michael@0: namespace gl { michael@0: michael@0: class WGLLibrary michael@0: { michael@0: public: michael@0: WGLLibrary() michael@0: : mInitialized(false), michael@0: mOGLLibrary(nullptr), michael@0: mHasRobustness(false), michael@0: mWindow (0), michael@0: mWindowDC(0), michael@0: mWindowGLContext(0), michael@0: mWindowPixelFormat (0) michael@0: {} michael@0: michael@0: typedef HGLRC (GLAPIENTRY * PFNWGLCREATECONTEXTPROC) (HDC); michael@0: PFNWGLCREATECONTEXTPROC fCreateContext; michael@0: typedef BOOL (GLAPIENTRY * PFNWGLDELETECONTEXTPROC) (HGLRC); michael@0: PFNWGLDELETECONTEXTPROC fDeleteContext; michael@0: typedef BOOL (GLAPIENTRY * PFNWGLMAKECURRENTPROC) (HDC, HGLRC); michael@0: PFNWGLMAKECURRENTPROC fMakeCurrent; michael@0: typedef PROC (GLAPIENTRY * PFNWGLGETPROCADDRESSPROC) (LPCSTR); michael@0: PFNWGLGETPROCADDRESSPROC fGetProcAddress; michael@0: typedef HGLRC (GLAPIENTRY * PFNWGLGETCURRENTCONTEXT) (void); michael@0: PFNWGLGETCURRENTCONTEXT fGetCurrentContext; michael@0: typedef HDC (GLAPIENTRY * PFNWGLGETCURRENTDC) (void); michael@0: PFNWGLGETCURRENTDC fGetCurrentDC; michael@0: typedef BOOL (GLAPIENTRY * PFNWGLSHARELISTS) (HGLRC oldContext, HGLRC newContext); michael@0: PFNWGLSHARELISTS fShareLists; michael@0: michael@0: typedef HANDLE (WINAPI * PFNWGLCREATEPBUFFERPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList); michael@0: PFNWGLCREATEPBUFFERPROC fCreatePbuffer; michael@0: typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERPROC) (HANDLE hPbuffer); michael@0: PFNWGLDESTROYPBUFFERPROC fDestroyPbuffer; michael@0: typedef HDC (WINAPI * PFNWGLGETPBUFFERDCPROC) (HANDLE hPbuffer); michael@0: PFNWGLGETPBUFFERDCPROC fGetPbufferDC; michael@0: michael@0: typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEPROC) (HANDLE hPbuffer, int iBuffer); michael@0: PFNWGLBINDTEXIMAGEPROC fBindTexImage; michael@0: typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEPROC) (HANDLE hPbuffer, int iBuffer); michael@0: PFNWGLRELEASETEXIMAGEPROC fReleaseTexImage; michael@0: michael@0: typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); michael@0: PFNWGLCHOOSEPIXELFORMATPROC fChoosePixelFormat; michael@0: typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int *piValues); michael@0: PFNWGLGETPIXELFORMATATTRIBIVPROC fGetPixelFormatAttribiv; michael@0: michael@0: typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGPROC) (HDC hdc); michael@0: PFNWGLGETEXTENSIONSSTRINGPROC fGetExtensionsString; michael@0: michael@0: typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSPROC) (HDC hdc, HGLRC hShareContext, const int *attribList); michael@0: PFNWGLCREATECONTEXTATTRIBSPROC fCreateContextAttribs; michael@0: michael@0: bool EnsureInitialized(); michael@0: HWND CreateDummyWindow(HDC *aWindowDC = nullptr); michael@0: michael@0: bool HasRobustness() const { return mHasRobustness; } michael@0: bool IsInitialized() const { return mInitialized; } michael@0: HWND GetWindow() const { return mWindow; } michael@0: HDC GetWindowDC() const {return mWindowDC; } michael@0: HGLRC GetWindowGLContext() const {return mWindowGLContext; } michael@0: int GetWindowPixelFormat() const { return mWindowPixelFormat; } michael@0: PRLibrary *GetOGLLibrary() { return mOGLLibrary; } michael@0: michael@0: private: michael@0: bool mInitialized; michael@0: PRLibrary *mOGLLibrary; michael@0: bool mHasRobustness; michael@0: michael@0: HWND mWindow; michael@0: HDC mWindowDC; michael@0: HGLRC mWindowGLContext; michael@0: int mWindowPixelFormat; michael@0: michael@0: }; michael@0: michael@0: // a global WGLLibrary instance michael@0: extern WGLLibrary sWGLLibrary; michael@0: michael@0: } /* namespace gl */ michael@0: } /* namespace mozilla */ michael@0: