Qt 4.8
Classes | Macros | Typedefs | Functions | Variables
qgl_win.cpp File Reference
#include <qgl.h>
#include <qlist.h>
#include <qmap.h>
#include <qpixmap.h>
#include <qevent.h>
#include <private/qgl_p.h>
#include <qcolormap.h>
#include <qvarlengtharray.h>
#include <qdebug.h>
#include <qcolor.h>
#include <qt_windows.h>

Go to the source code of this file.

Classes

class  QGLCmap
 
class  QGLCmapPrivate
 
class  QGLTemporaryContextPrivate
 

Macros

#define ERROR_INVALID_PROFILE_ARB   0x2096
 
#define ERROR_INVALID_VERSION_ARB   0x2095
 
#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT   0x0001
 
#define GL_CONTEXT_FLAGS   0x821E
 
#define GL_CONTEXT_PROFILE_MASK   0x9126
 
#define GL_MAJOR_VERSION   0x821B
 
#define GL_MINOR_VERSION   0x821C
 
#define GL_NUM_EXTENSIONS   0x821D
 
#define WGL_ACCELERATION_ARB   0x2003
 
#define WGL_ACCUM_ALPHA_BITS_ARB   0x2021
 
#define WGL_ACCUM_BITS_ARB   0x201D
 
#define WGL_ACCUM_BLUE_BITS_ARB   0x2020
 
#define WGL_ACCUM_GREEN_BITS_ARB   0x201F
 
#define WGL_ACCUM_RED_BITS_ARB   0x201E
 
#define WGL_ALPHA_BITS_ARB   0x201B
 
#define WGL_ALPHA_SHIFT_ARB   0x201C
 
#define WGL_AUX_BUFFERS_ARB   0x2024
 
#define WGL_BLUE_BITS_ARB   0x2019
 
#define WGL_BLUE_SHIFT_ARB   0x201A
 
#define WGL_COLOR_BITS_ARB   0x2014
 
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB   0x0002
 
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB   0x0001
 
#define WGL_CONTEXT_DEBUG_BIT_ARB   0x0001
 
#define WGL_CONTEXT_FLAGS_ARB   0x2094
 
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB   0x0002
 
#define WGL_CONTEXT_LAYER_PLANE_ARB   0x2093
 
#define WGL_CONTEXT_MAJOR_VERSION_ARB   0x2091
 
#define WGL_CONTEXT_MINOR_VERSION_ARB   0x2092
 
#define WGL_CONTEXT_PROFILE_MASK_ARB   0x9126
 
#define WGL_DEPTH_BITS_ARB   0x2022
 
#define WGL_DOUBLE_BUFFER_ARB   0x2011
 
#define WGL_DRAW_TO_BITMAP_ARB   0x2002
 
#define WGL_DRAW_TO_WINDOW_ARB   0x2001
 
#define WGL_FULL_ACCELERATION_ARB   0x2027
 
#define WGL_GENERIC_ACCELERATION_ARB   0x2026
 
#define WGL_GREEN_BITS_ARB   0x2017
 
#define WGL_GREEN_SHIFT_ARB   0x2018
 
#define WGL_NEED_PALETTE_ARB   0x2004
 
#define WGL_NEED_SYSTEM_PALETTE_ARB   0x2005
 
#define WGL_NO_ACCELERATION_ARB   0x2025
 
#define WGL_NUMBER_OVERLAYS_ARB   0x2008
 
#define WGL_NUMBER_PIXEL_FORMATS_ARB   0x2000
 
#define WGL_NUMBER_UNDERLAYS_ARB   0x2009
 
#define WGL_PIXEL_TYPE_ARB   0x2013
 
#define WGL_RED_BITS_ARB   0x2015
 
#define WGL_RED_SHIFT_ARB   0x2016
 
#define WGL_SAMPLE_BUFFERS_ARB   0x2041
 
#define WGL_SAMPLES_ARB   0x2042
 
#define WGL_SHARE_ACCUM_ARB   0x200E
 
#define WGL_SHARE_DEPTH_ARB   0x200C
 
#define WGL_SHARE_STENCIL_ARB   0x200D
 
#define WGL_STENCIL_BITS_ARB   0x2023
 
#define WGL_STEREO_ARB   0x2012
 
#define WGL_SUPPORT_GDI_ARB   0x200F
 
#define WGL_SUPPORT_OPENGL_ARB   0x2010
 
#define WGL_SWAP_COPY_ARB   0x2029
 
#define WGL_SWAP_EXCHANGE_ARB   0x2028
 
#define WGL_SWAP_LAYER_BUFFERS_ARB   0x2006
 
#define WGL_SWAP_METHOD_ARB   0x2007
 
#define WGL_SWAP_UNDEFINED_ARB   0x202A
 
#define WGL_TRANSPARENT_ALPHA_VALUE_ARB   0x203A
 
#define WGL_TRANSPARENT_ARB   0x200A
 
#define WGL_TRANSPARENT_BLUE_VALUE_ARB   0x2039
 
#define WGL_TRANSPARENT_GREEN_VALUE_ARB   0x2038
 
#define WGL_TRANSPARENT_INDEX_VALUE_ARB   0x203B
 
#define WGL_TRANSPARENT_RED_VALUE_ARB   0x2037
 
#define WGL_TYPE_COLORINDEX_ARB   0x202C
 
#define WGL_TYPE_RGBA_ARB   0x202B
 

Typedefs

typedef bool(APIENTRYPFNWGLCHOOSEPIXELFORMATARB) (HDC hdc, const int *piAttribList, const float *pfAttribFList, uint nMaxFormats, int *piFormats, UINT *nNumFormats)
 
typedef bool(APIENTRYPFNWGLGETPIXELFORMATATTRIBIVARB) (HDC hdc, int iPixelFormat, int iLayerPlane, uint nAttributes, const int *piAttributes, int *piValues)
 

Functions

static QGLFormat pfdToQGLFormat (const PIXELFORMATDESCRIPTOR *pfd)
 
QGLFormat pfiToQGLFormat (HDC hdc, int pfi)
 
static bool qgl_create_context (HDC hdc, QGLContextPrivate *d, QGLContextPrivate *shareContext)
 
static QRgbqgl_create_rgb_palette (const PIXELFORMATDESCRIPTOR *pfd)
 
static uchar qgl_rgb_palette_comp (int idx, uint nbits, uint shift)
 
static bool qLogEq (bool a, bool b)
 
static void qStoreColors (HPALETTE cmap, const QGLColormap &cols)
 
Q_GUI_EXPORT const QString qt_getRegisteredWndClass ()
 
void qwglError (const char *method, const char *func)
 

Variables

static bool opengl32dll = false
 

Macro Definition Documentation

◆ ERROR_INVALID_PROFILE_ARB

#define ERROR_INVALID_PROFILE_ARB   0x2096

Definition at line 137 of file qgl_win.cpp.

◆ ERROR_INVALID_VERSION_ARB

#define ERROR_INVALID_VERSION_ARB   0x2095

Definition at line 136 of file qgl_win.cpp.

◆ GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT

#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT   0x0001

Definition at line 146 of file qgl_win.cpp.

Referenced by QGLContextPrivate::updateFormatVersion().

◆ GL_CONTEXT_FLAGS

#define GL_CONTEXT_FLAGS   0x821E

Definition at line 145 of file qgl_win.cpp.

Referenced by QGLContextPrivate::updateFormatVersion().

◆ GL_CONTEXT_PROFILE_MASK

#define GL_CONTEXT_PROFILE_MASK   0x9126

Definition at line 141 of file qgl_win.cpp.

Referenced by QGLContextPrivate::updateFormatVersion().

◆ GL_MAJOR_VERSION

#define GL_MAJOR_VERSION   0x821B

Definition at line 142 of file qgl_win.cpp.

◆ GL_MINOR_VERSION

#define GL_MINOR_VERSION   0x821C

Definition at line 143 of file qgl_win.cpp.

◆ GL_NUM_EXTENSIONS

#define GL_NUM_EXTENSIONS   0x821D

Definition at line 144 of file qgl_win.cpp.

◆ WGL_ACCELERATION_ARB

#define WGL_ACCELERATION_ARB   0x2003

Definition at line 77 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat(), and pfiToQGLFormat().

◆ WGL_ACCUM_ALPHA_BITS_ARB

#define WGL_ACCUM_ALPHA_BITS_ARB   0x2021

Definition at line 111 of file qgl_win.cpp.

◆ WGL_ACCUM_BITS_ARB

#define WGL_ACCUM_BITS_ARB   0x201D

Definition at line 107 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat(), and pfiToQGLFormat().

◆ WGL_ACCUM_BLUE_BITS_ARB

#define WGL_ACCUM_BLUE_BITS_ARB   0x2020

Definition at line 110 of file qgl_win.cpp.

◆ WGL_ACCUM_GREEN_BITS_ARB

#define WGL_ACCUM_GREEN_BITS_ARB   0x201F

Definition at line 109 of file qgl_win.cpp.

◆ WGL_ACCUM_RED_BITS_ARB

#define WGL_ACCUM_RED_BITS_ARB   0x201E

Definition at line 108 of file qgl_win.cpp.

◆ WGL_ALPHA_BITS_ARB

#define WGL_ALPHA_BITS_ARB   0x201B

Definition at line 105 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat(), and pfiToQGLFormat().

◆ WGL_ALPHA_SHIFT_ARB

#define WGL_ALPHA_SHIFT_ARB   0x201C

Definition at line 106 of file qgl_win.cpp.

◆ WGL_AUX_BUFFERS_ARB

#define WGL_AUX_BUFFERS_ARB   0x2024

Definition at line 114 of file qgl_win.cpp.

◆ WGL_BLUE_BITS_ARB

#define WGL_BLUE_BITS_ARB   0x2019

Definition at line 103 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat(), and pfiToQGLFormat().

◆ WGL_BLUE_SHIFT_ARB

#define WGL_BLUE_SHIFT_ARB   0x201A

Definition at line 104 of file qgl_win.cpp.

◆ WGL_COLOR_BITS_ARB

#define WGL_COLOR_BITS_ARB   0x2014

Definition at line 98 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat().

◆ WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB

#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB   0x0002

Definition at line 134 of file qgl_win.cpp.

Referenced by qgl_create_context(), and QGLContextPrivate::updateFormatVersion().

◆ WGL_CONTEXT_CORE_PROFILE_BIT_ARB

#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB   0x0001

Definition at line 133 of file qgl_win.cpp.

Referenced by qgl_create_context(), and QGLContextPrivate::updateFormatVersion().

◆ WGL_CONTEXT_DEBUG_BIT_ARB

#define WGL_CONTEXT_DEBUG_BIT_ARB   0x0001

Definition at line 131 of file qgl_win.cpp.

◆ WGL_CONTEXT_FLAGS_ARB

#define WGL_CONTEXT_FLAGS_ARB   0x2094

Definition at line 129 of file qgl_win.cpp.

Referenced by qgl_create_context().

◆ WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB

#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB   0x0002

Definition at line 132 of file qgl_win.cpp.

Referenced by qgl_create_context().

◆ WGL_CONTEXT_LAYER_PLANE_ARB

#define WGL_CONTEXT_LAYER_PLANE_ARB   0x2093

Definition at line 128 of file qgl_win.cpp.

Referenced by qgl_create_context().

◆ WGL_CONTEXT_MAJOR_VERSION_ARB

#define WGL_CONTEXT_MAJOR_VERSION_ARB   0x2091

Definition at line 126 of file qgl_win.cpp.

Referenced by qgl_create_context().

◆ WGL_CONTEXT_MINOR_VERSION_ARB

#define WGL_CONTEXT_MINOR_VERSION_ARB   0x2092

Definition at line 127 of file qgl_win.cpp.

Referenced by qgl_create_context().

◆ WGL_CONTEXT_PROFILE_MASK_ARB

#define WGL_CONTEXT_PROFILE_MASK_ARB   0x9126

Definition at line 130 of file qgl_win.cpp.

Referenced by qgl_create_context().

◆ WGL_DEPTH_BITS_ARB

#define WGL_DEPTH_BITS_ARB   0x2022

Definition at line 112 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat(), and pfiToQGLFormat().

◆ WGL_DOUBLE_BUFFER_ARB

#define WGL_DOUBLE_BUFFER_ARB   0x2011

Definition at line 95 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat(), and pfiToQGLFormat().

◆ WGL_DRAW_TO_BITMAP_ARB

#define WGL_DRAW_TO_BITMAP_ARB   0x2002

Definition at line 76 of file qgl_win.cpp.

◆ WGL_DRAW_TO_WINDOW_ARB

#define WGL_DRAW_TO_WINDOW_ARB   0x2001

Definition at line 75 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat().

◆ WGL_FULL_ACCELERATION_ARB

#define WGL_FULL_ACCELERATION_ARB   0x2027

Definition at line 117 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat(), and pfiToQGLFormat().

◆ WGL_GENERIC_ACCELERATION_ARB

#define WGL_GENERIC_ACCELERATION_ARB   0x2026

Definition at line 116 of file qgl_win.cpp.

◆ WGL_GREEN_BITS_ARB

#define WGL_GREEN_BITS_ARB   0x2017

Definition at line 101 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat(), and pfiToQGLFormat().

◆ WGL_GREEN_SHIFT_ARB

#define WGL_GREEN_SHIFT_ARB   0x2018

Definition at line 102 of file qgl_win.cpp.

◆ WGL_NEED_PALETTE_ARB

#define WGL_NEED_PALETTE_ARB   0x2004

Definition at line 78 of file qgl_win.cpp.

◆ WGL_NEED_SYSTEM_PALETTE_ARB

#define WGL_NEED_SYSTEM_PALETTE_ARB   0x2005

Definition at line 79 of file qgl_win.cpp.

◆ WGL_NO_ACCELERATION_ARB

#define WGL_NO_ACCELERATION_ARB   0x2025

Definition at line 115 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat().

◆ WGL_NUMBER_OVERLAYS_ARB

#define WGL_NUMBER_OVERLAYS_ARB   0x2008

Definition at line 82 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat(), and pfiToQGLFormat().

◆ WGL_NUMBER_PIXEL_FORMATS_ARB

#define WGL_NUMBER_PIXEL_FORMATS_ARB   0x2000

Definition at line 74 of file qgl_win.cpp.

◆ WGL_NUMBER_UNDERLAYS_ARB

#define WGL_NUMBER_UNDERLAYS_ARB   0x2009

Definition at line 83 of file qgl_win.cpp.

◆ WGL_PIXEL_TYPE_ARB

#define WGL_PIXEL_TYPE_ARB   0x2013

Definition at line 97 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat(), and pfiToQGLFormat().

◆ WGL_RED_BITS_ARB

#define WGL_RED_BITS_ARB   0x2015

Definition at line 99 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat(), and pfiToQGLFormat().

◆ WGL_RED_SHIFT_ARB

#define WGL_RED_SHIFT_ARB   0x2016

Definition at line 100 of file qgl_win.cpp.

◆ WGL_SAMPLE_BUFFERS_ARB

#define WGL_SAMPLE_BUFFERS_ARB   0x2041

Definition at line 69 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat(), and pfiToQGLFormat().

◆ WGL_SAMPLES_ARB

#define WGL_SAMPLES_ARB   0x2042

Definition at line 70 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat(), and pfiToQGLFormat().

◆ WGL_SHARE_ACCUM_ARB

#define WGL_SHARE_ACCUM_ARB   0x200E

Definition at line 92 of file qgl_win.cpp.

◆ WGL_SHARE_DEPTH_ARB

#define WGL_SHARE_DEPTH_ARB   0x200C

Definition at line 90 of file qgl_win.cpp.

◆ WGL_SHARE_STENCIL_ARB

#define WGL_SHARE_STENCIL_ARB   0x200D

Definition at line 91 of file qgl_win.cpp.

◆ WGL_STENCIL_BITS_ARB

#define WGL_STENCIL_BITS_ARB   0x2023

Definition at line 113 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat(), and pfiToQGLFormat().

◆ WGL_STEREO_ARB

#define WGL_STEREO_ARB   0x2012

Definition at line 96 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat(), and pfiToQGLFormat().

◆ WGL_SUPPORT_GDI_ARB

#define WGL_SUPPORT_GDI_ARB   0x200F

Definition at line 93 of file qgl_win.cpp.

◆ WGL_SUPPORT_OPENGL_ARB

#define WGL_SUPPORT_OPENGL_ARB   0x2010

Definition at line 94 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat().

◆ WGL_SWAP_COPY_ARB

#define WGL_SWAP_COPY_ARB   0x2029

Definition at line 119 of file qgl_win.cpp.

◆ WGL_SWAP_EXCHANGE_ARB

#define WGL_SWAP_EXCHANGE_ARB   0x2028

Definition at line 118 of file qgl_win.cpp.

◆ WGL_SWAP_LAYER_BUFFERS_ARB

#define WGL_SWAP_LAYER_BUFFERS_ARB   0x2006

Definition at line 80 of file qgl_win.cpp.

◆ WGL_SWAP_METHOD_ARB

#define WGL_SWAP_METHOD_ARB   0x2007

Definition at line 81 of file qgl_win.cpp.

◆ WGL_SWAP_UNDEFINED_ARB

#define WGL_SWAP_UNDEFINED_ARB   0x202A

Definition at line 120 of file qgl_win.cpp.

◆ WGL_TRANSPARENT_ALPHA_VALUE_ARB

#define WGL_TRANSPARENT_ALPHA_VALUE_ARB   0x203A

Definition at line 88 of file qgl_win.cpp.

◆ WGL_TRANSPARENT_ARB

#define WGL_TRANSPARENT_ARB   0x200A

Definition at line 84 of file qgl_win.cpp.

◆ WGL_TRANSPARENT_BLUE_VALUE_ARB

#define WGL_TRANSPARENT_BLUE_VALUE_ARB   0x2039

Definition at line 87 of file qgl_win.cpp.

◆ WGL_TRANSPARENT_GREEN_VALUE_ARB

#define WGL_TRANSPARENT_GREEN_VALUE_ARB   0x2038

Definition at line 86 of file qgl_win.cpp.

◆ WGL_TRANSPARENT_INDEX_VALUE_ARB

#define WGL_TRANSPARENT_INDEX_VALUE_ARB   0x203B

Definition at line 89 of file qgl_win.cpp.

◆ WGL_TRANSPARENT_RED_VALUE_ARB

#define WGL_TRANSPARENT_RED_VALUE_ARB   0x2037

Definition at line 85 of file qgl_win.cpp.

◆ WGL_TYPE_COLORINDEX_ARB

#define WGL_TYPE_COLORINDEX_ARB   0x202C

Definition at line 122 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat().

◆ WGL_TYPE_RGBA_ARB

#define WGL_TYPE_RGBA_ARB   0x202B

Definition at line 121 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat(), and pfiToQGLFormat().

Typedef Documentation

◆ PFNWGLCHOOSEPIXELFORMATARB

typedef bool(APIENTRY * PFNWGLCHOOSEPIXELFORMATARB) (HDC hdc, const int *piAttribList, const float *pfAttribFList, uint nMaxFormats, int *piFormats, UINT *nNumFormats)

Definition at line 62 of file qgl_win.cpp.

◆ PFNWGLGETPIXELFORMATATTRIBIVARB

typedef bool(APIENTRY * PFNWGLGETPIXELFORMATATTRIBIVARB) (HDC hdc, int iPixelFormat, int iLayerPlane, uint nAttributes, const int *piAttributes, int *piValues)

Definition at line 56 of file qgl_win.cpp.

Function Documentation

◆ pfdToQGLFormat()

static QGLFormat pfdToQGLFormat ( const PIXELFORMATDESCRIPTOR *  pfd)
static

Definition at line 542 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat(), and QGLContextPrivate::updateFormatVersion().

543 {
544  QGLFormat fmt;
545  fmt.setDoubleBuffer(pfd->dwFlags & PFD_DOUBLEBUFFER);
546  fmt.setDepth(pfd->cDepthBits);
547  if (fmt.depth())
548  fmt.setDepthBufferSize(pfd->cDepthBits);
549  fmt.setRgba(pfd->iPixelType == PFD_TYPE_RGBA);
550  fmt.setRedBufferSize(pfd->cRedBits);
551  fmt.setGreenBufferSize(pfd->cGreenBits);
552  fmt.setBlueBufferSize(pfd->cBlueBits);
553  fmt.setAlpha(pfd->cAlphaBits);
554  if (fmt.alpha())
555  fmt.setAlphaBufferSize(pfd->cAlphaBits);
556  fmt.setAccum(pfd->cAccumBits);
557  if (fmt.accum())
558  fmt.setAccumBufferSize(pfd->cAccumRedBits);
559  fmt.setStencil(pfd->cStencilBits);
560  if (fmt.stencil())
561  fmt.setStencilBufferSize(pfd->cStencilBits);
562  fmt.setStereo(pfd->dwFlags & PFD_STEREO);
563  fmt.setDirectRendering((pfd->dwFlags & PFD_GENERIC_ACCELERATED) ||
564  !(pfd->dwFlags & PFD_GENERIC_FORMAT));
565  fmt.setOverlay((pfd->bReserved & 0x0f) != 0);
566  return fmt;
567 }
void setStencil(bool enable)
If enable is true enables the stencil buffer; otherwise disables the stencil buffer.
Definition: qgl.cpp:724
void setAccumBufferSize(int size)
Set the preferred accumulation buffer size, where size is the bit depth for each RGBA component...
Definition: qgl.cpp:1143
void setRedBufferSize(int size)
Set the preferred red buffer size to size.
Definition: qgl.cpp:1015
void setOverlay(bool enable)
If enable is true enables an overlay plane; otherwise disables the overlay plane. ...
Definition: qgl.cpp:912
void setAlpha(bool enable)
If enable is true enables the alpha buffer; otherwise disables the alpha buffer.
Definition: qgl.cpp:664
void setDirectRendering(bool enable)
If enable is true enables direct rendering; otherwise disables direct rendering.
Definition: qgl.cpp:787
void setAlphaBufferSize(int size)
Set the preferred alpha buffer size to size.
Definition: qgl.cpp:1116
bool depth() const
Returns true if the depth buffer is enabled; otherwise returns false.
Definition: qgl.h:618
The QGLFormat class specifies the display format of an OpenGL rendering context.
Definition: qgl.h:175
void setDepthBufferSize(int size)
Set the minimum depth buffer size to size.
Definition: qgl.cpp:984
bool stencil() const
Returns true if the stencil buffer is enabled; otherwise returns false.
Definition: qgl.h:638
void setDoubleBuffer(bool enable)
If enable is true sets double buffering; otherwise sets single buffering.
Definition: qgl.cpp:566
void setGreenBufferSize(int size)
Set the preferred green buffer size to size.
Definition: qgl.cpp:1050
bool accum() const
Returns true if the accumulation buffer is enabled; otherwise returns false.
Definition: qgl.h:633
void setDepth(bool enable)
If enable is true enables the depth buffer; otherwise disables the depth buffer.
Definition: qgl.cpp:599
void setRgba(bool enable)
If enable is true sets RGBA mode.
Definition: qgl.cpp:633
bool alpha() const
Returns true if the alpha buffer in the framebuffer is enabled; otherwise returns false...
Definition: qgl.h:628
void setStereo(bool enable)
If enable is true enables stereo buffering; otherwise disables stereo buffering.
Definition: qgl.cpp:754
void setBlueBufferSize(int size)
Set the preferred blue buffer size to size.
Definition: qgl.cpp:1085
void setStencilBufferSize(int size)
Set the preferred stencil buffer size to size.
Definition: qgl.cpp:1169
void setAccum(bool enable)
If enable is true enables the accumulation buffer; otherwise disables the accumulation buffer...
Definition: qgl.cpp:694

◆ pfiToQGLFormat()

QGLFormat pfiToQGLFormat ( HDC  hdc,
int  pfi 
)

Definition at line 572 of file qgl_win.cpp.

Referenced by qt_format_to_attrib_list(), and QGLContextPrivate::updateFormatVersion().

573 {
574  QGLFormat fmt;
575  QVarLengthArray<int> iAttributes(40);
576  QVarLengthArray<int> iValues(40);
577  int i = 0;
578  bool has_sample_buffers = QGLExtensions::glExtensions() & QGLExtensions::SampleBuffers;
579 
580  iAttributes[i++] = WGL_DOUBLE_BUFFER_ARB; // 0
581  iAttributes[i++] = WGL_DEPTH_BITS_ARB; // 1
582  iAttributes[i++] = WGL_PIXEL_TYPE_ARB; // 2
583  iAttributes[i++] = WGL_RED_BITS_ARB; // 3
584  iAttributes[i++] = WGL_GREEN_BITS_ARB; // 4
585  iAttributes[i++] = WGL_BLUE_BITS_ARB; // 5
586  iAttributes[i++] = WGL_ALPHA_BITS_ARB; // 6
587  iAttributes[i++] = WGL_ACCUM_BITS_ARB; // 7
588  iAttributes[i++] = WGL_STENCIL_BITS_ARB; // 8
589  iAttributes[i++] = WGL_STEREO_ARB; // 9
590  iAttributes[i++] = WGL_ACCELERATION_ARB; // 10
591  iAttributes[i++] = WGL_NUMBER_OVERLAYS_ARB; // 11
592  if (has_sample_buffers) {
593  iAttributes[i++] = WGL_SAMPLE_BUFFERS_ARB; // 12
594  iAttributes[i++] = WGL_SAMPLES_ARB; // 13
595  }
596  PFNWGLGETPIXELFORMATATTRIBIVARB wglGetPixelFormatAttribivARB =
597  (PFNWGLGETPIXELFORMATATTRIBIVARB) wglGetProcAddress("wglGetPixelFormatAttribivARB");
598 
599  if (wglGetPixelFormatAttribivARB
600  && wglGetPixelFormatAttribivARB(hdc, pfi, 0, i,
601  iAttributes.constData(),
602  iValues.data()))
603  {
604  fmt.setDoubleBuffer(iValues[0]);
605  fmt.setDepth(iValues[1]);
606  if (fmt.depth())
607  fmt.setDepthBufferSize(iValues[1]);
608  fmt.setRgba(iValues[2] == WGL_TYPE_RGBA_ARB);
609  fmt.setRedBufferSize(iValues[3]);
610  fmt.setGreenBufferSize(iValues[4]);
611  fmt.setBlueBufferSize(iValues[5]);
612  fmt.setAlpha(iValues[6]);
613  if (fmt.alpha())
614  fmt.setAlphaBufferSize(iValues[6]);
615  fmt.setAccum(iValues[7]);
616  if (fmt.accum())
617  fmt.setAccumBufferSize(iValues[7]);
618  fmt.setStencil(iValues[8]);
619  if (fmt.stencil())
620  fmt.setStencilBufferSize(iValues[8]);
621  fmt.setStereo(iValues[9]);
622  if (iValues[10] == WGL_FULL_ACCELERATION_ARB)
623  fmt.setDirectRendering(true);
624  else
625  fmt.setDirectRendering(false);
626  fmt.setOverlay(iValues[11]);
627  if (has_sample_buffers) {
628  fmt.setSampleBuffers(iValues[12]);
629  if (fmt.sampleBuffers())
630  fmt.setSamples(iValues[13]);
631  }
632  }
633 #if 0
634  qDebug() << "values for pfi:" << pfi;
635  qDebug() << "doublebuffer 0:" << fmt.doubleBuffer();
636  qDebug() << "depthbuffer 1:" << fmt.depthBufferSize();
637  qDebug() << "rgba 2:" << fmt.rgba();
638  qDebug() << "red size 3:" << fmt.redBufferSize();
639  qDebug() << "green size 4:" << fmt.greenBufferSize();
640  qDebug() << "blue size 5:" << fmt.blueBufferSize();
641  qDebug() << "alpha size 6:" << fmt.alphaBufferSize();
642  qDebug() << "accum size 7:" << fmt.accumBufferSize();
643  qDebug() << "stencil size 8:" << fmt.stencilBufferSize();
644  qDebug() << "stereo 9:" << fmt.stereo();
645  qDebug() << "direct 10:" << fmt.directRendering();
646  qDebug() << "has overlays 11:" << fmt.hasOverlay();
647  qDebug() << "sample buff 12:" << fmt.sampleBuffers();
648  qDebug() << "num samples 13:" << fmt.samples();
649 #endif
650  return fmt;
651 }
void setSamples(int numSamples)
Set the preferred number of samples per pixel when multisampling is enabled to numSamples.
Definition: qgl.cpp:836
void setStencil(bool enable)
If enable is true enables the stencil buffer; otherwise disables the stencil buffer.
Definition: qgl.cpp:724
bool rgba() const
Returns true if RGBA color mode is set.
Definition: qgl.h:623
void setAccumBufferSize(int size)
Set the preferred accumulation buffer size, where size is the bit depth for each RGBA component...
Definition: qgl.cpp:1143
int greenBufferSize() const
Returns the green buffer size.
Definition: qgl.cpp:1070
void setRedBufferSize(int size)
Set the preferred red buffer size to size.
Definition: qgl.cpp:1015
#define WGL_RED_BITS_ARB
Definition: qgl_win.cpp:99
#define WGL_TYPE_RGBA_ARB
Definition: qgl_win.cpp:121
void setOverlay(bool enable)
If enable is true enables an overlay plane; otherwise disables the overlay plane. ...
Definition: qgl.cpp:912
void setAlpha(bool enable)
If enable is true enables the alpha buffer; otherwise disables the alpha buffer.
Definition: qgl.cpp:664
void setSampleBuffers(bool enable)
If enable is true, a GL context with multisample buffer support is picked; otherwise ignored...
Definition: qgl.cpp:812
int redBufferSize() const
Returns the red buffer size.
Definition: qgl.cpp:1035
bool directRendering() const
Returns true if direct rendering is enabled; otherwise returns false.
Definition: qgl.h:648
void setDirectRendering(bool enable)
If enable is true enables direct rendering; otherwise disables direct rendering.
Definition: qgl.cpp:787
Q_CORE_EXPORT void qDebug(const char *,...)
bool sampleBuffers() const
Returns true if multisample buffer support is enabled; otherwise returns false.
Definition: qgl.h:658
#define WGL_GREEN_BITS_ARB
Definition: qgl_win.cpp:101
void setAlphaBufferSize(int size)
Set the preferred alpha buffer size to size.
Definition: qgl.cpp:1116
int alphaBufferSize() const
Returns the alpha buffer size.
Definition: qgl.cpp:1132
bool depth() const
Returns true if the depth buffer is enabled; otherwise returns false.
Definition: qgl.h:618
int accumBufferSize() const
Returns the accumulation buffer size.
Definition: qgl.cpp:1159
The QGLFormat class specifies the display format of an OpenGL rendering context.
Definition: qgl.h:175
int depthBufferSize() const
Returns the depth buffer size.
Definition: qgl.cpp:1000
void setDepthBufferSize(int size)
Set the minimum depth buffer size to size.
Definition: qgl.cpp:984
#define WGL_SAMPLE_BUFFERS_ARB
Definition: qgl_win.cpp:69
bool stencil() const
Returns true if the stencil buffer is enabled; otherwise returns false.
Definition: qgl.h:638
void setDoubleBuffer(bool enable)
If enable is true sets double buffering; otherwise sets single buffering.
Definition: qgl.cpp:566
void setGreenBufferSize(int size)
Set the preferred green buffer size to size.
Definition: qgl.cpp:1050
bool accum() const
Returns true if the accumulation buffer is enabled; otherwise returns false.
Definition: qgl.h:633
void setDepth(bool enable)
If enable is true enables the depth buffer; otherwise disables the depth buffer.
Definition: qgl.cpp:599
#define WGL_BLUE_BITS_ARB
Definition: qgl_win.cpp:103
void setRgba(bool enable)
If enable is true sets RGBA mode.
Definition: qgl.cpp:633
bool hasOverlay() const
Returns true if overlay plane is enabled; otherwise returns false.
Definition: qgl.h:653
#define WGL_DEPTH_BITS_ARB
Definition: qgl_win.cpp:112
#define WGL_STEREO_ARB
Definition: qgl_win.cpp:96
#define WGL_SAMPLES_ARB
Definition: qgl_win.cpp:70
bool alpha() const
Returns true if the alpha buffer in the framebuffer is enabled; otherwise returns false...
Definition: qgl.h:628
#define WGL_ACCUM_BITS_ARB
Definition: qgl_win.cpp:107
int blueBufferSize() const
Returns the blue buffer size.
Definition: qgl.cpp:1105
bool doubleBuffer() const
Returns true if double buffering is enabled; otherwise returns false.
Definition: qgl.h:613
static Extensions glExtensions()
Definition: qgl.cpp:5781
#define WGL_DOUBLE_BUFFER_ARB
Definition: qgl_win.cpp:95
void setStereo(bool enable)
If enable is true enables stereo buffering; otherwise disables stereo buffering.
Definition: qgl.cpp:754
bool(APIENTRY * PFNWGLGETPIXELFORMATATTRIBIVARB)(HDC hdc, int iPixelFormat, int iLayerPlane, uint nAttributes, const int *piAttributes, int *piValues)
Definition: qgl_win.cpp:56
#define WGL_ACCELERATION_ARB
Definition: qgl_win.cpp:77
void setBlueBufferSize(int size)
Set the preferred blue buffer size to size.
Definition: qgl.cpp:1085
#define WGL_STENCIL_BITS_ARB
Definition: qgl_win.cpp:113
int stencilBufferSize() const
Returns the stencil buffer size.
Definition: qgl.cpp:1185
bool stereo() const
Returns true if stereo buffering is enabled; otherwise returns false.
Definition: qgl.h:643
void setStencilBufferSize(int size)
Set the preferred stencil buffer size to size.
Definition: qgl.cpp:1169
int samples() const
Returns the number of samples per pixel when multisampling is enabled.
Definition: qgl.cpp:824
#define WGL_PIXEL_TYPE_ARB
Definition: qgl_win.cpp:97
#define WGL_ALPHA_BITS_ARB
Definition: qgl_win.cpp:105
#define WGL_FULL_ACCELERATION_ARB
Definition: qgl_win.cpp:117
void setAccum(bool enable)
If enable is true enables the accumulation buffer; otherwise disables the accumulation buffer...
Definition: qgl.cpp:694
#define WGL_NUMBER_OVERLAYS_ARB
Definition: qgl_win.cpp:82

◆ qgl_create_context()

static bool qgl_create_context ( HDC  hdc,
QGLContextPrivate d,
QGLContextPrivate shareContext 
)
static

Definition at line 709 of file qgl_win.cpp.

Referenced by QGLContextPrivate::updateFormatVersion().

710 {
711  d->rc = 0;
712 
713  typedef HGLRC (APIENTRYP PFNWGLCREATECONTEXTATTRIBSARB)(HDC, HGLRC, const int *);
714  PFNWGLCREATECONTEXTATTRIBSARB wglCreateContextAttribsARB =
715  (PFNWGLCREATECONTEXTATTRIBSARB) wglGetProcAddress("wglCreateContextAttribsARB");
716  if (wglCreateContextAttribsARB) {
717  int attributes[11];
718  int attribIndex = 0;
719  const int major = d->reqFormat.majorVersion();
720  const int minor = d->reqFormat.minorVersion();
721  attributes[attribIndex++] = WGL_CONTEXT_MAJOR_VERSION_ARB;
722  attributes[attribIndex++] = major;
723  attributes[attribIndex++] = WGL_CONTEXT_MINOR_VERSION_ARB;
724  attributes[attribIndex++] = minor;
725 
726  if (major >= 3 && !d->reqFormat.testOption(QGL::DeprecatedFunctions)) {
727  attributes[attribIndex++] = WGL_CONTEXT_FLAGS_ARB;
728  attributes[attribIndex++] = WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
729  }
730 
731  if ((major == 3 && minor >= 2) || major > 3) {
732  switch (d->reqFormat.profile()) {
734  break;
736  attributes[attribIndex++] = WGL_CONTEXT_PROFILE_MASK_ARB;
737  attributes[attribIndex++] = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
738  break;
740  attributes[attribIndex++] = WGL_CONTEXT_PROFILE_MASK_ARB;
741  attributes[attribIndex++] = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
742  break;
743  default:
744  qWarning("QGLContext::chooseContext(): Context profile not supported.");
745  return false;
746  }
747  }
748 
749  if (d->reqFormat.plane() != 0) {
750  attributes[attribIndex++] = WGL_CONTEXT_LAYER_PLANE_ARB;
751  attributes[attribIndex++] = d->reqFormat.plane();
752  }
753 
754  attributes[attribIndex++] = 0; // Terminate list.
755  d->rc = wglCreateContextAttribsARB(hdc, shareContext && shareContext->valid
756  ? shareContext->rc : 0, attributes);
757  if (d->rc) {
758  if (shareContext)
759  shareContext->sharing = d->sharing = true;
760  return true;
761  }
762  }
763 
764  d->rc = wglCreateLayerContext(hdc, d->reqFormat.plane());
765  if (d->rc && shareContext && shareContext->valid)
766  shareContext->sharing = d->sharing = wglShareLists(shareContext->rc, d->rc);
767  return d->rc != 0;
768 }
#define WGL_CONTEXT_FLAGS_ARB
Definition: qgl_win.cpp:129
#define WGL_CONTEXT_MINOR_VERSION_ARB
Definition: qgl_win.cpp:127
int majorVersion() const
Returns the OpenGL major version.
Definition: qgl.cpp:1223
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB
Definition: qgl_win.cpp:134
OpenGLContextProfile profile() const
Returns the OpenGL context profile.
Definition: qgl.cpp:1286
int plane() const
Returns the plane of this format.
Definition: qgl.cpp:924
#define APIENTRYP
Definition: glfunctions.h:58
Q_CORE_EXPORT void qWarning(const char *,...)
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB
Definition: qgl_win.cpp:133
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB
Definition: qgl_win.cpp:132
int minorVersion() const
Returns the OpenGL minor version.
Definition: qgl.cpp:1238
bool testOption(QGL::FormatOptions opt) const
Returns true if format option opt is set; otherwise returns false.
Definition: qgl.cpp:971
QGLFormat reqFormat
Definition: qgl_p.h:419
#define WGL_CONTEXT_LAYER_PLANE_ARB
Definition: qgl_win.cpp:128
#define WGL_CONTEXT_PROFILE_MASK_ARB
Definition: qgl_win.cpp:130
#define WGL_CONTEXT_MAJOR_VERSION_ARB
Definition: qgl_win.cpp:126

◆ qgl_create_rgb_palette()

static QRgb* qgl_create_rgb_palette ( const PIXELFORMATDESCRIPTOR *  pfd)
static

Definition at line 505 of file qgl_win.cpp.

Referenced by QGLContextPrivate::updateFormatVersion().

506 {
507  if ((pfd->iPixelType != PFD_TYPE_RGBA) ||
508  !(pfd->dwFlags & PFD_NEED_PALETTE) ||
509  (pfd->cColorBits != 8))
510  return 0;
511  int numEntries = 1 << pfd->cColorBits;
512  QRgb* pal = new QRgb[numEntries];
513  for (int i = 0; i < numEntries; i++) {
514  int r = qgl_rgb_palette_comp(i, pfd->cRedBits, pfd->cRedShift);
515  int g = qgl_rgb_palette_comp(i, pfd->cGreenBits, pfd->cGreenShift);
516  int b = qgl_rgb_palette_comp(i, pfd->cBlueBits, pfd->cBlueShift);
517  pal[i] = qRgb(r, g, b);
518  }
519 
520  const int syscol_indices[12] = {
521  3, 24, 27, 64, 67, 88, 173, 181, 236, 247, 164, 91
522  };
523 
524  const uint syscols[20] = {
525  0x000000, 0x800000, 0x008000, 0x808000, 0x000080, 0x800080,
526  0x008080, 0xc0c0c0, 0xc0dcc0, 0xa6caf0, 0xfffbf0, 0xa0a0a4,
527  0x808080, 0xff0000, 0x00ff00, 0xffff00, 0x0000ff, 0xff00ff,
528  0x00ffff, 0xffffff
529  }; // colors #1 - #12 are not present in pal; gets added below
530 
531  if ((pfd->cColorBits == 8) &&
532  (pfd->cRedBits == 3) && (pfd->cRedShift == 0) &&
533  (pfd->cGreenBits == 3) && (pfd->cGreenShift == 3) &&
534  (pfd->cBlueBits == 2) && (pfd->cBlueShift == 6)) {
535  for (int j = 0 ; j < 12 ; j++)
536  pal[syscol_indices[j]] = QRgb(syscols[j+1]);
537  }
538 
539  return pal;
540 }
unsigned int QRgb
Definition: qrgb.h:53
static uchar qgl_rgb_palette_comp(int idx, uint nbits, uint shift)
Definition: qgl_win.cpp:471
unsigned int uint
Definition: qglobal.h:996
QRgb qRgb(int r, int g, int b)
Returns the ARGB quadruplet (255, {r}, {g}, {b}).
Definition: qrgb.h:69
QRgb
An ARGB quadruplet on the format #AARRGGBB, equivalent to an unsigned int.

◆ qgl_rgb_palette_comp()

static uchar qgl_rgb_palette_comp ( int  idx,
uint  nbits,
uint  shift 
)
static

Definition at line 471 of file qgl_win.cpp.

Referenced by qgl_create_rgb_palette().

472 {
473  const uchar map_3_to_8[8] = {
474  0, 0111>>1, 0222>>1, 0333>>1, 0444>>1, 0555>>1, 0666>>1, 0377
475  };
476  const uchar map_2_to_8[4] = {
477  0, 0x55, 0xaa, 0xff
478  };
479  const uchar map_1_to_8[2] = {
480  0, 255
481  };
482 
483  uchar val = (uchar) (idx >> shift);
484  uchar res = 0;
485  switch (nbits) {
486  case 1:
487  val &= 0x1;
488  res = map_1_to_8[val];
489  break;
490  case 2:
491  val &= 0x3;
492  res = map_2_to_8[val];
493  break;
494  case 3:
495  val &= 0x7;
496  res = map_3_to_8[val];
497  break;
498  default:
499  res = 0;
500  }
501  return res;
502 }
static ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qreal threshold)
Definition: qbezier.cpp:289
unsigned char uchar
Definition: qglobal.h:994

◆ qLogEq()

static bool qLogEq ( bool  a,
bool  b 
)
static

Definition at line 1007 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat().

1008 {
1009  return (((!a) && (!b)) || (a && b));
1010 }
long ASN1_INTEGER_get ASN1_INTEGER * a

◆ qStoreColors()

static void qStoreColors ( HPALETTE  cmap,
const QGLColormap cols 
)
static

Definition at line 1425 of file qgl_win.cpp.

Referenced by QGLWidgetPrivate::updateColormap().

1426 {
1427  QRgb color;
1428  PALETTEENTRY pe;
1429 
1430  for (int i = 0; i < cols.size(); i++) {
1431  color = cols.entryRgb(i);
1432  pe.peRed = qRed(color);
1433  pe.peGreen = qGreen(color);
1434  pe.peBlue = qBlue(color);
1435  pe.peFlags = 0;
1436 
1437  SetPaletteEntries(cmap, i, 1, &pe);
1438  }
1439 }
unsigned int QRgb
Definition: qrgb.h:53
int size() const
Returns the number of colorcells in the colormap.
static QColor cmap[256]
Definition: qgl_mac.mm:760
int qRed(QRgb rgb)
Returns the red component of the ARGB quadruplet rgb.
Definition: qrgb.h:57
QRgb entryRgb(int idx) const
Returns the QRgb value in the colorcell with index idx.
int qGreen(QRgb rgb)
Returns the green component of the ARGB quadruplet rgb.
Definition: qrgb.h:60
int qBlue(QRgb rgb)
Returns the blue component of the ARGB quadruplet rgb.
Definition: qrgb.h:63

◆ qt_getRegisteredWndClass()

Q_GUI_EXPORT const QString qt_getRegisteredWndClass ( )

Definition at line 1118 of file qapplication_win.cpp.

Referenced by pfiToQGLFormat().

1119 {
1120  return qt_reg_winclass(0);
1121 }
const QString qt_reg_winclass(QWidget *w)

◆ qwglError()

void qwglError ( const char *  method,
const char *  func 
)

Definition at line 404 of file qgl_win.cpp.

Referenced by QGLContext::choosePixelFormat(), and QGLContextPrivate::updateFormatVersion().

405 {
406 #ifndef QT_NO_DEBUG
407  char* lpMsgBuf;
408  FormatMessageA(
409  FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
410  0, GetLastError(),
411  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
412  (char*) &lpMsgBuf, 0, 0);
413  qWarning("%s : %s failed: %s", method, func, lpMsgBuf);
414  LocalFree(lpMsgBuf);
415 #else
416  Q_UNUSED(method);
417  Q_UNUSED(func);
418 #endif
419 }
Q_CORE_EXPORT void qWarning(const char *,...)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

Variable Documentation

◆ opengl32dll

bool opengl32dll = false
static