context.h revision 9a33a11d714c90162d32781ebbd2c1dfab52cfd1
1/* $Id: context.h,v 1.29 2002/06/13 04:28:29 brianp Exp $ */
2
3/*
4 * Mesa 3-D graphics library
5 * Version:  4.1
6 *
7 * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27
28#ifndef CONTEXT_H
29#define CONTEXT_H
30
31
32#include "glapi.h"
33#include "mtypes.h"
34
35
36/*
37 * There are three Mesa datatypes which are meant to be used by device
38 * drivers:
39 *   GLcontext:  this contains the Mesa rendering state
40 *   GLvisual:  this describes the color buffer (rgb vs. ci), whether
41 *              or not there's a depth buffer, stencil buffer, etc.
42 *   GLframebuffer:  contains pointers to the depth buffer, stencil
43 *                   buffer, accum buffer and alpha buffers.
44 *
45 * These types should be encapsulated by corresponding device driver
46 * datatypes.  See xmesa.h and xmesaP.h for an example.
47 *
48 * In OOP terms, GLcontext, GLvisual, and GLframebuffer are base classes
49 * which the device driver must derive from.
50 *
51 * The following functions create and destroy these datatypes.
52 */
53
54
55/*
56 * Create/destroy a GLvisual.
57 */
58extern GLvisual *
59_mesa_create_visual( GLboolean rgbFlag,
60                     GLboolean dbFlag,
61                     GLboolean stereoFlag,
62                     GLint redBits,
63                     GLint greenBits,
64                     GLint blueBits,
65                     GLint alphaBits,
66                     GLint indexBits,
67                     GLint depthBits,
68                     GLint stencilBits,
69                     GLint accumRedBits,
70                     GLint accumGreenBits,
71                     GLint accumBlueBits,
72                     GLint accumAlphaBits,
73                     GLint numSamples );
74
75extern GLboolean
76_mesa_initialize_visual( GLvisual *v,
77                         GLboolean rgbFlag,
78                         GLboolean dbFlag,
79                         GLboolean stereoFlag,
80                         GLint redBits,
81                         GLint greenBits,
82                         GLint blueBits,
83                         GLint alphaBits,
84                         GLint indexBits,
85                         GLint depthBits,
86                         GLint stencilBits,
87                         GLint accumRedBits,
88                         GLint accumGreenBits,
89                         GLint accumBlueBits,
90                         GLint accumAlphaBits,
91                         GLint numSamples );
92
93extern void
94_mesa_destroy_visual( GLvisual *vis );
95
96
97
98/*
99 * Create/destroy a GLframebuffer.
100 */
101extern GLframebuffer *
102_mesa_create_framebuffer( const GLvisual *visual,
103                          GLboolean softwareDepth,
104                          GLboolean softwareStencil,
105                          GLboolean softwareAccum,
106                          GLboolean softwareAlpha );
107
108extern void
109_mesa_initialize_framebuffer( GLframebuffer *fb,
110                              const GLvisual *visual,
111                              GLboolean softwareDepth,
112                              GLboolean softwareStencil,
113                              GLboolean softwareAccum,
114                              GLboolean softwareAlpha );
115
116extern void
117_mesa_free_framebuffer_data( GLframebuffer *buffer );
118
119extern void
120_mesa_destroy_framebuffer( GLframebuffer *buffer );
121
122
123
124/*
125 * Create/destroy a GLcontext.
126 */
127extern GLcontext *
128_mesa_create_context( const GLvisual *visual,
129                      GLcontext *share_list,
130                      const __GLimports *imports );
131
132extern GLboolean
133_mesa_initialize_context( GLcontext *ctx,
134                          const GLvisual *visual,
135                          GLcontext *share_list,
136                          const __GLimports *imports );
137
138extern void
139_mesa_free_context_data( GLcontext *ctx );
140
141extern void
142_mesa_destroy_context( GLcontext *ctx );
143
144
145extern void
146_mesa_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask);
147
148
149extern void
150_mesa_make_current( GLcontext *ctx, GLframebuffer *buffer );
151
152
153extern void
154_mesa_make_current2( GLcontext *ctx, GLframebuffer *drawBuffer,
155                     GLframebuffer *readBuffer );
156
157
158extern GLcontext *
159_mesa_get_current_context(void);
160
161
162
163/*
164 * Macros for fetching current context.
165 */
166#ifdef THREADS
167
168#define GET_CURRENT_CONTEXT(C)	GLcontext *C = (GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context())
169
170#else
171
172#define GET_CURRENT_CONTEXT(C)  GLcontext *C = (GLcontext *) _glapi_Context
173
174#endif
175
176
177
178/* OpenGL SI-style export functions. */
179
180extern GLboolean
181_mesa_destroyContext(__GLcontext *gc);
182
183extern GLboolean
184_mesa_loseCurrent(__GLcontext *gc);
185
186extern GLboolean
187_mesa_makeCurrent(__GLcontext *gc);
188
189extern GLboolean
190_mesa_shareContext(__GLcontext *gc, __GLcontext *gcShare);
191
192extern GLboolean
193_mesa_copyContext(__GLcontext *dst, const __GLcontext *src, GLuint mask);
194
195extern GLboolean
196_mesa_forceCurrent(__GLcontext *gc);
197
198extern GLboolean
199_mesa_notifyResize(__GLcontext *gc);
200
201extern void
202_mesa_notifyDestroy(__GLcontext *gc);
203
204extern void
205_mesa_notifySwapBuffers(__GLcontext *gc);
206
207extern void
208_mesa_dispatchExec(__GLcontext *gc);
209
210extern void
211_mesa_beginDispatchOverride(__GLcontext *gc);
212
213extern void
214_mesa_endDispatchOverride(__GLcontext *gc);
215
216
217
218
219extern void
220_mesa_swapbuffers(GLcontext *ctx);
221
222extern struct _glapi_table *
223_mesa_get_dispatch(GLcontext *ctx);
224
225
226
227/*
228 * Miscellaneous
229 */
230
231extern void
232_mesa_problem( const GLcontext *ctx, const char *s );
233
234extern void
235_mesa_warning( const GLcontext *ctx, const char *s );
236
237extern void
238_mesa_error( GLcontext *ctx, GLenum error, const char *s );
239
240#ifdef DEBUG
241extern void
242_mesa_debug( const char *fmtString, ... );
243#endif
244
245extern void
246_mesa_Finish( void );
247
248extern void
249_mesa_Flush( void );
250
251
252#endif
253