work on GL_SGI_color_table
[mesa.git] / src / mesa / main / context.h
1 /* $Id: context.h,v 1.15 2000/03/31 01:05:51 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 alphaFlag,
63 GLboolean dbFlag,
64 GLboolean stereoFlag,
65 GLint redBits,
66 GLint greenBits,
67 GLint blueBits,
68 GLint alphaBits,
69 GLint indexBits,
70 GLint depthBits,
71 GLint stencilBits,
72 GLint accumRedBits,
73 GLint accumGreenBits,
74 GLint accumBlueBits,
75 GLint accumAlphaBits,
76 GLint numSamples );
77
78 /* this function is obsolete */
79 extern GLvisual *gl_create_visual( GLboolean rgbFlag,
80 GLboolean alphaFlag,
81 GLboolean dbFlag,
82 GLboolean stereoFlag,
83 GLint depthBits,
84 GLint stencilBits,
85 GLint accumBits,
86 GLint indexBits,
87 GLint redBits,
88 GLint greenBits,
89 GLint blueBits,
90 GLint alphaBits );
91
92
93 extern void
94 _mesa_destroy_visual( GLvisual *vis );
95
96 /*obsolete */ extern void gl_destroy_visual( GLvisual *vis );
97
98
99 /*
100 * Create/destroy a GLframebuffer. A GLframebuffer is like a GLX drawable.
101 * It bundles up the depth buffer, stencil buffer and accum buffers into a
102 * single entity.
103 */
104 extern GLframebuffer *gl_create_framebuffer( GLvisual *visual,
105 GLboolean softwareDepth,
106 GLboolean softwareStencil,
107 GLboolean softwareAccum,
108 GLboolean softwareAlpha );
109
110 extern void gl_destroy_framebuffer( GLframebuffer *buffer );
111
112
113
114 /*
115 * Create/destroy a GLcontext. A GLcontext is like a GLX context. It
116 * contains the rendering state.
117 */
118 extern GLcontext *gl_create_context( GLvisual *visual,
119 GLcontext *share_list,
120 void *driver_ctx,
121 GLboolean direct);
122
123 extern GLboolean gl_initialize_context_data( GLcontext *ctx,
124 GLvisual *visual,
125 GLcontext *share_list,
126 void *driver_ctx,
127 GLboolean direct );
128
129 extern void gl_free_context_data( GLcontext *ctx );
130
131 extern void gl_destroy_context( GLcontext *ctx );
132
133
134 extern void gl_context_initialize( GLcontext *ctx );
135
136
137 extern void gl_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask);
138
139
140 extern void gl_make_current( GLcontext *ctx, GLframebuffer *buffer );
141
142
143 extern void gl_make_current2( GLcontext *ctx, GLframebuffer *drawBuffer,
144 GLframebuffer *readBuffer );
145
146
147 extern GLcontext *gl_get_current_context(void);
148
149
150 /*
151 * Macros for fetching current context, input buffer, etc.
152 */
153 #ifdef THREADS
154
155 #define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context())
156
157 #define GET_IMMEDIATE struct immediate *IM = ((GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context()))->input
158
159 #define SET_IMMEDIATE(ctx, im) \
160 do { \
161 ctx->input = im; \
162 } while (0)
163
164 #else
165
166 extern struct immediate *_mesa_CurrentInput;
167
168 #define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_Context
169
170 #define GET_IMMEDIATE struct immediate *IM = _mesa_CurrentInput
171
172 #define SET_IMMEDIATE(ctx, im) \
173 do { \
174 ctx->input = im; \
175 _mesa_CurrentInput = im; \
176 } while (0)
177
178 #endif
179
180
181
182 extern void
183 _mesa_swapbuffers(GLcontext *ctx);
184
185
186 extern struct _glapi_table *
187 _mesa_get_dispatch(GLcontext *ctx);
188
189
190
191 /*
192 * Miscellaneous
193 */
194
195 extern void gl_problem( const GLcontext *ctx, const char *s );
196
197 extern void gl_warning( const GLcontext *ctx, const char *s );
198
199 extern void gl_error( GLcontext *ctx, GLenum error, const char *s );
200
201 extern void gl_compile_error( GLcontext *ctx, GLenum error, const char *s );
202
203
204
205 extern void
206 _mesa_Finish( void );
207
208 extern void
209 _mesa_Flush( void );
210
211
212
213 extern void
214 _mesa_init_no_op_table(struct _glapi_table *exec);
215
216 extern void
217 _mesa_init_exec_table(struct _glapi_table *exec);
218
219
220
221 #ifdef PROFILE
222 extern GLdouble gl_time( void );
223 #endif
224
225
226 #endif