blob: 792862c02700f8456f0d1e91dcb1c77e25b600bd [file] [log] [blame]
Brian Paul08836342001-03-03 20:33:27 +00001/* $Id: context.h,v 1.24 2001/03/03 20:33:27 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
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00006 *
Brian Paul5666c632000-01-18 17:36:16 +00007 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00008 *
jtgafb833d1999-08-19 00:55:39 +00009 * 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:
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000015 *
jtgafb833d1999-08-19 00:55:39 +000016 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000018 *
jtgafb833d1999-08-19 00:55:39 +000019 * 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"
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000033#include "mtypes.h"
jtgafb833d1999-08-19 00:55:39 +000034
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 Paulbe3602d2001-02-28 00:27:48 +0000106_mesa_create_framebuffer( const GLvisual *visual,
Brian Paulb1394fa2000-09-26 20:53:53 +0000107 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,
Brian Paulbe3602d2001-02-28 00:27:48 +0000114 const GLvisual *visual,
Brian Paul178a1c52000-04-22 01:05:00 +0000115 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 Paulbe3602d2001-02-28 00:27:48 +0000130_mesa_create_context( const GLvisual *visual,
Brian Paulb1394fa2000-09-26 20:53:53 +0000131 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,
Brian Paulbe3602d2001-02-28 00:27:48 +0000137 const GLvisual *visual,
Brian Paul178a1c52000-04-22 01:05:00 +0000138 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 Paulbe3602d2001-02-28 00:27:48 +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/*
Keith Whitwell23caf202000-11-16 21:05:34 +0000172 * Macros for fetching current context.
Brian Paul00037781999-12-17 14:52:35 +0000173 */
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 Paul04986821999-11-19 22:26:52 +0000178#else
Brian Paul04986821999-11-19 22:26:52 +0000179
Brian Paul959f8022000-03-19 01:10:11 +0000180#define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_Context
Brian Paul26e14d22000-01-05 04:36:17 +0000181
Brian Paul04986821999-11-19 22:26:52 +0000182#endif
183
184
jtgafb833d1999-08-19 00:55:39 +0000185
Brian Paulfbd8f211999-11-11 01:22:25 +0000186extern void
187_mesa_swapbuffers(GLcontext *ctx);
188
Brian Paul00037781999-12-17 14:52:35 +0000189
Brian Paulfbd8f211999-11-11 01:22:25 +0000190extern struct _glapi_table *
191_mesa_get_dispatch(GLcontext *ctx);
jtgafb833d1999-08-19 00:55:39 +0000192
193
194
195/*
jtgafb833d1999-08-19 00:55:39 +0000196 * Miscellaneous
197 */
198
Brian Paul178a1c52000-04-22 01:05:00 +0000199extern void
Brian Paul08836342001-03-03 20:33:27 +0000200_mesa_problem( const GLcontext *ctx, const char *s );
jtgafb833d1999-08-19 00:55:39 +0000201
Brian Paul178a1c52000-04-22 01:05:00 +0000202extern void
Brian Paulb1394fa2000-09-26 20:53:53 +0000203_mesa_warning( const GLcontext *ctx, const char *s );
jtgafb833d1999-08-19 00:55:39 +0000204
Brian Paul178a1c52000-04-22 01:05:00 +0000205extern void
Brian Paul08836342001-03-03 20:33:27 +0000206_mesa_error( GLcontext *ctx, GLenum error, const char *s );
jtgafb833d1999-08-19 00:55:39 +0000207
Brian Paul178a1c52000-04-22 01:05:00 +0000208extern void
Brian Paulb1394fa2000-09-26 20:53:53 +0000209_mesa_compile_error( GLcontext *ctx, GLenum error, const char *s );
jtgafb833d1999-08-19 00:55:39 +0000210
jtgafb833d1999-08-19 00:55:39 +0000211
212
Brian Paulfa9df402000-02-02 19:16:46 +0000213extern void
214_mesa_Finish( void );
jtgafb833d1999-08-19 00:55:39 +0000215
Brian Paulfa9df402000-02-02 19:16:46 +0000216extern void
217_mesa_Flush( void );
218
219
220
Brian Paul699bc7b2000-10-29 18:12:14 +0000221extern void
Brian Paul08836342001-03-03 20:33:27 +0000222_mesa_read_config_file(GLcontext *ctx);
Brian Paul699bc7b2000-10-29 18:12:14 +0000223
224extern void
Brian Paul08836342001-03-03 20:33:27 +0000225_mesa_register_config_var(const char *name,
226 void (*notify)( const char *, int ));
Brian Paul699bc7b2000-10-29 18:12:14 +0000227
228
jtgafb833d1999-08-19 00:55:39 +0000229#endif