ReactOS  0.4.13-dev-464-g6b95727
wgl.c File Reference
#include "opengl32.h"
#include <pseh/pseh2.h>
#include "glfuncs.h"
Include dependency graph for wgl.c:

Go to the source code of this file.

Macros

#define USE_GL_FUNC(func, w, x, y, z)   if(!strcmp(name, "gl" #func)) return NULL;
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (wgl)
 
static struct wgl_dc_dataget_dc_data_ex (HDC hdc, INT format, UINT size, PIXELFORMATDESCRIPTOR *descr)
 
static struct wgl_dc_dataget_dc_data (HDC hdc)
 
void release_dc_data (struct wgl_dc_data *dc_data)
 
struct wgl_contextget_context (HGLRC hglrc)
 
INT WINAPI wglDescribePixelFormat (HDC hdc, INT format, UINT size, PIXELFORMATDESCRIPTOR *descr)
 
INT WINAPI wglChoosePixelFormat (HDC hdc, const PIXELFORMATDESCRIPTOR *ppfd)
 
BOOL WINAPI wglCopyContext (HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask)
 
HGLRC WINAPI wglCreateContext (HDC hdc)
 
HGLRC WINAPI wglCreateLayerContext (HDC hdc, int iLayerPlane)
 
BOOL WINAPI wglDeleteContext (HGLRC hglrc)
 
BOOL WINAPI wglDescribeLayerPlane (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nBytes, LPLAYERPLANEDESCRIPTOR plpd)
 
HGLRC WINAPI wglGetCurrentContext (void)
 
HDC WINAPI wglGetCurrentDC (void)
 
PROC WINAPI wglGetDefaultProcAddress (LPCSTR lpszProc)
 
int WINAPI wglGetLayerPaletteEntries (HDC hdc, int iLayerPlane, int iStart, int cEntries, COLORREF *pcr)
 
INT WINAPI wglGetPixelFormat (HDC hdc)
 
PROC WINAPI wglGetProcAddress (LPCSTR name)
 
void APIENTRY set_api_table (const GLCLTPROCTABLE *table)
 
BOOL WINAPI wglMakeCurrent (HDC hdc, HGLRC hglrc)
 
BOOL WINAPI wglRealizeLayerPalette (HDC hdc, int iLayerPlane, BOOL bRealize)
 
int WINAPI wglSetLayerPaletteEntries (HDC hdc, int iLayerPlane, int iStart, int cEntries, const COLORREF *pcr)
 
BOOL WINAPI wglSetPixelFormat (HDC hdc, INT format, const PIXELFORMATDESCRIPTOR *descr)
 
BOOL WINAPI wglShareLists (HGLRC hglrcSrc, HGLRC hglrcDst)
 
BOOL WINAPI DECLSPEC_HOTPATCH wglSwapBuffers (HDC hdc)
 
BOOL WINAPI wglSwapLayerBuffers (HDC hdc, UINT fuPlanes)
 
DWORD WINAPI wglSwapMultipleBuffers (UINT count, CONST WGLSWAP *toSwap)
 
void IntDeleteAllContexts (void)
 

Variables

static CRITICAL_SECTION dc_data_cs = {NULL, -1, 0, 0, 0, 0}
 
static struct wgl_dc_datadc_data_list = NULL
 
LIST_ENTRY ContextListHead
 

Macro Definition Documentation

◆ USE_GL_FUNC

#define USE_GL_FUNC (   func,
  w,
  x,
  y,
  z 
)    if(!strcmp(name, "gl" #func)) return NULL;

Function Documentation

◆ get_context()

struct wgl_context* get_context ( HGLRC  hglrc)

Definition at line 102 of file wgl.c.

103 {
104  struct wgl_context* context = (struct wgl_context*)hglrc;
105 
106  if(!hglrc)
107  return NULL;
108 
109  _SEH2_TRY
110  {
111  if(context->magic != 'GLRC')
112  context = NULL;
113  }
115  {
116  context = NULL;
117  }
118  _SEH2_END;
119 
120  return context;
121 }
Definition: http.c:6587
static HDC HGLRC hglrc
Definition: opengl.c:36
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
_SEH2_END
Definition: create.c:4424
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

Referenced by wglCopyContext(), wglDeleteContext(), wglGetProcAddress(), wglMakeCurrent(), and wglShareLists().

◆ get_dc_data()

static struct wgl_dc_data* get_dc_data ( HDC  hdc)
static

Definition at line 92 of file wgl.c.

93 {
94  return get_dc_data_ex(hdc, 0, 0, NULL);
95 }
static struct wgl_dc_data * get_dc_data_ex(HDC hdc, INT format, UINT size, PIXELFORMATDESCRIPTOR *descr)
Definition: wgl.c:22
smooth NULL
Definition: ftsmooth.c:416
HDC hdc
Definition: main.c:9

Referenced by wglCreateContext(), wglCreateLayerContext(), wglDescribeLayerPlane(), wglGetLayerPaletteEntries(), wglGetPixelFormat(), wglMakeCurrent(), wglRealizeLayerPalette(), wglSetLayerPaletteEntries(), wglSetPixelFormat(), and wglSwapBuffers().

◆ get_dc_data_ex()

static struct wgl_dc_data* get_dc_data_ex ( HDC  hdc,
INT  format,
UINT  size,
PIXELFORMATDESCRIPTOR descr 
)
static

Definition at line 22 of file wgl.c.

23 {
24  HWND hwnd = NULL;
25  struct wgl_dc_data* data;
26  DWORD objType = GetObjectType(hdc);
27  ULONG flags = 0;
28  union
29  {
30  HWND hwnd;
31  HDC hdc;
32  HANDLE u;
33  } id;
34 
35  /* Look for the right data identifier */
36  if(objType == OBJ_DC)
37  {
39  if(!hwnd)
40  return NULL;
41  id.hwnd = hwnd;
43  }
44  else if(objType == OBJ_MEMDC)
45  {
46  id.hdc = hdc;
47  }
48  else
49  {
50  return NULL;
51  }
52 
55  while(data)
56  {
57  if(data->owner.u == id.u)
58  {
60  return data;
61  }
62  data = data->next;
63  }
64  data= HeapAlloc(GetProcessHeap(), 0, sizeof(*data));
65  if(!data)
66  {
68  return NULL;
69  }
70  /* initialize the structure */
71  data->owner.u = id.u;
72  data->flags = flags;
73  data->pixelformat = 0;
74  data->sw_data = NULL;
75  /* Load the driver */
76  data->icd_data = IntGetIcdData(hdc);
77  /* Get the number of available formats for this DC once and for all */
78  if(data->icd_data)
79  data->nb_icd_formats = data->icd_data->DrvDescribePixelFormat(hdc, format, size, descr);
80  else
81  data->nb_icd_formats = 0;
82  TRACE("ICD %S has %u formats for HDC %x.\n", data->icd_data ? data->icd_data->DriverName : NULL, data->nb_icd_formats, hdc);
83  data->nb_sw_formats = sw_DescribePixelFormat(hdc, 0, 0, NULL);
84  data->next = dc_data_list;
87  return data;
88 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define OBJ_MEMDC
Definition: objidl.idl:1418
static HDC
Definition: imagelist.c:92
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
smooth NULL
Definition: ftsmooth.c:416
struct ICD_Data * IntGetIcdData(HDC hdc)
Definition: icdload.c:57
HWND WINAPI WindowFromDC(_In_ HDC hDC)
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define OBJ_DC
Definition: objidl.idl:1411
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
HDC hdc
Definition: main.c:9
#define WGL_DC_OBJ_DC
Definition: opengl32.h:84
INT sw_DescribePixelFormat(HDC hdc, INT format, UINT size, PIXELFORMATDESCRIPTOR *descr)
Definition: swimpl.c:315
static POBJECT_TYPE GetObjectType(IN PCWSTR TypeName)
Definition: ObTypes.c:15
unsigned int ULONG
Definition: retypes.h:1
GLenum GLuint id
Definition: glext.h:5579
const char * descr
Definition: boot.c:42
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static struct wgl_dc_data * dc_data_list
Definition: wgl.c:15
static CRITICAL_SECTION dc_data_cs
Definition: wgl.c:14

Referenced by get_dc_data(), and wglDescribePixelFormat().

◆ IntDeleteAllContexts()

void IntDeleteAllContexts ( void  )

Definition at line 927 of file wgl.c.

928 {
929  struct wgl_context* context;
931 
932  while (Entry != &ContextListHead)
933  {
936  Entry = Entry->Flink;
937  }
938 }
static HGLRC(WINAPI *pwglCreateContextAttribsARB)(HDC hDC
BOOL WINAPI wglDeleteContext(HGLRC hglrc)
Definition: wgl.c:514
Definition: http.c:6587
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
Definition: typedefs.h:117
LIST_ENTRY ListEntry
Definition: opengl32.h:76
base of all file and directory entries
Definition: entries.h:82
LIST_ENTRY ContextListHead
Definition: wgl.c:17

Referenced by DllMain().

◆ release_dc_data()

void release_dc_data ( struct wgl_dc_data dc_data)

Definition at line 97 of file wgl.c.

98 {
99  (void)dc_data;
100 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49

Referenced by wglCreateLayerContext(), wglDescribePixelFormat(), wglGetPixelFormat(), and wglMakeCurrent().

◆ set_api_table()

void APIENTRY set_api_table ( const GLCLTPROCTABLE table)

Definition at line 645 of file wgl.c.

646 {
647  IntSetCurrentDispatchTable(&table->glDispatchTable);
648 }
FORCEINLINE void IntSetCurrentDispatchTable(const GLDISPATCHTABLE *table)
Definition: opengl32.h:124

Referenced by wglMakeCurrent().

◆ wglChoosePixelFormat()

INT WINAPI wglChoosePixelFormat ( HDC  hdc,
const PIXELFORMATDESCRIPTOR ppfd 
)

Definition at line 174 of file wgl.c.

175 {
177  int i, count, best_format;
178  int bestDBuffer = -1, bestStereo = -1;
179 
180  TRACE_(wgl)( "%p %p: size %u version %u flags %u type %u color %u %u,%u,%u,%u "
181  "accum %u depth %u stencil %u aux %u\n",
182  hdc, ppfd, ppfd->nSize, ppfd->nVersion, ppfd->dwFlags, ppfd->iPixelType,
183  ppfd->cColorBits, ppfd->cRedBits, ppfd->cGreenBits, ppfd->cBlueBits, ppfd->cAlphaBits,
184  ppfd->cAccumBits, ppfd->cDepthBits, ppfd->cStencilBits, ppfd->cAuxBuffers );
185 
186  count = wglDescribePixelFormat( hdc, 0, 0, NULL );
187  if (!count) return 0;
188 
189  best_format = 0;
191  best.cAlphaBits = -1;
192  best.cColorBits = -1;
193  best.cDepthBits = -1;
194  best.cStencilBits = -1;
195  best.cAuxBuffers = -1;
196 
197  for (i = 1; i <= count; i++)
198  {
199  if (!wglDescribePixelFormat( hdc, i, sizeof(format), &format )) continue;
200 
201  if (ppfd->iPixelType != format.iPixelType)
202  {
203  TRACE( "pixel type mismatch for iPixelFormat=%d\n", i );
204  continue;
205  }
206 
207  /* only use bitmap capable formats for bitmap rendering */
208  if ((ppfd->dwFlags & PFD_DRAW_TO_BITMAP) && !(format.dwFlags & PFD_DRAW_TO_BITMAP))
209  {
210  TRACE( "PFD_DRAW_TO_BITMAP mismatch for iPixelFormat=%d\n", i );
211  continue;
212  }
213 
214  /* only use window capable formats for window rendering */
215  if ((ppfd->dwFlags & PFD_DRAW_TO_WINDOW) && !(format.dwFlags & PFD_DRAW_TO_WINDOW))
216  {
217  TRACE( "PFD_DRAW_TO_WINDOW mismatch for iPixelFormat=%d\n", i );
218  continue;
219  }
220 
221  /* only use opengl capable formats for opengl rendering */
222  if ((ppfd->dwFlags & PFD_SUPPORT_OPENGL) && !(format.dwFlags & PFD_SUPPORT_OPENGL))
223  {
224  TRACE( "PFD_SUPPORT_OPENGL mismatch for iPixelFormat=%d\n", i );
225  continue;
226  }
227 
228  /* only use GDI capable formats for GDI rendering */
229  if ((ppfd->dwFlags & PFD_SUPPORT_GDI) && !(format.dwFlags & PFD_SUPPORT_GDI))
230  {
231  TRACE( "PFD_SUPPORT_GDI mismatch for iPixelFormat=%d\n", i );
232  continue;
233  }
234 
235  /* The behavior of PDF_STEREO/PFD_STEREO_DONTCARE and PFD_DOUBLEBUFFER / PFD_DOUBLEBUFFER_DONTCARE
236  * is not very clear on MSDN. They specify that ChoosePixelFormat tries to match pixel formats
237  * with the flag (PFD_STEREO / PFD_DOUBLEBUFFERING) set. Otherwise it says that it tries to match
238  * formats without the given flag set.
239  * A test on Windows using a Radeon 9500pro on WinXP (the driver doesn't support Stereo)
240  * has indicated that a format without stereo is returned when stereo is unavailable.
241  * So in case PFD_STEREO is set, formats that support it should have priority above formats
242  * without. In case PFD_STEREO_DONTCARE is set, stereo is ignored.
243  *
244  * To summarize the following is most likely the correct behavior:
245  * stereo not set -> prefer non-stereo formats, but also accept stereo formats
246  * stereo set -> prefer stereo formats, but also accept non-stereo formats
247  * stereo don't care -> it doesn't matter whether we get stereo or not
248  *
249  * In Wine we will treat non-stereo the same way as don't care because it makes
250  * format selection even more complicated and second drivers with Stereo advertise
251  * each format twice anyway.
252  */
253 
254  /* Doublebuffer, see the comments above */
255  if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE))
256  {
257  if (((ppfd->dwFlags & PFD_DOUBLEBUFFER) != bestDBuffer) &&
258  ((format.dwFlags & PFD_DOUBLEBUFFER) == (ppfd->dwFlags & PFD_DOUBLEBUFFER)))
259  goto found;
260 
261  if (bestDBuffer != -1 && (format.dwFlags & PFD_DOUBLEBUFFER) != bestDBuffer) continue;
262  }
263 
264  /* Stereo, see the comments above. */
265  if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE))
266  {
267  if (((ppfd->dwFlags & PFD_STEREO) != bestStereo) &&
268  ((format.dwFlags & PFD_STEREO) == (ppfd->dwFlags & PFD_STEREO)))
269  goto found;
270 
271  if (bestStereo != -1 && (format.dwFlags & PFD_STEREO) != bestStereo) continue;
272  }
273 
274  /* Below we will do a number of checks to select the 'best' pixelformat.
275  * We assume the precedence cColorBits > cAlphaBits > cDepthBits > cStencilBits -> cAuxBuffers.
276  * The code works by trying to match the most important options as close as possible.
277  * When a reasonable format is found, we will try to match more options.
278  * It appears (see the opengl32 test) that Windows opengl drivers ignore options
279  * like cColorBits, cAlphaBits and friends if they are set to 0, so they are considered
280  * as DONTCARE. At least Serious Sam TSE relies on this behavior. */
281 
282  if (ppfd->cColorBits)
283  {
284  if (((ppfd->cColorBits > best.cColorBits) && (format.cColorBits > best.cColorBits)) ||
285  ((format.cColorBits >= ppfd->cColorBits) && (format.cColorBits < best.cColorBits)))
286  goto found;
287 
288  if (best.cColorBits != format.cColorBits) /* Do further checks if the format is compatible */
289  {
290  TRACE( "color mismatch for iPixelFormat=%d\n", i );
291  continue;
292  }
293  }
294  if (ppfd->cAlphaBits)
295  {
296  if (((ppfd->cAlphaBits > best.cAlphaBits) && (format.cAlphaBits > best.cAlphaBits)) ||
297  ((format.cAlphaBits >= ppfd->cAlphaBits) && (format.cAlphaBits < best.cAlphaBits)))
298  goto found;
299 
300  if (best.cAlphaBits != format.cAlphaBits)
301  {
302  TRACE( "alpha mismatch for iPixelFormat=%d\n", i );
303  continue;
304  }
305  }
306  if (ppfd->cDepthBits)
307  {
308  if (((ppfd->cDepthBits > best.cDepthBits) && (format.cDepthBits > best.cDepthBits)) ||
309  ((format.cDepthBits >= ppfd->cDepthBits) && (format.cDepthBits < best.cDepthBits)))
310  goto found;
311 
312  if (best.cDepthBits != format.cDepthBits)
313  {
314  TRACE( "depth mismatch for iPixelFormat=%d\n", i );
315  continue;
316  }
317  }
318  if (ppfd->cStencilBits)
319  {
320  if (((ppfd->cStencilBits > best.cStencilBits) && (format.cStencilBits > best.cStencilBits)) ||
321  ((format.cStencilBits >= ppfd->cStencilBits) && (format.cStencilBits < best.cStencilBits)))
322  goto found;
323 
324  if (best.cStencilBits != format.cStencilBits)
325  {
326  TRACE( "stencil mismatch for iPixelFormat=%d\n", i );
327  continue;
328  }
329  }
330  if (ppfd->cAuxBuffers)
331  {
332  if (((ppfd->cAuxBuffers > best.cAuxBuffers) && (format.cAuxBuffers > best.cAuxBuffers)) ||
333  ((format.cAuxBuffers >= ppfd->cAuxBuffers) && (format.cAuxBuffers < best.cAuxBuffers)))
334  goto found;
335 
336  if (best.cAuxBuffers != format.cAuxBuffers)
337  {
338  TRACE( "aux mismatch for iPixelFormat=%d\n", i );
339  continue;
340  }
341  }
342  continue;
343 
344  found:
345  /* Prefer HW accelerated formats */
346  if ((format.dwFlags & PFD_GENERIC_FORMAT) && !(best.dwFlags & PFD_GENERIC_FORMAT))
347  continue;
348  best_format = i;
349  best = format;
350  bestDBuffer = format.dwFlags & PFD_DOUBLEBUFFER;
351  bestStereo = format.dwFlags & PFD_STEREO;
352  }
353 
354  TRACE( "returning %u\n", best_format );
355  return best_format;
356 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define PFD_DRAW_TO_BITMAP
Definition: wingdi.h:303
INT WINAPI wglDescribePixelFormat(HDC hdc, INT format, UINT size, PIXELFORMATDESCRIPTOR *descr)
Definition: wgl.c:123
_In_ LONG _In_ ULONG _Out_opt_ PIXELFORMATDESCRIPTOR * ppfd
Definition: winddi.h:3488
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define PFD_DOUBLEBUFFER
Definition: wingdi.h:300
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
#define TRACE_(x)
Definition: compat.h:66
#define PFD_SUPPORT_GDI
Definition: wingdi.h:304
#define TRACE(s)
Definition: solgame.cpp:4
#define PFD_DOUBLEBUFFER_DONTCARE
Definition: wingdi.h:315
HDC hdc
Definition: main.c:9
#define PFD_GENERIC_FORMAT
Definition: wingdi.h:306
#define PFD_STEREO
Definition: wingdi.h:301
#define PFD_SUPPORT_OPENGL
Definition: wingdi.h:305
#define PFD_DRAW_TO_WINDOW
Definition: wingdi.h:302
#define PFD_STEREO_DONTCARE
Definition: wingdi.h:316

◆ wglCopyContext()

BOOL WINAPI wglCopyContext ( HGLRC  hglrcSrc,
HGLRC  hglrcDst,
UINT  mask 
)

Definition at line 358 of file wgl.c.

359 {
360  struct wgl_context* ctx_src = get_context(hglrcSrc);
361  struct wgl_context* ctx_dst = get_context(hglrcDst);
362 
363  if(!ctx_src || !ctx_dst)
364  {
366  return FALSE;
367  }
368 
369  /* Check this is the same pixel format */
370  if((ctx_dst->icd_data != ctx_src->icd_data) ||
371  (ctx_dst->pixelformat != ctx_src->pixelformat))
372  {
374  return FALSE;
375  }
376 
377  if(ctx_src->icd_data)
378  return ctx_src->icd_data->DrvCopyContext(ctx_src->dhglrc, ctx_dst->dhglrc, mask);
379 
380  return sw_CopyContext(ctx_src->dhglrc, ctx_dst->dhglrc, mask);
381 }
DHGLRC dhglrc
Definition: opengl32.h:78
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
struct ICD_Data * icd_data
Definition: opengl32.h:79
GLenum GLint GLuint mask
Definition: glext.h:6028
#define SetLastError(x)
Definition: compat.h:409
BOOL sw_CopyContext(DHGLRC dhglrcSrc, DHGLRC dhglrcDst, UINT mask)
Definition: swimpl.c:498
#define ERROR_INVALID_PIXEL_FORMAT
Definition: winerror.h:1179
struct wgl_context * get_context(HGLRC hglrc)
Definition: wgl.c:102
INT pixelformat
Definition: opengl32.h:80

◆ wglCreateContext()

HGLRC WINAPI wglCreateContext ( HDC  hdc)

Definition at line 383 of file wgl.c.

384 {
385  struct wgl_dc_data* dc_data = get_dc_data(hdc);
386  struct wgl_context* context;
387  DHGLRC dhglrc;
388 
389  TRACE("Creating context for %p.\n", hdc);
390 
391  if(!dc_data)
392  {
393  WARN("Not a DC handle!\n");
395  return NULL;
396  }
397 
398  if(!dc_data->pixelformat)
399  {
400  WARN("Pixel format not set!\n");
402  return NULL;
403  }
404 
405  if(!dc_data->icd_data)
406  {
407  TRACE("Calling SW implementation.\n");
408  dhglrc = sw_CreateContext(dc_data);
409  TRACE("done\n");
410  }
411  else
412  {
413  TRACE("Calling ICD.\n");
414  dhglrc = dc_data->icd_data->DrvCreateContext(hdc);
415  }
416 
417  if(!dhglrc)
418  {
419  WARN("Failed!\n");
421  return NULL;
422  }
423 
424  context = HeapAlloc(GetProcessHeap(), 0, sizeof(*context));
425  if(!context)
426  {
427  WARN("Failed to allocate a context!\n");
428  if(!dc_data->icd_data)
430  else
431  dc_data->icd_data->DrvDeleteContext(dhglrc);
433  return NULL;
434  }
435  /* Copy info from the DC data */
436  context->dhglrc = dhglrc;
437  context->icd_data = dc_data->icd_data;
438  context->pixelformat = dc_data->pixelformat;
439  context->thread_id = 0;
440 
441  /* Insert into the list */
442  InsertTailList(&ContextListHead, &context->ListEntry);
443 
444  context->magic = 'GLRC';
445  TRACE("Success!\n");
446  return (HGLRC)context;
447 }
static HGLRC(WINAPI *pwglCreateContextAttribsARB)(HDC hDC
DHGLRC dhglrc
Definition: opengl32.h:78
Definition: http.c:6587
#define WARN(fmt,...)
Definition: debug.h:111
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define InsertTailList(ListHead, Entry)
struct ICD_Data * icd_data
Definition: opengl32.h:100
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define SetLastError(x)
Definition: compat.h:409
HDC hdc
Definition: main.c:9
INT pixelformat
Definition: opengl32.h:97
#define ERROR_INVALID_PIXEL_FORMAT
Definition: winerror.h:1179
static struct wgl_dc_data * get_dc_data(HDC hdc)
Definition: wgl.c:92
BOOL sw_DeleteContext(DHGLRC dhglrc)
Definition: swimpl.c:448
DHGLRC sw_CreateContext(struct wgl_dc_data *)
Definition: swimpl.c:422
LIST_ENTRY ContextListHead
Definition: wgl.c:17

Referenced by context_create(), InitGL(), InitOGLWindow(), OnCreate(), ScreenSaverProc(), START_TEST(), test_bitmap_rendering(), test_deletecontext(), test_destroy(), test_destroy_read(), test_make_current_read(), test_makecurrent(), test_message_window(), test_minimized(), test_opengl3(), test_setpixelformat(), test_sharelists(), test_swap_control(), test_window_dc(), and wined3d_caps_gl_ctx_create().

◆ wglCreateLayerContext()

HGLRC WINAPI wglCreateLayerContext ( HDC  hdc,
int  iLayerPlane 
)

Definition at line 449 of file wgl.c.

450 {
451  struct wgl_dc_data* dc_data = get_dc_data(hdc);
452  struct wgl_context* context;
453  DHGLRC dhglrc;
454 
455  if(!dc_data)
456  {
458  return NULL;
459  }
460 
461  if(!dc_data->pixelformat)
462  {
463  release_dc_data(dc_data);
465  return NULL;
466  }
467 
468  if(!dc_data->icd_data)
469  {
470  if(iLayerPlane != 0)
471  {
472  /* Not supported in SW implementation */
473  release_dc_data(dc_data);
475  return NULL;
476  }
477  dhglrc = sw_CreateContext(dc_data);
478  }
479  else
480  {
481  dhglrc = dc_data->icd_data->DrvCreateLayerContext(hdc, iLayerPlane);
482  }
483 
484  if(!dhglrc)
485  {
486  release_dc_data(dc_data);
488  return NULL;
489  }
490 
491  context = HeapAlloc(GetProcessHeap(), 0, sizeof(*context));
492  if(!context)
493  {
494  if(!dc_data->icd_data)
496  else
497  dc_data->icd_data->DrvDeleteContext(dhglrc);
498  release_dc_data(dc_data);
500  return NULL;
501  }
502  /* Copy info from the DC data */
503  context->dhglrc = dhglrc;
504  context->icd_data = dc_data->icd_data;
505  context->pixelformat = dc_data->pixelformat;
506  context->thread_id = 0;
507 
508  context->magic = 'GLRC';
509 
510  release_dc_data(dc_data);
511  return (HGLRC)context;
512 }
static HGLRC(WINAPI *pwglCreateContextAttribsARB)(HDC hDC
DHGLRC dhglrc
Definition: opengl32.h:78
Definition: http.c:6587
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
struct ICD_Data * icd_data
Definition: opengl32.h:100
void release_dc_data(struct wgl_dc_data *dc_data)
Definition: wgl.c:97
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define SetLastError(x)
Definition: compat.h:409
HDC hdc
Definition: main.c:9
INT pixelformat
Definition: opengl32.h:97
#define ERROR_INVALID_PIXEL_FORMAT
Definition: winerror.h:1179
static struct wgl_dc_data * get_dc_data(HDC hdc)
Definition: wgl.c:92
BOOL sw_DeleteContext(DHGLRC dhglrc)
Definition: swimpl.c:448
DHGLRC sw_CreateContext(struct wgl_dc_data *)
Definition: swimpl.c:422

◆ wglDeleteContext()

BOOL WINAPI wglDeleteContext ( HGLRC  hglrc)

Definition at line 514 of file wgl.c.

515 {
518 
519  if(!context)
520  {
522  return FALSE;
523  }
524 
525  /* Own this context before touching it */
526  if(InterlockedCompareExchange(&context->thread_id, thread_id, 0) != 0)
527  {
528  /* We can't delete a context current to another thread */
529  if(context->thread_id != thread_id)
530  {
532  return FALSE;
533  }
534 
535  /* This is in our thread. Release and try again */
536  if(!wglMakeCurrent(NULL, NULL))
537  return FALSE;
538  return wglDeleteContext(hglrc);
539  }
540 
541  if(context->icd_data)
542  context->icd_data->DrvDeleteContext(context->dhglrc);
543  else
544  sw_DeleteContext(context->dhglrc);
545 
546  context->magic = 0;
547  RemoveEntryList(&context->ListEntry);
549 
550  return TRUE;
551 }
#define TRUE
Definition: types.h:120
BOOL WINAPI wglDeleteContext(HGLRC hglrc)
Definition: wgl.c:514
Definition: http.c:6587
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define InterlockedCompareExchange
Definition: interlocked.h:104
static HDC HGLRC hglrc
Definition: opengl.c:36
#define ERROR_BUSY
Definition: dderror.h:12
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
#define GetProcessHeap()
Definition: compat.h:395
#define SetLastError(x)
Definition: compat.h:409
BOOL WINAPI wglMakeCurrent(HDC hdc, HGLRC hglrc)
Definition: wgl.c:650
static DWORD thread_id
Definition: protocol.c:158
BOOL sw_DeleteContext(DHGLRC dhglrc)
Definition: swimpl.c:448
struct wgl_context * get_context(HGLRC hglrc)
Definition: wgl.c:102
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by context_create(), context_destroy_gl_resources(), IntDeleteAllContexts(), OnDestroy(), ScreenSaverProc(), START_TEST(), test_bitmap_rendering(), test_deletecontext(), test_destroy(), test_destroy_read(), test_message_window(), test_minimized(), test_opengl3(), test_sharelists(), test_swap_control(), test_window_dc(), wgl_thread(), wglDeleteContext(), wined3d_caps_gl_ctx_create(), wined3d_caps_gl_ctx_create_attribs(), and wined3d_caps_gl_ctx_destroy().

◆ wglDescribeLayerPlane()

BOOL WINAPI wglDescribeLayerPlane ( HDC  hdc,
int  iPixelFormat,
int  iLayerPlane,
UINT  nBytes,
LPLAYERPLANEDESCRIPTOR  plpd 
)

Definition at line 553 of file wgl.c.

558 {
559  struct wgl_dc_data* dc_data = get_dc_data(hdc);
560 
561  if(!dc_data)
562  {
564  return FALSE;
565  }
566 
568  return dc_data->icd_data->DrvDescribeLayerPlane(hdc, iPixelFormat, iLayerPlane, nBytes, plpd);
569 
570  /* SW implementation doesn't support this */
571  return FALSE;
572 }
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
struct ICD_Data * icd_data
Definition: opengl32.h:100
#define SetLastError(x)
Definition: compat.h:409
HDC hdc
Definition: main.c:9
INT nb_icd_formats
Definition: opengl32.h:101
_In_ LONG iPixelFormat
Definition: winddi.h:3488
static struct wgl_dc_data * get_dc_data(HDC hdc)
Definition: wgl.c:92

◆ wglDescribePixelFormat()

INT WINAPI wglDescribePixelFormat ( HDC  hdc,
INT  format,
UINT  size,
PIXELFORMATDESCRIPTOR descr 
)

Definition at line 123 of file wgl.c.

124 {
125  struct wgl_dc_data* dc_data = get_dc_data_ex(hdc, format, size, descr);
126  INT ret;
127 
128  if(!dc_data)
129  {
131  return 0;
132  }
133 
134  ret = dc_data->nb_icd_formats + dc_data->nb_sw_formats;
135 
136  if(!descr)
137  {
138  release_dc_data(dc_data);
139  return ret;
140  }
141  if((format <= 0) || (format > ret) || (size < sizeof(*descr)))
142  {
143  release_dc_data(dc_data);
145  return 0;
146  }
147 
148  /* Query ICD if needed */
150  {
151  struct ICD_Data* icd_data = dc_data->icd_data;
152  /* SetPixelFormat may have NULLified this */
153  if (!icd_data)
154  icd_data = IntGetIcdData(hdc);
155  if(!icd_data->DrvDescribePixelFormat(hdc, format, size, descr))
156  {
157  ret = 0;
158  }
159  }
160  else
161  {
162  /* This is a software format */
163  format -= dc_data->nb_icd_formats;
165  {
166  ret = 0;
167  }
168  }
169 
170  release_dc_data(dc_data);
171  return ret;
172 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
static struct wgl_dc_data * get_dc_data_ex(HDC hdc, INT format, UINT size, PIXELFORMATDESCRIPTOR *descr)
Definition: wgl.c:22
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
int32_t INT
Definition: typedefs.h:56
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
struct ICD_Data * icd_data
Definition: opengl32.h:100
void release_dc_data(struct wgl_dc_data *dc_data)
Definition: wgl.c:97
INT nb_sw_formats
Definition: opengl32.h:104
struct ICD_Data * IntGetIcdData(HDC hdc)
Definition: icdload.c:57
GLsizeiptr size
Definition: glext.h:5919
#define SetLastError(x)
Definition: compat.h:409
int ret
HDC hdc
Definition: main.c:9
INT nb_icd_formats
Definition: opengl32.h:101
INT sw_DescribePixelFormat(HDC hdc, INT format, UINT size, PIXELFORMATDESCRIPTOR *descr)
Definition: swimpl.c:315
Definition: icd.h:365
const char * descr
Definition: boot.c:42

Referenced by wglChoosePixelFormat().

◆ wglGetCurrentContext()

◆ wglGetCurrentDC()

HDC WINAPI wglGetCurrentDC ( void  )

Definition at line 579 of file wgl.c.

580 {
581  return IntGetCurrentDC();
582 }
FORCEINLINE HDC IntGetCurrentDC(void)
Definition: opengl32.h:149

Referenced by context_destroy_gl_resources(), context_enter(), wined3d_adapter_init_gl_caps(), and wined3d_caps_gl_ctx_create().

◆ wglGetDefaultProcAddress()

PROC WINAPI wglGetDefaultProcAddress ( LPCSTR  lpszProc)

Definition at line 584 of file wgl.c.

585 {
586  /* undocumented... */
587  return NULL;
588 }
smooth NULL
Definition: ftsmooth.c:416

◆ wglGetLayerPaletteEntries()

int WINAPI wglGetLayerPaletteEntries ( HDC  hdc,
int  iLayerPlane,
int  iStart,
int  cEntries,
COLORREF pcr 
)

Definition at line 590 of file wgl.c.

591 {
592  struct wgl_dc_data* dc_data = get_dc_data(hdc);
593 
594  if(!dc_data)
595  {
597  return 0;
598  }
599 
600  if(!dc_data->pixelformat)
601  {
603  return 0;
604  }
605 
606  if(dc_data->icd_data)
607  return dc_data->icd_data->DrvGetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);
608 
609  /* SW implementation doesn't support this */
610  return 0;
611 }
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
_In_ UINT iStart
Definition: wingdi.h:3598
struct ICD_Data * icd_data
Definition: opengl32.h:100
#define SetLastError(x)
Definition: compat.h:409
_In_ UINT _In_ UINT cEntries
Definition: wingdi.h:3598
HDC hdc
Definition: main.c:9
INT pixelformat
Definition: opengl32.h:97
#define ERROR_INVALID_PIXEL_FORMAT
Definition: winerror.h:1179
static struct wgl_dc_data * get_dc_data(HDC hdc)
Definition: wgl.c:92

◆ wglGetPixelFormat()

INT WINAPI wglGetPixelFormat ( HDC  hdc)

Definition at line 613 of file wgl.c.

614 {
615  INT ret;
616  struct wgl_dc_data* dc_data = get_dc_data(hdc);
617 
618  if(!dc_data)
619  {
621  return 0;
622  }
623 
624  ret = dc_data->pixelformat;
625  release_dc_data(dc_data);
626  return ret;
627 }
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
int32_t INT
Definition: typedefs.h:56
void release_dc_data(struct wgl_dc_data *dc_data)
Definition: wgl.c:97
#define SetLastError(x)
Definition: compat.h:409
int ret
HDC hdc
Definition: main.c:9
INT pixelformat
Definition: opengl32.h:97
static struct wgl_dc_data * get_dc_data(HDC hdc)
Definition: wgl.c:92

◆ wglGetProcAddress()

PROC WINAPI wglGetProcAddress ( LPCSTR  name)

Definition at line 629 of file wgl.c.

630 {
632  if(!context)
633  return NULL;
634 
635  /* This shall fail for opengl 1.1 functions */
636 #define USE_GL_FUNC(func, w, x, y, z) if(!strcmp(name, "gl" #func)) return NULL;
637 #include "glfuncs.h"
638 
639  /* Forward */
640  if(context->icd_data)
641  return context->icd_data->DrvGetProcAddress(name);
642  return sw_GetProcAddress(name);
643 }
Definition: http.c:6587
FORCEINLINE HGLRC IntGetCurrentRC(void)
Definition: opengl32.h:142
smooth NULL
Definition: ftsmooth.c:416
PROC sw_GetProcAddress(LPCSTR name)
Definition: swimpl.c:478
Definition: name.c:36
struct wgl_context * get_context(HGLRC hglrc)
Definition: wgl.c:102

Referenced by test_getprocaddress(), and wined3d_caps_gl_ctx_create_attribs().

◆ wglMakeCurrent()

BOOL WINAPI wglMakeCurrent ( HDC  hdc,
HGLRC  hglrc 
)

Definition at line 650 of file wgl.c.

651 {
652  struct wgl_context* ctx = get_context(hglrc);
653  struct wgl_context* old_ctx = get_context(IntGetCurrentRC());
654  const GLCLTPROCTABLE* apiTable;
656 
657  if(ctx)
658  {
659  struct wgl_dc_data* dc_data = get_dc_data(hdc);
660  if(!dc_data)
661  {
662  ERR("wglMakeCurrent was passed an invalid DC handle.\n");
664  return FALSE;
665  }
666 
667  /* Check compatibility */
668  if((ctx->icd_data != dc_data->icd_data) || (ctx->pixelformat != dc_data->pixelformat))
669  {
670  /* That's bad, man */
671  ERR("HGLRC %p and HDC %p are not compatible.\n", hglrc, hdc);
672  release_dc_data(dc_data);
674  return FALSE;
675  }
676 
677  /* Set the thread ID */
679  {
680  /* Already current for a thread. Maybe it's us ? */
681  release_dc_data(dc_data);
682  if(ctx->thread_id != thread_id)
684  return (ctx->thread_id == thread_id);
685  }
686 
687  if(old_ctx)
688  {
689  /* Unset it */
690  if(old_ctx->icd_data)
691  old_ctx->icd_data->DrvReleaseContext(old_ctx->dhglrc);
692  else
693  sw_ReleaseContext(old_ctx->dhglrc);
694  InterlockedExchange(&old_ctx->thread_id, 0);
695  }
696 
697  /* Call the ICD or SW implementation */
698  if(ctx->icd_data)
699  {
700  apiTable = ctx->icd_data->DrvSetContext(hdc, ctx->dhglrc, set_api_table);
701  if(!apiTable)
702  {
703  ERR("DrvSetContext failed!\n");
704  /* revert */
705  InterlockedExchange(&ctx->thread_id, 0);
708  return FALSE;
709  }
710  set_api_table(apiTable);
711  /* Make it current */
712  IntMakeCurrent(hglrc, hdc, dc_data);
713  }
714  else
715  {
716  /* We must set current before, SW implementation relies on it */
717  IntMakeCurrent(hglrc, hdc, dc_data);
718  if(!sw_SetContext(dc_data, ctx->dhglrc))
719  {
720  ERR("sw_SetContext failed!\n");
721  /* revert */
723  InterlockedExchange(&ctx->thread_id, 0);
725  return FALSE;
726  }
727  }
728  }
729  else if(old_ctx)
730  {
731  if(old_ctx->icd_data)
732  old_ctx->icd_data->DrvReleaseContext(old_ctx->dhglrc);
733  else
734  sw_ReleaseContext(old_ctx->dhglrc);
735  InterlockedExchange(&old_ctx->thread_id, 0);
736  /* Unset it */
739  /* Test conformance (extreme cases) */
740  return hglrc == NULL;
741  }
742  else
743  {
744  /* Winetest conformance */
745  if (GetObjectType( hdc ) != OBJ_DC && GetObjectType( hdc ) != OBJ_MEMDC)
746  {
747  ERR( "Error: hdc is not a DC handle!\n");
749  return FALSE;
750  }
751  }
752 
753  return TRUE;
754 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
FORCEINLINE void IntMakeCurrent(HGLRC hglrc, HDC hdc, struct wgl_dc_data *dc_data)
Definition: opengl32.h:131
DHGLRC dhglrc
Definition: opengl32.h:78
BOOL sw_SetContext(struct wgl_dc_data *dc_data, DHGLRC dhglrc)
Definition: swimpl.c:1429
void sw_ReleaseContext(DHGLRC hglrc)
Definition: swimpl.c:1516
volatile LONG thread_id
Definition: opengl32.h:81
#define OBJ_MEMDC
Definition: objidl.idl:1418
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
struct ICD_Data * icd_data
Definition: opengl32.h:79
#define InterlockedCompareExchange
Definition: interlocked.h:104
static HDC HGLRC hglrc
Definition: opengl.c:36
#define ERROR_BUSY
Definition: dderror.h:12
void APIENTRY set_api_table(const GLCLTPROCTABLE *table)
Definition: wgl.c:645
FORCEINLINE HGLRC IntGetCurrentRC(void)
Definition: opengl32.h:142
long LONG
Definition: pedump.c:60
struct ICD_Data * icd_data
Definition: opengl32.h:100
void release_dc_data(struct wgl_dc_data *dc_data)
Definition: wgl.c:97
smooth NULL
Definition: ftsmooth.c:416
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
#define OBJ_DC
Definition: objidl.idl:1411
#define SetLastError(x)
Definition: compat.h:409
HDC hdc
Definition: main.c:9
INT pixelformat
Definition: opengl32.h:97
#define InterlockedExchange
Definition: armddk.h:54
#define ERR(fmt,...)
Definition: debug.h:109
FORCEINLINE void IntSetCurrentDispatchTable(const GLDISPATCHTABLE *table)
Definition: opengl32.h:124
static DWORD thread_id
Definition: protocol.c:158
static POBJECT_TYPE GetObjectType(IN PCWSTR TypeName)
Definition: ObTypes.c:15
static struct wgl_dc_data * get_dc_data(HDC hdc)
Definition: wgl.c:92
struct wgl_context * get_context(HGLRC hglrc)
Definition: wgl.c:102
INT pixelformat
Definition: opengl32.h:80

Referenced by context_destroy_gl_resources(), context_restore_gl_context(), context_set_current(), context_set_gl_context(), DllMain(), InitGL(), InitOGLWindow(), OnCreate(), OnDestroy(), ScreenSaverProc(), START_TEST(), test_bitmap_rendering(), test_deletecontext(), test_destroy(), test_destroy_read(), test_getprocaddress(), test_make_current_read(), test_makecurrent(), test_message_window(), test_minimized(), test_opengl3(), test_sharelists(), test_swap_control(), test_window_dc(), wgl_thread(), wglDeleteContext(), wined3d_caps_gl_ctx_create(), wined3d_caps_gl_ctx_create_attribs(), and wined3d_caps_gl_ctx_destroy().

◆ wglRealizeLayerPalette()

BOOL WINAPI wglRealizeLayerPalette ( HDC  hdc,
int  iLayerPlane,
BOOL  bRealize 
)

Definition at line 756 of file wgl.c.

759 {
760  struct wgl_dc_data* dc_data = get_dc_data(hdc);
761 
762  if(!dc_data)
763  {
765  return FALSE;
766  }
767 
768  if(!dc_data->pixelformat)
769  {
771  return FALSE;
772  }
773 
774  if(dc_data->icd_data)
775  return dc_data->icd_data->DrvRealizeLayerPalette(hdc, iLayerPlane, bRealize);
776 
777  /* SW implementation doesn't support this */
778  return FALSE;
779 }
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
struct ICD_Data * icd_data
Definition: opengl32.h:100
#define SetLastError(x)
Definition: compat.h:409
HDC hdc
Definition: main.c:9
INT pixelformat
Definition: opengl32.h:97
#define ERROR_INVALID_PIXEL_FORMAT
Definition: winerror.h:1179
static struct wgl_dc_data * get_dc_data(HDC hdc)
Definition: wgl.c:92

◆ wglSetLayerPaletteEntries()

int WINAPI wglSetLayerPaletteEntries ( HDC  hdc,
int  iLayerPlane,
int  iStart,
int  cEntries,
const COLORREF pcr 
)

Definition at line 781 of file wgl.c.

786 {
787  struct wgl_dc_data* dc_data = get_dc_data(hdc);
788 
789  if(!dc_data)
790  {
792  return 0;
793  }
794 
795  if(!dc_data->pixelformat)
796  {
798  return 0;
799  }
800 
801  if(dc_data->icd_data)
802  return dc_data->icd_data->DrvSetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);
803 
804  /* SW implementation doesn't support this */
805  return 0;
806 }
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
_In_ UINT iStart
Definition: wingdi.h:3598
struct ICD_Data * icd_data
Definition: opengl32.h:100
#define SetLastError(x)
Definition: compat.h:409
_In_ UINT _In_ UINT cEntries
Definition: wingdi.h:3598
HDC hdc
Definition: main.c:9
INT pixelformat
Definition: opengl32.h:97
#define ERROR_INVALID_PIXEL_FORMAT
Definition: winerror.h:1179
static struct wgl_dc_data * get_dc_data(HDC hdc)
Definition: wgl.c:92

◆ wglSetPixelFormat()

BOOL WINAPI wglSetPixelFormat ( HDC  hdc,
INT  format,
const PIXELFORMATDESCRIPTOR descr 
)

Definition at line 808 of file wgl.c.

809 {
810  struct wgl_dc_data* dc_data = get_dc_data(hdc);
811  INT sw_format;
812  BOOL ret;
813 
814  TRACE("HDC %p, format %i.\n", hdc, format);
815 
816  if(!dc_data)
817  {
818  WARN("Not a valid DC!.\n");
820  return FALSE;
821  }
822 
823  if(!format)
824  {
825  WARN("format == 0!\n");
827  return FALSE;
828  }
829 
830  if(dc_data->pixelformat)
831  {
832  TRACE("DC format already set, %i.\n", dc_data->pixelformat);
833  return (format == dc_data->pixelformat);
834  }
835 
837  {
838  TRACE("Calling ICD.\n");
839  ret = dc_data->icd_data->DrvSetPixelFormat(hdc, format);
840  if(ret)
841  {
842  TRACE("Success!\n");
843  dc_data->pixelformat = format;
844  }
845  return ret;
846  }
847 
848  sw_format = format - dc_data->nb_icd_formats;
849  if(sw_format <= dc_data->nb_sw_formats)
850  {
851  TRACE("Calling SW implementation.\n");
852  ret = sw_SetPixelFormat(hdc, dc_data, sw_format);
853  if(ret)
854  {
855  TRACE("Success!\n");
856  /* This is now officially a software-only HDC */
857  dc_data->icd_data = NULL;
858  dc_data->pixelformat = format;
859  }
860  return ret;
861  }
862 
863  TRACE("Invalid pixel format!\n");
865  return FALSE;
866 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define WARN(fmt,...)
Definition: debug.h:111
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
int32_t INT
Definition: typedefs.h:56
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
unsigned int BOOL
Definition: ntddk_ex.h:94
struct ICD_Data * icd_data
Definition: opengl32.h:100
smooth NULL
Definition: ftsmooth.c:416
INT nb_sw_formats
Definition: opengl32.h:104
BOOL sw_SetPixelFormat(HDC hdc, struct wgl_dc_data *, INT format)
Definition: swimpl.c:359
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
int ret
HDC hdc
Definition: main.c:9
INT pixelformat
Definition: opengl32.h:97
INT nb_icd_formats
Definition: opengl32.h:101
static struct wgl_dc_data * get_dc_data(HDC hdc)
Definition: wgl.c:92

◆ wglShareLists()

BOOL WINAPI wglShareLists ( HGLRC  hglrcSrc,
HGLRC  hglrcDst 
)

Definition at line 868 of file wgl.c.

869 {
870  struct wgl_context* ctx_src = get_context(hglrcSrc);
871  struct wgl_context* ctx_dst = get_context(hglrcDst);
872 
873  if(!ctx_src || !ctx_dst)
874  {
876  return FALSE;
877  }
878 
879  /* Check this is the same pixel format */
880  if((ctx_dst->icd_data != ctx_src->icd_data) ||
881  (ctx_dst->pixelformat != ctx_src->pixelformat))
882  {
884  return FALSE;
885  }
886 
887  if(ctx_src->icd_data)
888  return ctx_src->icd_data->DrvShareLists(ctx_src->dhglrc, ctx_dst->dhglrc);
889 
890  return sw_ShareLists(ctx_src->dhglrc, ctx_dst->dhglrc);
891 }
DHGLRC dhglrc
Definition: opengl32.h:78
BOOL sw_ShareLists(DHGLRC dhglrcSrc, DHGLRC dhglrcDst)
Definition: swimpl.c:504
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
struct ICD_Data * icd_data
Definition: opengl32.h:79
#define SetLastError(x)
Definition: compat.h:409
#define ERROR_INVALID_PIXEL_FORMAT
Definition: winerror.h:1179
struct wgl_context * get_context(HGLRC hglrc)
Definition: wgl.c:102
INT pixelformat
Definition: opengl32.h:80

Referenced by context_create(), and test_sharelists().

◆ wglSwapBuffers()

BOOL WINAPI DECLSPEC_HOTPATCH wglSwapBuffers ( HDC  hdc)

Definition at line 893 of file wgl.c.

894 {
895  struct wgl_dc_data* dc_data = get_dc_data(hdc);
896 
897  if(!dc_data)
898  {
900  return FALSE;
901  }
902 
903  if(!dc_data->pixelformat)
904  {
906  return FALSE;
907  }
908 
909  if(dc_data->icd_data)
910  return dc_data->icd_data->DrvSwapBuffers(hdc);
911 
912  return sw_SwapBuffers(hdc, dc_data);
913 }
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
BOOL sw_SwapBuffers(HDC hdc, struct wgl_dc_data *dc_data)
Definition: swimpl.c:1531
struct ICD_Data * icd_data
Definition: opengl32.h:100
#define SetLastError(x)
Definition: compat.h:409
HDC hdc
Definition: main.c:9
INT pixelformat
Definition: opengl32.h:97
#define ERROR_INVALID_PIXEL_FORMAT
Definition: winerror.h:1179
static struct wgl_dc_data * get_dc_data(HDC hdc)
Definition: wgl.c:92

◆ wglSwapLayerBuffers()

BOOL WINAPI wglSwapLayerBuffers ( HDC  hdc,
UINT  fuPlanes 
)

Definition at line 915 of file wgl.c.

916 {
917  return FALSE;
918 }

◆ wglSwapMultipleBuffers()

DWORD WINAPI wglSwapMultipleBuffers ( UINT  count,
CONST WGLSWAP *  toSwap 
)

Definition at line 920 of file wgl.c.

921 {
922  return 0;
923 }

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( wgl  )

Variable Documentation

◆ ContextListHead

LIST_ENTRY ContextListHead

Definition at line 17 of file wgl.c.

Referenced by DllMain(), IntDeleteAllContexts(), and wglCreateContext().

◆ dc_data_cs

CRITICAL_SECTION dc_data_cs = {NULL, -1, 0, 0, 0, 0}
static

Definition at line 14 of file wgl.c.

Referenced by get_dc_data_ex().

◆ dc_data_list

struct wgl_dc_data* dc_data_list = NULL
static

Definition at line 15 of file wgl.c.

Referenced by get_dc_data_ex().