gfx/gl/WGLLibrary.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/gl/WGLLibrary.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,93 @@
     1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "GLContextTypes.h"
    1.10 +#include <windows.h>
    1.11 +
    1.12 +struct PRLibrary;
    1.13 +
    1.14 +namespace mozilla {
    1.15 +namespace gl {
    1.16 +
    1.17 +class WGLLibrary
    1.18 +{
    1.19 +public:
    1.20 +    WGLLibrary() 
    1.21 +      : mInitialized(false), 
    1.22 +        mOGLLibrary(nullptr),
    1.23 +        mHasRobustness(false), 
    1.24 +        mWindow (0),
    1.25 +        mWindowDC(0),
    1.26 +        mWindowGLContext(0),
    1.27 +        mWindowPixelFormat (0)
    1.28 +    {}
    1.29 +
    1.30 +    typedef HGLRC (GLAPIENTRY * PFNWGLCREATECONTEXTPROC) (HDC);
    1.31 +    PFNWGLCREATECONTEXTPROC fCreateContext;
    1.32 +    typedef BOOL (GLAPIENTRY * PFNWGLDELETECONTEXTPROC) (HGLRC);
    1.33 +    PFNWGLDELETECONTEXTPROC fDeleteContext;
    1.34 +    typedef BOOL (GLAPIENTRY * PFNWGLMAKECURRENTPROC) (HDC, HGLRC);
    1.35 +    PFNWGLMAKECURRENTPROC fMakeCurrent;
    1.36 +    typedef PROC (GLAPIENTRY * PFNWGLGETPROCADDRESSPROC) (LPCSTR);
    1.37 +    PFNWGLGETPROCADDRESSPROC fGetProcAddress;
    1.38 +    typedef HGLRC (GLAPIENTRY * PFNWGLGETCURRENTCONTEXT) (void);
    1.39 +    PFNWGLGETCURRENTCONTEXT fGetCurrentContext;
    1.40 +    typedef HDC (GLAPIENTRY * PFNWGLGETCURRENTDC) (void);
    1.41 +    PFNWGLGETCURRENTDC fGetCurrentDC;
    1.42 +    typedef BOOL (GLAPIENTRY * PFNWGLSHARELISTS) (HGLRC oldContext, HGLRC newContext);
    1.43 +    PFNWGLSHARELISTS fShareLists;
    1.44 +
    1.45 +    typedef HANDLE (WINAPI * PFNWGLCREATEPBUFFERPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList);
    1.46 +    PFNWGLCREATEPBUFFERPROC fCreatePbuffer;
    1.47 +    typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERPROC) (HANDLE hPbuffer);
    1.48 +    PFNWGLDESTROYPBUFFERPROC fDestroyPbuffer;
    1.49 +    typedef HDC (WINAPI * PFNWGLGETPBUFFERDCPROC) (HANDLE hPbuffer);
    1.50 +    PFNWGLGETPBUFFERDCPROC fGetPbufferDC;
    1.51 +
    1.52 +    typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEPROC) (HANDLE hPbuffer, int iBuffer);
    1.53 +    PFNWGLBINDTEXIMAGEPROC fBindTexImage;
    1.54 +    typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEPROC) (HANDLE hPbuffer, int iBuffer);
    1.55 +    PFNWGLRELEASETEXIMAGEPROC fReleaseTexImage;
    1.56 +
    1.57 +    typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
    1.58 +    PFNWGLCHOOSEPIXELFORMATPROC fChoosePixelFormat;
    1.59 +    typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int *piValues);
    1.60 +    PFNWGLGETPIXELFORMATATTRIBIVPROC fGetPixelFormatAttribiv;
    1.61 +
    1.62 +    typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGPROC) (HDC hdc);
    1.63 +    PFNWGLGETEXTENSIONSSTRINGPROC fGetExtensionsString;
    1.64 +
    1.65 +    typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSPROC) (HDC hdc, HGLRC hShareContext, const int *attribList);
    1.66 +    PFNWGLCREATECONTEXTATTRIBSPROC fCreateContextAttribs;
    1.67 +
    1.68 +    bool EnsureInitialized();
    1.69 +    HWND CreateDummyWindow(HDC *aWindowDC = nullptr);
    1.70 +
    1.71 +    bool HasRobustness() const { return mHasRobustness; }
    1.72 +    bool IsInitialized() const { return mInitialized; }
    1.73 +    HWND GetWindow() const { return mWindow; }
    1.74 +    HDC GetWindowDC() const {return mWindowDC; }
    1.75 +    HGLRC GetWindowGLContext() const {return mWindowGLContext; }
    1.76 +    int GetWindowPixelFormat() const { return mWindowPixelFormat; }
    1.77 +    PRLibrary *GetOGLLibrary() { return mOGLLibrary; }
    1.78 +
    1.79 +private:
    1.80 +    bool mInitialized;
    1.81 +    PRLibrary *mOGLLibrary;
    1.82 +    bool mHasRobustness;
    1.83 +
    1.84 +    HWND mWindow;
    1.85 +    HDC mWindowDC;
    1.86 +    HGLRC mWindowGLContext;
    1.87 +    int mWindowPixelFormat;
    1.88 +
    1.89 +};
    1.90 +
    1.91 +// a global WGLLibrary instance
    1.92 +extern WGLLibrary sWGLLibrary;
    1.93 +
    1.94 +} /* namespace gl */
    1.95 +} /* namespace mozilla */
    1.96 +

mercurial