added Window-isms previously in gl.h
[mesa.git] / src / mesa / main / context.h
1 /* $Id: context.h,v 1.17 2000/05/04 13:53:55 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.3
6 *
7 * Copyright (C) 1999-2000 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 "types.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. A GLvisual is like a GLX visual. It describes
57 * the colorbuffer, depth buffer, stencil buffer and accum buffer which will
58 * be used by the GL context and framebuffer.
59 */
60 extern GLvisual *
61 _mesa_create_visual( GLboolean rgbFlag,
62 GLboolean dbFlag,
63 GLboolean stereoFlag,
64 GLint redBits,
65 GLint greenBits,
66 GLint blueBits,
67 GLint alphaBits,
68 GLint indexBits,
69 GLint depthBits,
70 GLint stencilBits,
71 GLint accumRedBits,
72 GLint accumGreenBits,
73 GLint accumBlueBits,
74 GLint accumAlphaBits,
75 GLint numSamples );
76
77 extern GLboolean
78 _mesa_initialize_visual( GLvisual *v,
79 GLboolean rgbFlag,
80 GLboolean dbFlag,
81 GLboolean stereoFlag,
82 GLint redBits,
83 GLint greenBits,
84 GLint blueBits,
85 GLint alphaBits,
86 GLint indexBits,
87 GLint depthBits,
88 GLint stencilBits,
89 GLint accumRedBits,
90 GLint accumGreenBits,
91 GLint accumBlueBits,
92 GLint accumAlphaBits,
93 GLint numSamples );
94
95 /* this function is obsolete */
96 extern GLvisual *
97 gl_create_visual( GLboolean rgbFlag,
98 GLboolean alphaFlag,
99 GLboolean dbFlag,
100 GLboolean stereoFlag,
101 GLint depthBits,
102 GLint stencilBits,
103 GLint accumBits,
104 GLint indexBits,
105 GLint redBits,
106 GLint greenBits,
107 GLint blueBits,
108 GLint alphaBits );
109
110
111 extern void
112 _mesa_destroy_visual( GLvisual *vis );
113
114 /*obsolete */ extern void gl_destroy_visual( GLvisual *vis );
115
116
117
118 /*
119 * Create/destroy a GLframebuffer. A GLframebuffer is like a GLX drawable.
120 * It bundles up the depth buffer, stencil buffer and accum buffers into a
121 * single entity.
122 */
123 extern GLframebuffer *
124 gl_create_framebuffer( GLvisual *visual,
125 GLboolean softwareDepth,
126 GLboolean softwareStencil,
127 GLboolean softwareAccum,
128 GLboolean softwareAlpha );
129
130 extern void
131 _mesa_initialize_framebuffer( GLframebuffer *fb,
132 GLvisual *visual,
133 GLboolean softwareDepth,
134 GLboolean softwareStencil,
135 GLboolean softwareAccum,
136 GLboolean softwareAlpha );
137
138 extern void
139 gl_destroy_framebuffer( GLframebuffer *buffer );
140
141
142
143 /*
144 * Create/destroy a GLcontext. A GLcontext is like a GLX context. It
145 * contains the rendering state.
146 */
147 extern GLcontext *
148 gl_create_context( GLvisual *visual,
149 GLcontext *share_list,
150 void *driver_ctx,
151 GLboolean direct);
152
153 extern GLboolean
154 _mesa_initialize_context( GLcontext *ctx,
155 GLvisual *visual,
156 GLcontext *share_list,
157 void *driver_ctx,
158 GLboolean direct );
159
160 extern void
161 gl_free_context_data( GLcontext *ctx );
162
163 extern void
164 gl_destroy_context( GLcontext *ctx );
165
166
167 extern void
168 gl_context_initialize( GLcontext *ctx );
169
170
171 extern void
172 gl_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask);
173
174
175 extern void
176 gl_make_current( GLcontext *ctx, GLframebuffer *buffer );
177
178
179 extern void
180 gl_make_current2( GLcontext *ctx, GLframebuffer *drawBuffer,
181 GLframebuffer *readBuffer );
182
183
184 extern GLcontext *
185 gl_get_current_context(void);
186
187
188
189 /*
190 * Macros for fetching current context, input buffer, etc.
191 */
192 #ifdef THREADS
193
194 #define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context())
195
196 #define GET_IMMEDIATE struct immediate *IM = ((GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context()))->input
197
198 #define SET_IMMEDIATE(ctx, im) \
199 do { \
200 ctx->input = im; \
201 } while (0)
202
203 #else
204
205 extern struct immediate *_mesa_CurrentInput;
206
207 #define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_Context
208
209 #define GET_IMMEDIATE struct immediate *IM = _mesa_CurrentInput
210
211 #define SET_IMMEDIATE(ctx, im) \
212 do { \
213 ctx->input = im; \
214 _mesa_CurrentInput = im; \
215 } while (0)
216
217 #endif
218
219
220
221 extern void
222 _mesa_swapbuffers(GLcontext *ctx);
223
224
225 extern struct _glapi_table *
226 _mesa_get_dispatch(GLcontext *ctx);
227
228
229
230 /*
231 * Miscellaneous
232 */
233
234 extern void
235 gl_problem( const GLcontext *ctx, const char *s );
236
237 extern void
238 gl_warning( const GLcontext *ctx, const char *s );
239
240 extern void
241 gl_error( GLcontext *ctx, GLenum error, const char *s );
242
243 extern void
244 gl_compile_error( GLcontext *ctx, GLenum error, const char *s );
245
246
247
248 extern void
249 _mesa_Finish( void );
250
251 extern void
252 _mesa_Flush( void );
253
254
255
256 extern void
257 _mesa_init_no_op_table(struct _glapi_table *exec);
258
259 extern void
260 _mesa_init_exec_table(struct _glapi_table *exec);
261
262
263 #endif