osmesa_context.h 3.78 KB
Newer Older
Camilla Berglund's avatar
Camilla Berglund committed
1
2
3
4
//========================================================================
// GLFW 3.3 OSMesa - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2016 Google Inc.
Camilla Löwy's avatar
Camilla Löwy committed
5
// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
Camilla Berglund's avatar
Camilla Berglund committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
//    claim that you wrote the original software. If you use this software
//    in a product, an acknowledgment in the product documentation would
//    be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
//    be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
//    distribution.
//
//========================================================================
Jason Daly's avatar
Jason Daly committed
27
28
29
30

#ifndef _glfw3_osmesa_context_h_
#define _glfw3_osmesa_context_h_

Camilla Berglund's avatar
Camilla Berglund committed
31
32
33
34
35
36
37
38
39
40
#define OSMESA_RGBA 0x1908
#define OSMESA_FORMAT 0x22
#define OSMESA_DEPTH_BITS 0x30
#define OSMESA_STENCIL_BITS 0x31
#define OSMESA_ACCUM_BITS 0x32
#define OSMESA_PROFILE 0x33
#define OSMESA_CORE_PROFILE 0x34
#define OSMESA_COMPAT_PROFILE 0x35
#define OSMESA_CONTEXT_MAJOR_VERSION 0x36
#define OSMESA_CONTEXT_MINOR_VERSION 0x37
Jason Daly's avatar
Jason Daly committed
41
42
43
44

typedef void* OSMesaContext;
typedef void (*OSMESAproc)();

45
46
47
48
49
50
51
typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextExt)(GLenum,GLint,GLint,GLint,OSMesaContext);
typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextAttribs)(const int*,OSMesaContext);
typedef void (GLAPIENTRY * PFN_OSMesaDestroyContext)(OSMesaContext);
typedef int (GLAPIENTRY * PFN_OSMesaMakeCurrent)(OSMesaContext,void*,int,int,int);
typedef int (GLAPIENTRY * PFN_OSMesaGetColorBuffer)(OSMesaContext,int*,int*,int*,void**);
typedef int (GLAPIENTRY * PFN_OSMesaGetDepthBuffer)(OSMesaContext,int*,int*,int*,void**);
typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*);
52
#define OSMesaCreateContextExt _glfw.osmesa.CreateContextExt
Camilla Berglund's avatar
Camilla Berglund committed
53
#define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs
Jason Daly's avatar
Jason Daly committed
54
55
56
57
58
59
#define OSMesaDestroyContext _glfw.osmesa.DestroyContext
#define OSMesaMakeCurrent _glfw.osmesa.MakeCurrent
#define OSMesaGetColorBuffer _glfw.osmesa.GetColorBuffer
#define OSMesaGetDepthBuffer _glfw.osmesa.GetDepthBuffer
#define OSMesaGetProcAddress _glfw.osmesa.GetProcAddress

Camilla Berglund's avatar
Camilla Berglund committed
60
61
#define _GLFW_PLATFORM_CONTEXT_STATE            _GLFWcontextOSMesa osmesa
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE    _GLFWlibraryOSMesa osmesa
Jason Daly's avatar
Jason Daly committed
62
63
64
65
66
67


// OSMesa-specific per-context data
//
typedef struct _GLFWcontextOSMesa
{
68
69
70
71
    OSMesaContext       handle;
    int                 width;
    int                 height;
    void*               buffer;
Jason Daly's avatar
Jason Daly committed
72
73
74
75
76

} _GLFWcontextOSMesa;

// OSMesa-specific global data
//
Camilla Berglund's avatar
Camilla Berglund committed
77
typedef struct _GLFWlibraryOSMesa
Jason Daly's avatar
Jason Daly committed
78
79
80
{
    void*           handle;

81
82
83
84
85
86
87
    PFN_OSMesaCreateContextExt      CreateContextExt;
    PFN_OSMesaCreateContextAttribs  CreateContextAttribs;
    PFN_OSMesaDestroyContext        DestroyContext;
    PFN_OSMesaMakeCurrent           MakeCurrent;
    PFN_OSMesaGetColorBuffer        GetColorBuffer;
    PFN_OSMesaGetDepthBuffer        GetDepthBuffer;
    PFN_OSMesaGetProcAddress        GetProcAddress;
Jason Daly's avatar
Jason Daly committed
88

Camilla Berglund's avatar
Camilla Berglund committed
89
} _GLFWlibraryOSMesa;
Jason Daly's avatar
Jason Daly committed
90
91
92
93
94
95
96
97
98


GLFWbool _glfwInitOSMesa(void);
void _glfwTerminateOSMesa(void);
GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
                                  const _GLFWctxconfig* ctxconfig,
                                  const _GLFWfbconfig* fbconfig);

#endif // _glfw3_osmesa_context_h_