1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "GLContextTypes.h"
7 #include "GLLibraryLoader.h"
8 #include "mozilla/UniquePtr.h"
21 virtual ~ScopedDC() = 0;
24 struct WindowDC final : public ScopedDC
32 struct PBufferDC final : public ScopedDC
42 ~WGLLibrary() { Reset(); }
49 HGLRC(GLAPIENTRY
* fCreateContext
)(HDC
);
50 BOOL(GLAPIENTRY
* fDeleteContext
)(HGLRC
);
51 BOOL(GLAPIENTRY
* fMakeCurrent
)(HDC
, HGLRC
);
52 PROC(GLAPIENTRY
* fGetProcAddress
)(LPCSTR
);
53 HGLRC(GLAPIENTRY
* fGetCurrentContext
)(void);
54 HDC(GLAPIENTRY
* fGetCurrentDC
)(void);
55 // BOOL (GLAPIENTRY * fShareLists) (HGLRC oldContext, HGLRC newContext);
56 HANDLE(GLAPIENTRY
* fCreatePbuffer
)
57 (HDC hDC
, int iPixelFormat
, int iWidth
, int iHeight
,
58 const int* piAttribList
);
59 BOOL(GLAPIENTRY
* fDestroyPbuffer
)(HANDLE hPbuffer
);
60 HDC(GLAPIENTRY
* fGetPbufferDC
)(HANDLE hPbuffer
);
61 int(GLAPIENTRY
* fReleasePbufferDC
)(HANDLE hPbuffer
, HDC dc
);
62 // BOOL (GLAPIENTRY * fBindTexImage) (HANDLE hPbuffer, int iBuffer);
63 // BOOL (GLAPIENTRY * fReleaseTexImage) (HANDLE hPbuffer, int iBuffer);
64 BOOL(GLAPIENTRY
* fChoosePixelFormat
)
65 (HDC hdc
, const int* piAttribIList
, const FLOAT
* pfAttribFList
,
66 UINT nMaxFormats
, int* piFormats
, UINT
* nNumFormats
);
67 // BOOL (GLAPIENTRY * fGetPixelFormatAttribiv) (HDC hdc,
73 const char*(GLAPIENTRY
* fGetExtensionsStringARB
)(HDC hdc
);
74 HGLRC(GLAPIENTRY
* fCreateContextAttribsARB
)
75 (HDC hdc
, HGLRC hShareContext
, const int* attribList
);
77 BOOL(GLAPIENTRY
* fDXSetResourceShareHandleNV
)
78 (void* dxObject
, HANDLE shareHandle
);
79 HANDLE(GLAPIENTRY
* fDXOpenDeviceNV
)(void* dxDevice
);
80 BOOL(GLAPIENTRY
* fDXCloseDeviceNV
)(HANDLE hDevice
);
81 HANDLE(GLAPIENTRY
* fDXRegisterObjectNV
)
82 (HANDLE hDevice
, void* dxObject
, GLuint name
, GLenum type
, GLenum access
);
83 BOOL(GLAPIENTRY
* fDXUnregisterObjectNV
)(HANDLE hDevice
, HANDLE hObject
);
84 BOOL(GLAPIENTRY
* fDXObjectAccessNV
)(HANDLE hObject
, GLenum access
);
85 BOOL(GLAPIENTRY
* fDXLockObjectsNV
)
86 (HANDLE hDevice
, GLint count
, HANDLE
* hObjects
);
87 BOOL(GLAPIENTRY
* fDXUnlockObjectsNV
)
88 (HANDLE hDevice
, GLint count
, HANDLE
* hObjects
);
91 bool EnsureInitialized();
92 // UniquePtr<WindowDC> CreateDummyWindow();
93 HGLRC
CreateContextWithFallback(HDC dc
, bool tryRobustBuffers
) const;
95 bool HasDXInterop2() const { return bool(mSymbols
.fDXOpenDeviceNV
); }
96 bool IsInitialized() const { return mInitialized
; }
97 auto GetOGLLibrary() const { return mOGLLibrary
; }
98 auto RootDc() const { return mRootDc
; }
99 SymbolLoader
GetSymbolLoader() const;
102 bool mInitialized
= false;
103 PRLibrary
* mOGLLibrary
;
110 // a global WGLLibrary instance
111 extern WGLLibrary sWGLLib
;
114 } /* namespace mozilla */