4#ifndef QWINDOWSGLCONTEXT_H
5#define QWINDOWSGLCONTEXT_H
7#include <QtCore/qt_windows.h>
10#include <QtGui/qopenglcontext.h>
52 void apply(QSurfaceFormat *format)
const;
59#ifndef QT_NO_DEBUG_STREAM
60QDebug operator<<(QDebug d,
const PIXELFORMATDESCRIPTOR &);
67 bool init(
bool softwareRendering);
79 HGLRC (WINAPI * wglGetCurrentContext)();
80 HDC (WINAPI * wglGetCurrentDC)();
98 int (WINAPI * wglDescribePixelFormat)(HDC dc,
int pf, UINT size, PIXELFORMATDESCRIPTOR *pfd);
115 (HDC hdc,
int iPixelFormat,
int iLayerPlane,
116 uint nAttributes,
const int *piAttributes,
int *piValues);
120 const float *pfAttribFList, uint nMaxFormats,
int *piFormats,
135 {
return wglGetPixelFormatAttribIVARB && wglChoosePixelFormatARB && wglCreateContextAttribsARB; }
144 {
return QOpenGLContext::LibGL; }
178 void swapBuffers(QPlatformSurface *surface)
override;
180 bool makeCurrent(QPlatformSurface *surface)
override;
192 typedef GLenum (APIENTRY *GlGetGraphicsResetStatusArbType)();
194 inline void releaseDCs();
195 bool updateObtainedParams(HDC hdc,
int *obtainedSwapInterval =
nullptr);
198 QSurfaceFormat m_obtainedFormat;
199 HGLRC m_renderingContext =
nullptr;
200 std::vector<QOpenGLContextData> m_windowContexts;
201 PIXELFORMATDESCRIPTOR m_obtainedPixelFormatDescriptor;
202 int m_pixelFormat = 0;
203 bool m_extensionsUsed =
false;
204 int m_swapInterval = -1;
205 bool m_ownsContext =
true;
206 GlGetGraphicsResetStatusArbType m_getGraphicsResetStatus =
nullptr;
Static Open GL context containing version information, extension function pointers,...
BOOL(APIENTRY * WglSwapInternalExt)(int interval)
QWindowsOpenGLContext * createContext(HGLRC context, HWND window) override
const QWindowsOpenGLContextFormat defaultFormat
void * moduleHandle() const override
WglChoosePixelFormatARB wglChoosePixelFormatARB
WglCreateContextAttribsARB wglCreateContextAttribsARB
static QByteArray getGlString(unsigned int which)
QOpenGLContext::OpenGLModuleType moduleType() const override
HGLRC(APIENTRY * WglCreateContextAttribsARB)(HDC, HGLRC, const int *)
WglGetExtensionsStringARB wglGetExtensionsStringARB
WglGetSwapInternalExt wglGetSwapInternalExt
const QByteArray renderer
bool hasExtensions() const
QWindowsOpenGLContext * createContext(QOpenGLContext *context) override
WglGetPixelFormatAttribIVARB wglGetPixelFormatAttribIVARB
bool(APIENTRY * WglGetPixelFormatAttribIVARB)(HDC hdc, int iPixelFormat, int iLayerPlane, uint nAttributes, const int *piAttributes, int *piValues)
WglSwapInternalExt wglSwapInternalExt
bool supportsThreadedOpenGL() const override
static QOpenGLStaticContext * create(bool softwareRendering=false)
const QByteArray extensionNames
static QWindowsOpengl32DLL opengl32
A temporary context that can be instantiated on the stack.
~QOpenGLTemporaryContext()
Singleton container for all relevant information.
bool isValid() const override
HGLRC nativeContext() const override
void doneCurrent() override
QWindowsGLContext(QOpenGLStaticContext *staticContext, HGLRC context, HWND window)
QFunctionPointer getProcAddress(const char *procName) override
Reimplement in subclass to allow dynamic querying of OpenGL symbols.
bool makeCurrent(QPlatformSurface *surface) override
QWindowsGLContext(QOpenGLStaticContext *staticContext, QOpenGLContext *context)
QSurfaceFormat format() const override
void swapBuffers(QPlatformSurface *surface) override
Reimplement in subclass to native swap buffers calls.
bool isSharing() const override
HGLRC renderingContext() const
~QWindowsGLContext() override
@ OpenGlPixelFormatInitialized
static HGLRC createContext(const QOpenGLStaticContext &staticContext, HDC hdc, const QSurfaceFormat &format, const QWindowsOpenGLAdditionalFormat &, HGLRC shared=nullptr)
static int choosePixelFormat(HDC hdc, const QOpenGLStaticContext &staticContext, const QSurfaceFormat &format, const QWindowsOpenGLAdditionalFormat &additional, PIXELFORMATDESCRIPTOR *obtainedPfd)
static QSurfaceFormat qSurfaceFormatFromHDC(const QOpenGLStaticContext &staticContext, HDC hdc, int pixelFormat, QWindowsOpenGLAdditionalFormat *additionalIn=nullptr)
static PIXELFORMATDESCRIPTOR qPixelFormatFromSurfaceFormat(const QSurfaceFormat &format, const QWindowsOpenGLAdditionalFormat &additional)
static QSurfaceFormat qSurfaceFormatFromPixelFormat(const PIXELFORMATDESCRIPTOR &pfd, QWindowsOpenGLAdditionalFormat *additionalIn=nullptr)
static HGLRC createContext(HDC hdc, HGLRC shared)
static int choosePixelFormat(HDC hdc, const QSurfaceFormat &format, const QWindowsOpenGLAdditionalFormat &additional, PIXELFORMATDESCRIPTOR *obtainedPfd)
#define GL_CONTEXT_PROFILE_MASK
#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT
#define GL_CONTEXT_CORE_PROFILE_BIT
#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT
#define GL_CONTEXT_FLAG_DEBUG_BIT
#define GL_NUM_EXTENSIONS
#define WGL_CONTEXT_MINOR_VERSION_ARB
#define WGL_STENCIL_BITS_ARB
#define WGL_ACCELERATION_ARB
static const QOpenGLContextData * findByHWND(const std::vector< QOpenGLContextData > &data, HWND hwnd)
static bool isDirectRendering(const PIXELFORMATDESCRIPTOR &pfd)
#define WGL_BLUE_BITS_ARB
#define RESET_NOTIFICATION_STRATEGY_ARB
static QOpenGLContextData currentOpenGLContextData()
#define WGL_GREEN_BITS_ARB
static bool hasGLOverlay(const PIXELFORMATDESCRIPTOR &pd)
#define WGL_ALPHA_BITS_ARB
#define WGL_CONTEXT_MAJOR_VERSION_ARB
#define WGL_CONTEXT_PROFILE_MASK_ARB
#define WGL_NO_ACCELERATION_ARB
#define WGL_PIXEL_TYPE_ARB
#define WGL_DEPTH_BITS_ARB
#define ROBUSTNESS_EXTENSION
static bool isAcceptableFormat(const QWindowsOpenGLAdditionalFormat &additional, const PIXELFORMATDESCRIPTOR &pfd, bool ignoreGLSupport=false)
#define WGL_NUMBER_OVERLAYS_ARB
#define WGL_CONTEXT_DEBUG_BIT_ARB
#define WGL_DOUBLE_BUFFER_ARB
static HGLRC createDummyGLContext(HDC dc)
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB
static void initPixelFormatDescriptor(PIXELFORMATDESCRIPTOR *d)
static QOpenGLContextData createDummyWindowOpenGLContextData()
#define WGL_DRAW_TO_WINDOW_ARB
static HWND handleOf(QPlatformSurface *s)
#define WGL_TYPE_RGBA_ARB
#define LOSE_CONTEXT_ON_RESET_ARB
#define WGL_CONTEXT_FLAGS_ARB
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB
static void describeFormats(HDC hdc)
#define SAMPLE_BUFFER_EXTENSION
bool testFlag(MaskType mask, FlagType flag)
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB
#define WGL_FULL_ACCELERATION_ARB
#define WGL_SAMPLE_BUFFERS_ARB
static QWindowsWindow * glWindowOf(QPlatformSurface *s)
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT
#define WGL_ACCUM_BITS_ARB
static HWND createDummyGLWindow()
#define WGL_COLOR_BITS_ARB
#define WGL_SUPPORT_OPENGL_ARB
@ QWindowsGLDirectRendering
@ QWindowsGLRenderToPixmap
QOpenGLContextData(HGLRC r, HWND h, HDC d)
QSurfaceFormat::FormatOptions options
majorVersion<<8 + minorVersion
QSurfaceFormat::OpenGLContextProfile profile
static QWindowsOpenGLContextFormat current()
void apply(QSurfaceFormat *format) const
bool init(bool softwareRendering)
int describePixelFormat(HDC dc, int pf, UINT size, PIXELFORMATDESCRIPTOR *pfd)
BOOL(WINAPI *wglDeleteContext)(HGLRC context)
GLenum(APIENTRY *glGetError)()
PROC(WINAPI *wglGetProcAddress)(LPCSTR name)
HGLRC(WINAPI *wglCreateContext)(HDC dc)
void(APIENTRY *glGetIntegerv)(GLenum pname
QFunctionPointer resolve(const char *name)
void * moduleHandle() const
const GLubyte *APIENTRY * glGetString(GLenum name)
HDC(WINAPI *wglGetCurrentDC)()
bool moduleIsNotOpengl32() const
BOOL setPixelFormat(HDC dc, int pf, const PIXELFORMATDESCRIPTOR *pfd)