blob: 8345f9e70fc77cea9f0b500f5630a2803f726676 [file] [log] [blame]
Brian Paulb1394fa2000-09-26 20:53:53 +00001/* $Id: context.h,v 1.19 2000/09/26 20:53:53 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 +000095extern void
96_mesa_destroy_visual( GLvisual *vis );
97
jtgafb833d1999-08-19 00:55:39 +000098
Brian Paul178a1c52000-04-22 01:05:00 +000099
jtgafb833d1999-08-19 00:55:39 +0000100/*
Brian Paul00037781999-12-17 14:52:35 +0000101 * Create/destroy a GLframebuffer. A GLframebuffer is like a GLX drawable.
102 * It bundles up the depth buffer, stencil buffer and accum buffers into a
103 * single entity.
104 */
Brian Paul178a1c52000-04-22 01:05:00 +0000105extern GLframebuffer *
Brian Paulb1394fa2000-09-26 20:53:53 +0000106_mesa_create_framebuffer( GLvisual *visual,
107 GLboolean softwareDepth,
108 GLboolean softwareStencil,
109 GLboolean softwareAccum,
110 GLboolean softwareAlpha );
Brian Paul00037781999-12-17 14:52:35 +0000111
Brian Paul178a1c52000-04-22 01:05:00 +0000112extern void
113_mesa_initialize_framebuffer( GLframebuffer *fb,
114 GLvisual *visual,
115 GLboolean softwareDepth,
116 GLboolean softwareStencil,
117 GLboolean softwareAccum,
118 GLboolean softwareAlpha );
119
120extern void
Brian Paulb1394fa2000-09-26 20:53:53 +0000121_mesa_destroy_framebuffer( GLframebuffer *buffer );
Brian Paul00037781999-12-17 14:52:35 +0000122
123
124
125/*
jtgafb833d1999-08-19 00:55:39 +0000126 * Create/destroy a GLcontext. A GLcontext is like a GLX context. It
127 * contains the rendering state.
128 */
Brian Paul178a1c52000-04-22 01:05:00 +0000129extern GLcontext *
Brian Paulb1394fa2000-09-26 20:53:53 +0000130_mesa_create_context( GLvisual *visual,
131 GLcontext *share_list,
132 void *driver_ctx,
133 GLboolean direct);
jtgafb833d1999-08-19 00:55:39 +0000134
Brian Paul178a1c52000-04-22 01:05:00 +0000135extern GLboolean
136_mesa_initialize_context( GLcontext *ctx,
137 GLvisual *visual,
138 GLcontext *share_list,
139 void *driver_ctx,
140 GLboolean direct );
Brian Paul4d053dd2000-01-14 04:45:47 +0000141
Brian Paul178a1c52000-04-22 01:05:00 +0000142extern void
Brian Paulb1394fa2000-09-26 20:53:53 +0000143_mesa_free_context_data( GLcontext *ctx );
Brian Paul4d053dd2000-01-14 04:45:47 +0000144
Brian Paul178a1c52000-04-22 01:05:00 +0000145extern void
Brian Paulb1394fa2000-09-26 20:53:53 +0000146_mesa_destroy_context( GLcontext *ctx );
jtgafb833d1999-08-19 00:55:39 +0000147
Brian Paul4d053dd2000-01-14 04:45:47 +0000148
Brian Paul178a1c52000-04-22 01:05:00 +0000149extern void
Brian Paulb1394fa2000-09-26 20:53:53 +0000150_mesa_context_initialize( GLcontext *ctx );
jtgafb833d1999-08-19 00:55:39 +0000151
Brian Paul04986821999-11-19 22:26:52 +0000152
Brian Paul178a1c52000-04-22 01:05:00 +0000153extern void
Brian Paulb1394fa2000-09-26 20:53:53 +0000154_mesa_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask);
Brian Paul04986821999-11-19 22:26:52 +0000155
156
Brian Paul178a1c52000-04-22 01:05:00 +0000157extern void
Brian Paulb1394fa2000-09-26 20:53:53 +0000158_mesa_make_current( GLcontext *ctx, GLframebuffer *buffer );
jtgafb833d1999-08-19 00:55:39 +0000159
Brian Paul00037781999-12-17 14:52:35 +0000160
Brian Paul178a1c52000-04-22 01:05:00 +0000161extern void
Brian Paulb1394fa2000-09-26 20:53:53 +0000162_mesa_make_current2( GLcontext *ctx, GLframebuffer *drawBuffer,
Brian Paul178a1c52000-04-22 01:05:00 +0000163 GLframebuffer *readBuffer );
Brian Paul3f02f901999-11-24 18:48:30 +0000164
Brian Paul00037781999-12-17 14:52:35 +0000165
Brian Paul178a1c52000-04-22 01:05:00 +0000166extern GLcontext *
Brian Paulb1394fa2000-09-26 20:53:53 +0000167_mesa_get_current_context(void);
Brian Paul178a1c52000-04-22 01:05:00 +0000168
jtgafb833d1999-08-19 00:55:39 +0000169
Brian Paul04986821999-11-19 22:26:52 +0000170
Brian Paul00037781999-12-17 14:52:35 +0000171/*
172 * Macros for fetching current context, input buffer, etc.
173 */
Brian Paul04986821999-11-19 22:26:52 +0000174#ifdef THREADS
Brian Paul04986821999-11-19 22:26:52 +0000175
Brian Paulf9b97d92000-01-28 20:17:42 +0000176#define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context())
Brian Paul00037781999-12-17 14:52:35 +0000177
Brian Paulf9b97d92000-01-28 20:17:42 +0000178#define GET_IMMEDIATE struct immediate *IM = ((GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context()))->input
Brian Paul26e14d22000-01-05 04:36:17 +0000179
Brian Paul04986821999-11-19 22:26:52 +0000180#define SET_IMMEDIATE(ctx, im) \
181do { \
182 ctx->input = im; \
183} while (0)
184
Brian Paul04986821999-11-19 22:26:52 +0000185#else
Brian Paul04986821999-11-19 22:26:52 +0000186
Brian Paul5666c632000-01-18 17:36:16 +0000187extern struct immediate *_mesa_CurrentInput;
Brian Paul26e14d22000-01-05 04:36:17 +0000188
Brian Paul959f8022000-03-19 01:10:11 +0000189#define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_Context
Brian Paul26e14d22000-01-05 04:36:17 +0000190
Brian Paul5666c632000-01-18 17:36:16 +0000191#define GET_IMMEDIATE struct immediate *IM = _mesa_CurrentInput
Brian Paul26e14d22000-01-05 04:36:17 +0000192
Brian Paul04986821999-11-19 22:26:52 +0000193#define SET_IMMEDIATE(ctx, im) \
194do { \
195 ctx->input = im; \
Brian Paul5666c632000-01-18 17:36:16 +0000196 _mesa_CurrentInput = im; \
Brian Paul04986821999-11-19 22:26:52 +0000197} while (0)
198
Brian Paul04986821999-11-19 22:26:52 +0000199#endif
200
201
jtgafb833d1999-08-19 00:55:39 +0000202
Brian Paulfbd8f211999-11-11 01:22:25 +0000203extern void
204_mesa_swapbuffers(GLcontext *ctx);
205
Brian Paul00037781999-12-17 14:52:35 +0000206
Brian Paulfbd8f211999-11-11 01:22:25 +0000207extern struct _glapi_table *
208_mesa_get_dispatch(GLcontext *ctx);
jtgafb833d1999-08-19 00:55:39 +0000209
210
211
212/*
jtgafb833d1999-08-19 00:55:39 +0000213 * Miscellaneous
214 */
215
Brian Paul178a1c52000-04-22 01:05:00 +0000216extern void
217gl_problem( const GLcontext *ctx, const char *s );
jtgafb833d1999-08-19 00:55:39 +0000218
Brian Paul178a1c52000-04-22 01:05:00 +0000219extern void
Brian Paulb1394fa2000-09-26 20:53:53 +0000220_mesa_warning( const GLcontext *ctx, const char *s );
jtgafb833d1999-08-19 00:55:39 +0000221
Brian Paul178a1c52000-04-22 01:05:00 +0000222extern void
223gl_error( GLcontext *ctx, GLenum error, const char *s );
jtgafb833d1999-08-19 00:55:39 +0000224
Brian Paul178a1c52000-04-22 01:05:00 +0000225extern void
Brian Paulb1394fa2000-09-26 20:53:53 +0000226_mesa_compile_error( GLcontext *ctx, GLenum error, const char *s );
jtgafb833d1999-08-19 00:55:39 +0000227
jtgafb833d1999-08-19 00:55:39 +0000228
229
Brian Paulfa9df402000-02-02 19:16:46 +0000230extern void
231_mesa_Finish( void );
jtgafb833d1999-08-19 00:55:39 +0000232
Brian Paulfa9df402000-02-02 19:16:46 +0000233extern void
234_mesa_Flush( void );
235
236
237
jtgafb833d1999-08-19 00:55:39 +0000238#endif