| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame^] | 1 | /* $Id: context.h,v 1.24 2001/03/03 20:33:27 brianp Exp $ */ |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 2 | |
| 3 | /* |
| 4 | * Mesa 3-D graphics library |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 5 | * Version: 3.3 |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 6 | * |
| Brian Paul | 5666c63 | 2000-01-18 17:36:16 +0000 | [diff] [blame] | 7 | * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 8 | * |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 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: |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 15 | * |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 16 | * The above copyright notice and this permission notice shall be included |
| 17 | * in all copies or substantial portions of the Software. |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 18 | * |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 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 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 28 | #ifndef CONTEXT_H |
| 29 | #define CONTEXT_H |
| 30 | |
| 31 | |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 32 | #include "glapi.h" |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 33 | #include "mtypes.h" |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 34 | |
| 35 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 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 | */ |
| Brian Paul | b371e0d | 2000-03-31 01:05:51 +0000 | [diff] [blame] | 60 | extern GLvisual * |
| 61 | _mesa_create_visual( GLboolean rgbFlag, |
| Brian Paul | b371e0d | 2000-03-31 01:05:51 +0000 | [diff] [blame] | 62 | 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 Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 77 | extern GLboolean |
| 78 | _mesa_initialize_visual( GLvisual *v, |
| 79 | GLboolean rgbFlag, |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 80 | 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 Paul | b371e0d | 2000-03-31 01:05:51 +0000 | [diff] [blame] | 95 | extern void |
| 96 | _mesa_destroy_visual( GLvisual *vis ); |
| 97 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 98 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 99 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 100 | /* |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 101 | * 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 Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 105 | extern GLframebuffer * |
| Brian Paul | be3602d | 2001-02-28 00:27:48 +0000 | [diff] [blame] | 106 | _mesa_create_framebuffer( const GLvisual *visual, |
| Brian Paul | b1394fa | 2000-09-26 20:53:53 +0000 | [diff] [blame] | 107 | GLboolean softwareDepth, |
| 108 | GLboolean softwareStencil, |
| 109 | GLboolean softwareAccum, |
| 110 | GLboolean softwareAlpha ); |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 111 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 112 | extern void |
| 113 | _mesa_initialize_framebuffer( GLframebuffer *fb, |
| Brian Paul | be3602d | 2001-02-28 00:27:48 +0000 | [diff] [blame] | 114 | const GLvisual *visual, |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 115 | GLboolean softwareDepth, |
| 116 | GLboolean softwareStencil, |
| 117 | GLboolean softwareAccum, |
| 118 | GLboolean softwareAlpha ); |
| 119 | |
| 120 | extern void |
| Brian Paul | b1394fa | 2000-09-26 20:53:53 +0000 | [diff] [blame] | 121 | _mesa_destroy_framebuffer( GLframebuffer *buffer ); |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 122 | |
| 123 | |
| 124 | |
| 125 | /* |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 126 | * Create/destroy a GLcontext. A GLcontext is like a GLX context. It |
| 127 | * contains the rendering state. |
| 128 | */ |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 129 | extern GLcontext * |
| Brian Paul | be3602d | 2001-02-28 00:27:48 +0000 | [diff] [blame] | 130 | _mesa_create_context( const GLvisual *visual, |
| Brian Paul | b1394fa | 2000-09-26 20:53:53 +0000 | [diff] [blame] | 131 | GLcontext *share_list, |
| 132 | void *driver_ctx, |
| 133 | GLboolean direct); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 134 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 135 | extern GLboolean |
| 136 | _mesa_initialize_context( GLcontext *ctx, |
| Brian Paul | be3602d | 2001-02-28 00:27:48 +0000 | [diff] [blame] | 137 | const GLvisual *visual, |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 138 | GLcontext *share_list, |
| 139 | void *driver_ctx, |
| 140 | GLboolean direct ); |
| Brian Paul | 4d053dd | 2000-01-14 04:45:47 +0000 | [diff] [blame] | 141 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 142 | extern void |
| Brian Paul | b1394fa | 2000-09-26 20:53:53 +0000 | [diff] [blame] | 143 | _mesa_free_context_data( GLcontext *ctx ); |
| Brian Paul | 4d053dd | 2000-01-14 04:45:47 +0000 | [diff] [blame] | 144 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 145 | extern void |
| Brian Paul | b1394fa | 2000-09-26 20:53:53 +0000 | [diff] [blame] | 146 | _mesa_destroy_context( GLcontext *ctx ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 147 | |
| Brian Paul | 4d053dd | 2000-01-14 04:45:47 +0000 | [diff] [blame] | 148 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 149 | extern void |
| Brian Paul | b1394fa | 2000-09-26 20:53:53 +0000 | [diff] [blame] | 150 | _mesa_context_initialize( GLcontext *ctx ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 151 | |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 152 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 153 | extern void |
| Brian Paul | b1394fa | 2000-09-26 20:53:53 +0000 | [diff] [blame] | 154 | _mesa_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask); |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 155 | |
| 156 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 157 | extern void |
| Brian Paul | b1394fa | 2000-09-26 20:53:53 +0000 | [diff] [blame] | 158 | _mesa_make_current( GLcontext *ctx, GLframebuffer *buffer ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 159 | |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 160 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 161 | extern void |
| Brian Paul | b1394fa | 2000-09-26 20:53:53 +0000 | [diff] [blame] | 162 | _mesa_make_current2( GLcontext *ctx, GLframebuffer *drawBuffer, |
| Brian Paul | be3602d | 2001-02-28 00:27:48 +0000 | [diff] [blame] | 163 | GLframebuffer *readBuffer ); |
| Brian Paul | 3f02f90 | 1999-11-24 18:48:30 +0000 | [diff] [blame] | 164 | |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 165 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 166 | extern GLcontext * |
| Brian Paul | b1394fa | 2000-09-26 20:53:53 +0000 | [diff] [blame] | 167 | _mesa_get_current_context(void); |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 168 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 169 | |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 170 | |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 171 | /* |
| Keith Whitwell | 23caf20 | 2000-11-16 21:05:34 +0000 | [diff] [blame] | 172 | * Macros for fetching current context. |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 173 | */ |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 174 | #ifdef THREADS |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 175 | |
| Brian Paul | f9b97d9 | 2000-01-28 20:17:42 +0000 | [diff] [blame] | 176 | #define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context()) |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 177 | |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 178 | #else |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 179 | |
| Brian Paul | 959f802 | 2000-03-19 01:10:11 +0000 | [diff] [blame] | 180 | #define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_Context |
| Brian Paul | 26e14d2 | 2000-01-05 04:36:17 +0000 | [diff] [blame] | 181 | |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 182 | #endif |
| 183 | |
| 184 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 185 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 186 | extern void |
| 187 | _mesa_swapbuffers(GLcontext *ctx); |
| 188 | |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 189 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 190 | extern struct _glapi_table * |
| 191 | _mesa_get_dispatch(GLcontext *ctx); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 192 | |
| 193 | |
| 194 | |
| 195 | /* |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 196 | * Miscellaneous |
| 197 | */ |
| 198 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 199 | extern void |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame^] | 200 | _mesa_problem( const GLcontext *ctx, const char *s ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 201 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 202 | extern void |
| Brian Paul | b1394fa | 2000-09-26 20:53:53 +0000 | [diff] [blame] | 203 | _mesa_warning( const GLcontext *ctx, const char *s ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 204 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 205 | extern void |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame^] | 206 | _mesa_error( GLcontext *ctx, GLenum error, const char *s ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 207 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 208 | extern void |
| Brian Paul | b1394fa | 2000-09-26 20:53:53 +0000 | [diff] [blame] | 209 | _mesa_compile_error( GLcontext *ctx, GLenum error, const char *s ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 210 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 211 | |
| 212 | |
| Brian Paul | fa9df40 | 2000-02-02 19:16:46 +0000 | [diff] [blame] | 213 | extern void |
| 214 | _mesa_Finish( void ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 215 | |
| Brian Paul | fa9df40 | 2000-02-02 19:16:46 +0000 | [diff] [blame] | 216 | extern void |
| 217 | _mesa_Flush( void ); |
| 218 | |
| 219 | |
| 220 | |
| Brian Paul | 699bc7b | 2000-10-29 18:12:14 +0000 | [diff] [blame] | 221 | extern void |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame^] | 222 | _mesa_read_config_file(GLcontext *ctx); |
| Brian Paul | 699bc7b | 2000-10-29 18:12:14 +0000 | [diff] [blame] | 223 | |
| 224 | extern void |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame^] | 225 | _mesa_register_config_var(const char *name, |
| 226 | void (*notify)( const char *, int )); |
| Brian Paul | 699bc7b | 2000-10-29 18:12:14 +0000 | [diff] [blame] | 227 | |
| 228 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 229 | #endif |