blob: 284f15e078edf50547f3193ef223ae5ae56eceab [file] [log] [blame]
Brian Paul5fb84d22000-05-24 15:04:45 +00001/* $Id: context.h,v 1.18 2000/05/24 15:04:45 brianp Exp $ */
jtgafb833d1999-08-19 00:55:39 +00002
3/*
4 * Mesa 3-D graphics library
Brian Paulfbd8f211999-11-11 01:22:25 +00005 * Version: 3.3
jtgafb833d1999-08-19 00:55:39 +00006 *
Brian Paul5666c632000-01-18 17:36:16 +00007 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
jtgafb833d1999-08-19 00:55:39 +00008 *
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
jtgafb833d1999-08-19 00:55:39 +000028#ifndef CONTEXT_H
29#define CONTEXT_H
30
31
Brian Paul00037781999-12-17 14:52:35 +000032#include "glapi.h"
jtgafb833d1999-08-19 00:55:39 +000033#include "types.h"
34
35
jtgafb833d1999-08-19 00:55:39 +000036/*
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 */
Brian Paulb371e0d2000-03-31 01:05:51 +000060extern GLvisual *
61_mesa_create_visual( GLboolean rgbFlag,
Brian Paulb371e0d2000-03-31 01:05:51 +000062 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
Brian Paul178a1c52000-04-22 01:05:00 +000077extern GLboolean
78_mesa_initialize_visual( GLvisual *v,
79 GLboolean rgbFlag,
Brian Paul178a1c52000-04-22 01:05:00 +000080 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
Brian Paulb371e0d2000-03-31 01:05:51 +000095/* this function is obsolete */
Brian Paul178a1c52000-04-22 01:05:00 +000096extern GLvisual *
97gl_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 );
jtgafb833d1999-08-19 00:55:39 +0000109
Brian Paulb371e0d2000-03-31 01:05:51 +0000110
111extern void
112_mesa_destroy_visual( GLvisual *vis );
113
114/*obsolete */ extern void gl_destroy_visual( GLvisual *vis );
jtgafb833d1999-08-19 00:55:39 +0000115
116
Brian Paul178a1c52000-04-22 01:05:00 +0000117
jtgafb833d1999-08-19 00:55:39 +0000118/*
Brian Paul00037781999-12-17 14:52:35 +0000119 * 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 */
Brian Paul178a1c52000-04-22 01:05:00 +0000123extern GLframebuffer *
124gl_create_framebuffer( GLvisual *visual,
125 GLboolean softwareDepth,
126 GLboolean softwareStencil,
127 GLboolean softwareAccum,
128 GLboolean softwareAlpha );
Brian Paul00037781999-12-17 14:52:35 +0000129
Brian Paul178a1c52000-04-22 01:05:00 +0000130extern void
131_mesa_initialize_framebuffer( GLframebuffer *fb,
132 GLvisual *visual,
133 GLboolean softwareDepth,
134 GLboolean softwareStencil,
135 GLboolean softwareAccum,
136 GLboolean softwareAlpha );
137
138extern void
139gl_destroy_framebuffer( GLframebuffer *buffer );
Brian Paul00037781999-12-17 14:52:35 +0000140
141
142
143/*
jtgafb833d1999-08-19 00:55:39 +0000144 * Create/destroy a GLcontext. A GLcontext is like a GLX context. It
145 * contains the rendering state.
146 */
Brian Paul178a1c52000-04-22 01:05:00 +0000147extern GLcontext *
148gl_create_context( GLvisual *visual,
149 GLcontext *share_list,
150 void *driver_ctx,
151 GLboolean direct);
jtgafb833d1999-08-19 00:55:39 +0000152
Brian Paul178a1c52000-04-22 01:05:00 +0000153extern GLboolean
154_mesa_initialize_context( GLcontext *ctx,
155 GLvisual *visual,
156 GLcontext *share_list,
157 void *driver_ctx,
158 GLboolean direct );
Brian Paul4d053dd2000-01-14 04:45:47 +0000159
Brian Paul178a1c52000-04-22 01:05:00 +0000160extern void
161gl_free_context_data( GLcontext *ctx );
Brian Paul4d053dd2000-01-14 04:45:47 +0000162
Brian Paul178a1c52000-04-22 01:05:00 +0000163extern void
164gl_destroy_context( GLcontext *ctx );
jtgafb833d1999-08-19 00:55:39 +0000165
Brian Paul4d053dd2000-01-14 04:45:47 +0000166
Brian Paul178a1c52000-04-22 01:05:00 +0000167extern void
168gl_context_initialize( GLcontext *ctx );
jtgafb833d1999-08-19 00:55:39 +0000169
Brian Paul04986821999-11-19 22:26:52 +0000170
Brian Paul178a1c52000-04-22 01:05:00 +0000171extern void
172gl_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask);
Brian Paul04986821999-11-19 22:26:52 +0000173
174
Brian Paul178a1c52000-04-22 01:05:00 +0000175extern void
176gl_make_current( GLcontext *ctx, GLframebuffer *buffer );
jtgafb833d1999-08-19 00:55:39 +0000177
Brian Paul00037781999-12-17 14:52:35 +0000178
Brian Paul178a1c52000-04-22 01:05:00 +0000179extern void
180gl_make_current2( GLcontext *ctx, GLframebuffer *drawBuffer,
181 GLframebuffer *readBuffer );
Brian Paul3f02f901999-11-24 18:48:30 +0000182
Brian Paul00037781999-12-17 14:52:35 +0000183
Brian Paul178a1c52000-04-22 01:05:00 +0000184extern GLcontext *
185gl_get_current_context(void);
186
jtgafb833d1999-08-19 00:55:39 +0000187
Brian Paul04986821999-11-19 22:26:52 +0000188
Brian Paul00037781999-12-17 14:52:35 +0000189/*
190 * Macros for fetching current context, input buffer, etc.
191 */
Brian Paul04986821999-11-19 22:26:52 +0000192#ifdef THREADS
Brian Paul04986821999-11-19 22:26:52 +0000193
Brian Paulf9b97d92000-01-28 20:17:42 +0000194#define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context())
Brian Paul00037781999-12-17 14:52:35 +0000195
Brian Paulf9b97d92000-01-28 20:17:42 +0000196#define GET_IMMEDIATE struct immediate *IM = ((GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context()))->input
Brian Paul26e14d22000-01-05 04:36:17 +0000197
Brian Paul04986821999-11-19 22:26:52 +0000198#define SET_IMMEDIATE(ctx, im) \
199do { \
200 ctx->input = im; \
201} while (0)
202
Brian Paul04986821999-11-19 22:26:52 +0000203#else
Brian Paul04986821999-11-19 22:26:52 +0000204
Brian Paul5666c632000-01-18 17:36:16 +0000205extern struct immediate *_mesa_CurrentInput;
Brian Paul26e14d22000-01-05 04:36:17 +0000206
Brian Paul959f8022000-03-19 01:10:11 +0000207#define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_Context
Brian Paul26e14d22000-01-05 04:36:17 +0000208
Brian Paul5666c632000-01-18 17:36:16 +0000209#define GET_IMMEDIATE struct immediate *IM = _mesa_CurrentInput
Brian Paul26e14d22000-01-05 04:36:17 +0000210
Brian Paul04986821999-11-19 22:26:52 +0000211#define SET_IMMEDIATE(ctx, im) \
212do { \
213 ctx->input = im; \
Brian Paul5666c632000-01-18 17:36:16 +0000214 _mesa_CurrentInput = im; \
Brian Paul04986821999-11-19 22:26:52 +0000215} while (0)
216
Brian Paul04986821999-11-19 22:26:52 +0000217#endif
218
219
jtgafb833d1999-08-19 00:55:39 +0000220
Brian Paulfbd8f211999-11-11 01:22:25 +0000221extern void
222_mesa_swapbuffers(GLcontext *ctx);
223
Brian Paul00037781999-12-17 14:52:35 +0000224
Brian Paulfbd8f211999-11-11 01:22:25 +0000225extern struct _glapi_table *
226_mesa_get_dispatch(GLcontext *ctx);
jtgafb833d1999-08-19 00:55:39 +0000227
228
229
230/*
jtgafb833d1999-08-19 00:55:39 +0000231 * Miscellaneous
232 */
233
Brian Paul178a1c52000-04-22 01:05:00 +0000234extern void
235gl_problem( const GLcontext *ctx, const char *s );
jtgafb833d1999-08-19 00:55:39 +0000236
Brian Paul178a1c52000-04-22 01:05:00 +0000237extern void
238gl_warning( const GLcontext *ctx, const char *s );
jtgafb833d1999-08-19 00:55:39 +0000239
Brian Paul178a1c52000-04-22 01:05:00 +0000240extern void
241gl_error( GLcontext *ctx, GLenum error, const char *s );
jtgafb833d1999-08-19 00:55:39 +0000242
Brian Paul178a1c52000-04-22 01:05:00 +0000243extern void
244gl_compile_error( GLcontext *ctx, GLenum error, const char *s );
jtgafb833d1999-08-19 00:55:39 +0000245
jtgafb833d1999-08-19 00:55:39 +0000246
247
Brian Paulfa9df402000-02-02 19:16:46 +0000248extern void
249_mesa_Finish( void );
jtgafb833d1999-08-19 00:55:39 +0000250
Brian Paulfa9df402000-02-02 19:16:46 +0000251extern void
252_mesa_Flush( void );
253
254
255
jtgafb833d1999-08-19 00:55:39 +0000256#endif