2010-05-17 21:04:22 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-05-17 21:04:22 -07:00
|
|
|
|
2013-09-04 05:14:52 -07:00
|
|
|
#include "GLContextTypes.h"
|
2014-01-07 12:02:18 -08:00
|
|
|
#include <windows.h>
|
|
|
|
|
2013-09-04 05:14:52 -07:00
|
|
|
struct PRLibrary;
|
2010-05-17 21:04:22 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
|
|
|
|
|
|
|
class WGLLibrary
|
|
|
|
{
|
|
|
|
public:
|
2012-06-02 09:05:45 -07:00
|
|
|
WGLLibrary()
|
|
|
|
: mInitialized(false),
|
2012-07-30 07:20:58 -07:00
|
|
|
mOGLLibrary(nullptr),
|
2012-06-02 09:05:45 -07:00
|
|
|
mHasRobustness(false),
|
|
|
|
mWindow (0),
|
|
|
|
mWindowDC(0),
|
|
|
|
mWindowGLContext(0),
|
2014-01-10 10:55:23 -08:00
|
|
|
mWindowPixelFormat (0)
|
2012-06-02 09:05:45 -07:00
|
|
|
{}
|
|
|
|
|
2010-05-17 21:04:22 -07:00
|
|
|
typedef HGLRC (GLAPIENTRY * PFNWGLCREATECONTEXTPROC) (HDC);
|
|
|
|
PFNWGLCREATECONTEXTPROC fCreateContext;
|
|
|
|
typedef BOOL (GLAPIENTRY * PFNWGLDELETECONTEXTPROC) (HGLRC);
|
|
|
|
PFNWGLDELETECONTEXTPROC fDeleteContext;
|
|
|
|
typedef BOOL (GLAPIENTRY * PFNWGLMAKECURRENTPROC) (HDC, HGLRC);
|
|
|
|
PFNWGLMAKECURRENTPROC fMakeCurrent;
|
|
|
|
typedef PROC (GLAPIENTRY * PFNWGLGETPROCADDRESSPROC) (LPCSTR);
|
|
|
|
PFNWGLGETPROCADDRESSPROC fGetProcAddress;
|
|
|
|
typedef HGLRC (GLAPIENTRY * PFNWGLGETCURRENTCONTEXT) (void);
|
|
|
|
PFNWGLGETCURRENTCONTEXT fGetCurrentContext;
|
|
|
|
typedef HDC (GLAPIENTRY * PFNWGLGETCURRENTDC) (void);
|
|
|
|
PFNWGLGETCURRENTDC fGetCurrentDC;
|
2010-07-18 22:01:14 -07:00
|
|
|
typedef BOOL (GLAPIENTRY * PFNWGLSHARELISTS) (HGLRC oldContext, HGLRC newContext);
|
|
|
|
PFNWGLSHARELISTS fShareLists;
|
2010-05-17 21:04:22 -07:00
|
|
|
|
|
|
|
typedef HANDLE (WINAPI * PFNWGLCREATEPBUFFERPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList);
|
|
|
|
PFNWGLCREATEPBUFFERPROC fCreatePbuffer;
|
|
|
|
typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERPROC) (HANDLE hPbuffer);
|
|
|
|
PFNWGLDESTROYPBUFFERPROC fDestroyPbuffer;
|
|
|
|
typedef HDC (WINAPI * PFNWGLGETPBUFFERDCPROC) (HANDLE hPbuffer);
|
|
|
|
PFNWGLGETPBUFFERDCPROC fGetPbufferDC;
|
|
|
|
|
|
|
|
typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEPROC) (HANDLE hPbuffer, int iBuffer);
|
|
|
|
PFNWGLBINDTEXIMAGEPROC fBindTexImage;
|
|
|
|
typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEPROC) (HANDLE hPbuffer, int iBuffer);
|
|
|
|
PFNWGLRELEASETEXIMAGEPROC fReleaseTexImage;
|
|
|
|
|
|
|
|
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
|
|
|
|
PFNWGLCHOOSEPIXELFORMATPROC fChoosePixelFormat;
|
|
|
|
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int *piValues);
|
|
|
|
PFNWGLGETPIXELFORMATATTRIBIVPROC fGetPixelFormatAttribiv;
|
|
|
|
|
2011-12-02 23:50:11 -08:00
|
|
|
typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGPROC) (HDC hdc);
|
|
|
|
PFNWGLGETEXTENSIONSSTRINGPROC fGetExtensionsString;
|
|
|
|
|
|
|
|
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSPROC) (HDC hdc, HGLRC hShareContext, const int *attribList);
|
|
|
|
PFNWGLCREATECONTEXTATTRIBSPROC fCreateContextAttribs;
|
|
|
|
|
2014-01-10 10:55:23 -08:00
|
|
|
bool EnsureInitialized();
|
2012-07-30 07:20:58 -07:00
|
|
|
HWND CreateDummyWindow(HDC *aWindowDC = nullptr);
|
2011-12-02 23:50:11 -08:00
|
|
|
|
2012-07-30 13:15:39 -07:00
|
|
|
bool HasRobustness() const { return mHasRobustness; }
|
|
|
|
bool IsInitialized() const { return mInitialized; }
|
|
|
|
HWND GetWindow() const { return mWindow; }
|
|
|
|
HDC GetWindowDC() const {return mWindowDC; }
|
|
|
|
HGLRC GetWindowGLContext() const {return mWindowGLContext; }
|
2012-06-02 09:05:45 -07:00
|
|
|
int GetWindowPixelFormat() const { return mWindowPixelFormat; }
|
2013-12-18 10:09:11 -08:00
|
|
|
PRLibrary *GetOGLLibrary() { return mOGLLibrary; }
|
|
|
|
|
2010-05-17 21:04:22 -07:00
|
|
|
private:
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mInitialized;
|
2010-05-17 21:04:22 -07:00
|
|
|
PRLibrary *mOGLLibrary;
|
2011-12-02 23:50:11 -08:00
|
|
|
bool mHasRobustness;
|
2012-06-02 09:05:45 -07:00
|
|
|
|
|
|
|
HWND mWindow;
|
|
|
|
HDC mWindowDC;
|
|
|
|
HGLRC mWindowGLContext;
|
|
|
|
int mWindowPixelFormat;
|
|
|
|
|
2010-05-17 21:04:22 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
// a global WGLLibrary instance
|
2014-01-10 10:55:23 -08:00
|
|
|
extern WGLLibrary sWGLLibrary;
|
2010-05-17 21:04:22 -07:00
|
|
|
|
|
|
|
} /* namespace gl */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|