1 /* $Id: context.h,v 1.18 2000/05/24 15:04:45 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
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.
37 * There are three Mesa datatypes which are meant to be used by device
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.
45 * These types should be encapsulated by corresponding device driver
46 * datatypes. See xmesa.h and xmesaP.h for an example.
48 * In OOP terms, GLcontext, GLvisual, and GLframebuffer are base classes
49 * which the device driver must derive from.
51 * The following functions create and destroy these datatypes.
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.
61 _mesa_create_visual( GLboolean rgbFlag
,
78 _mesa_initialize_visual( GLvisual
*v
,
95 /* this function is obsolete */
97 gl_create_visual( GLboolean rgbFlag
,
100 GLboolean stereoFlag
,
112 _mesa_destroy_visual( GLvisual
*vis
);
114 /*obsolete */ extern void gl_destroy_visual( GLvisual
*vis
);
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
123 extern GLframebuffer
*
124 gl_create_framebuffer( GLvisual
*visual
,
125 GLboolean softwareDepth
,
126 GLboolean softwareStencil
,
127 GLboolean softwareAccum
,
128 GLboolean softwareAlpha
);
131 _mesa_initialize_framebuffer( GLframebuffer
*fb
,
133 GLboolean softwareDepth
,
134 GLboolean softwareStencil
,
135 GLboolean softwareAccum
,
136 GLboolean softwareAlpha
);
139 gl_destroy_framebuffer( GLframebuffer
*buffer
);
144 * Create/destroy a GLcontext. A GLcontext is like a GLX context. It
145 * contains the rendering state.
148 gl_create_context( GLvisual
*visual
,
149 GLcontext
*share_list
,
154 _mesa_initialize_context( GLcontext
*ctx
,
156 GLcontext
*share_list
,
161 gl_free_context_data( GLcontext
*ctx
);
164 gl_destroy_context( GLcontext
*ctx
);
168 gl_context_initialize( GLcontext
*ctx
);
172 gl_copy_context(const GLcontext
*src
, GLcontext
*dst
, GLuint mask
);
176 gl_make_current( GLcontext
*ctx
, GLframebuffer
*buffer
);
180 gl_make_current2( GLcontext
*ctx
, GLframebuffer
*drawBuffer
,
181 GLframebuffer
*readBuffer
);
185 gl_get_current_context(void);
190 * Macros for fetching current context, input buffer, etc.
194 #define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context())
196 #define GET_IMMEDIATE struct immediate *IM = ((GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context()))->input
198 #define SET_IMMEDIATE(ctx, im) \
205 extern struct immediate
*_mesa_CurrentInput
;
207 #define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_Context
209 #define GET_IMMEDIATE struct immediate *IM = _mesa_CurrentInput
211 #define SET_IMMEDIATE(ctx, im) \
214 _mesa_CurrentInput = im; \
222 _mesa_swapbuffers(GLcontext
*ctx
);
225 extern struct _glapi_table
*
226 _mesa_get_dispatch(GLcontext
*ctx
);
235 gl_problem( const GLcontext
*ctx
, const char *s
);
238 gl_warning( const GLcontext
*ctx
, const char *s
);
241 gl_error( GLcontext
*ctx
, GLenum error
, const char *s
);
244 gl_compile_error( GLcontext
*ctx
, GLenum error
, const char *s
);
249 _mesa_Finish( void );