1/*
2 * Copyright © 2014 Jon TURNEY
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24#ifndef indirect_h
25#define indirect_h
26
27#include <X11/Xwindows.h>
28#include <GL/wglext.h>
29#include <glx/extension_string.h>
30
31/* ---------------------------------------------------------------------- */
32/*
33 *   structure definitions
34 */
35
36typedef struct __GLXWinContext __GLXWinContext;
37typedef struct __GLXWinDrawable __GLXWinDrawable;
38typedef struct __GLXWinScreen glxWinScreen;
39typedef struct __GLXWinConfig GLXWinConfig;
40
41struct __GLXWinContext {
42    __GLXcontext base;
43    HGLRC ctx;                  /* Windows GL Context */
44    __GLXWinContext *shareContext;      /* Context with which we will share display lists and textures */
45    HWND hwnd;                  /* For detecting when HWND has changed */
46};
47
48struct __GLXWinDrawable {
49    __GLXdrawable base;
50    __GLXWinContext *drawContext;
51    __GLXWinContext *readContext;
52
53    /* If this drawable is GLX_DRAWABLE_PBUFFER */
54    HPBUFFERARB hPbuffer;
55
56    /* If this drawable is GLX_DRAWABLE_PIXMAP */
57    HDC dibDC;
58    HANDLE hSection;            /* file mapping handle */
59    HBITMAP hDIB;
60    HBITMAP hOldDIB;            /* original DIB for DC */
61    void *pOldBits;             /* original pBits for this drawable's pixmap */
62};
63
64struct __GLXWinScreen {
65    __GLXscreen base;
66
67    Bool has_WGL_ARB_multisample;
68    Bool has_WGL_ARB_pixel_format;
69    Bool has_WGL_ARB_pbuffer;
70    Bool has_WGL_ARB_render_texture;
71    Bool has_WGL_ARB_make_current_read;
72    Bool has_WGL_ARB_framebuffer_sRGB;
73
74    /* wrapped screen functions */
75    RealizeWindowProcPtr RealizeWindow;
76    UnrealizeWindowProcPtr UnrealizeWindow;
77    CopyWindowProcPtr CopyWindow;
78};
79
80struct __GLXWinConfig {
81    __GLXconfig base;
82    int pixelFormatIndex;
83};
84
85/* ---------------------------------------------------------------------- */
86/*
87 *   function prototypes
88 */
89
90void
91glxWinDeferredCreateDrawable(__GLXWinDrawable *draw, __GLXconfig *config);
92
93#endif /* indirect_h */
94