| Brian Paul | 5fb84d2 | 2000-05-24 15:04:45 +0000 | [diff] [blame] | 1 | /* $Id: context.h,v 1.18 2000/05/24 15:04:45 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 |
| jtg | afb833d | 1999-08-19 00:55:39 +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. |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 8 | * |
| 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 | |
| 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" |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 33 | #include "types.h" |
| 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 | /* this function is obsolete */ |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 96 | extern GLvisual * |
| 97 | gl_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 ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 109 | |
| Brian Paul | b371e0d | 2000-03-31 01:05:51 +0000 | [diff] [blame] | 110 | |
| 111 | extern void |
| 112 | _mesa_destroy_visual( GLvisual *vis ); |
| 113 | |
| 114 | /*obsolete */ extern void gl_destroy_visual( GLvisual *vis ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 115 | |
| 116 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 117 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 118 | /* |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 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 |
| 121 | * single entity. |
| 122 | */ |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 123 | extern GLframebuffer * |
| 124 | gl_create_framebuffer( GLvisual *visual, |
| 125 | GLboolean softwareDepth, |
| 126 | GLboolean softwareStencil, |
| 127 | GLboolean softwareAccum, |
| 128 | GLboolean softwareAlpha ); |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 129 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 130 | extern void |
| 131 | _mesa_initialize_framebuffer( GLframebuffer *fb, |
| 132 | GLvisual *visual, |
| 133 | GLboolean softwareDepth, |
| 134 | GLboolean softwareStencil, |
| 135 | GLboolean softwareAccum, |
| 136 | GLboolean softwareAlpha ); |
| 137 | |
| 138 | extern void |
| 139 | gl_destroy_framebuffer( GLframebuffer *buffer ); |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 140 | |
| 141 | |
| 142 | |
| 143 | /* |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 144 | * Create/destroy a GLcontext. A GLcontext is like a GLX context. It |
| 145 | * contains the rendering state. |
| 146 | */ |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 147 | extern GLcontext * |
| 148 | gl_create_context( GLvisual *visual, |
| 149 | GLcontext *share_list, |
| 150 | void *driver_ctx, |
| 151 | GLboolean direct); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 152 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 153 | extern GLboolean |
| 154 | _mesa_initialize_context( GLcontext *ctx, |
| 155 | GLvisual *visual, |
| 156 | GLcontext *share_list, |
| 157 | void *driver_ctx, |
| 158 | GLboolean direct ); |
| Brian Paul | 4d053dd | 2000-01-14 04:45:47 +0000 | [diff] [blame] | 159 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 160 | extern void |
| 161 | gl_free_context_data( GLcontext *ctx ); |
| Brian Paul | 4d053dd | 2000-01-14 04:45:47 +0000 | [diff] [blame] | 162 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 163 | extern void |
| 164 | gl_destroy_context( GLcontext *ctx ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 165 | |
| Brian Paul | 4d053dd | 2000-01-14 04:45:47 +0000 | [diff] [blame] | 166 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 167 | extern void |
| 168 | gl_context_initialize( GLcontext *ctx ); |
| 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 | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 171 | extern void |
| 172 | gl_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask); |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 173 | |
| 174 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 175 | extern void |
| 176 | gl_make_current( GLcontext *ctx, GLframebuffer *buffer ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 177 | |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 178 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 179 | extern void |
| 180 | gl_make_current2( GLcontext *ctx, GLframebuffer *drawBuffer, |
| 181 | GLframebuffer *readBuffer ); |
| Brian Paul | 3f02f90 | 1999-11-24 18:48:30 +0000 | [diff] [blame] | 182 | |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 183 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 184 | extern GLcontext * |
| 185 | gl_get_current_context(void); |
| 186 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 187 | |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 188 | |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 189 | /* |
| 190 | * Macros for fetching current context, input buffer, etc. |
| 191 | */ |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 192 | #ifdef THREADS |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 193 | |
| Brian Paul | f9b97d9 | 2000-01-28 20:17:42 +0000 | [diff] [blame] | 194 | #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] | 195 | |
| Brian Paul | f9b97d9 | 2000-01-28 20:17:42 +0000 | [diff] [blame] | 196 | #define GET_IMMEDIATE struct immediate *IM = ((GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context()))->input |
| Brian Paul | 26e14d2 | 2000-01-05 04:36:17 +0000 | [diff] [blame] | 197 | |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 198 | #define SET_IMMEDIATE(ctx, im) \ |
| 199 | do { \ |
| 200 | ctx->input = im; \ |
| 201 | } while (0) |
| 202 | |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 203 | #else |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 204 | |
| Brian Paul | 5666c63 | 2000-01-18 17:36:16 +0000 | [diff] [blame] | 205 | extern struct immediate *_mesa_CurrentInput; |
| Brian Paul | 26e14d2 | 2000-01-05 04:36:17 +0000 | [diff] [blame] | 206 | |
| Brian Paul | 959f802 | 2000-03-19 01:10:11 +0000 | [diff] [blame] | 207 | #define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_Context |
| Brian Paul | 26e14d2 | 2000-01-05 04:36:17 +0000 | [diff] [blame] | 208 | |
| Brian Paul | 5666c63 | 2000-01-18 17:36:16 +0000 | [diff] [blame] | 209 | #define GET_IMMEDIATE struct immediate *IM = _mesa_CurrentInput |
| Brian Paul | 26e14d2 | 2000-01-05 04:36:17 +0000 | [diff] [blame] | 210 | |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 211 | #define SET_IMMEDIATE(ctx, im) \ |
| 212 | do { \ |
| 213 | ctx->input = im; \ |
| Brian Paul | 5666c63 | 2000-01-18 17:36:16 +0000 | [diff] [blame] | 214 | _mesa_CurrentInput = im; \ |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 215 | } while (0) |
| 216 | |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 217 | #endif |
| 218 | |
| 219 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 220 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 221 | extern void |
| 222 | _mesa_swapbuffers(GLcontext *ctx); |
| 223 | |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 224 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 225 | extern struct _glapi_table * |
| 226 | _mesa_get_dispatch(GLcontext *ctx); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 227 | |
| 228 | |
| 229 | |
| 230 | /* |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 231 | * Miscellaneous |
| 232 | */ |
| 233 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 234 | extern void |
| 235 | gl_problem( const GLcontext *ctx, const char *s ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 236 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 237 | extern void |
| 238 | gl_warning( const GLcontext *ctx, const char *s ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 239 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 240 | extern void |
| 241 | gl_error( GLcontext *ctx, GLenum error, const char *s ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 242 | |
| Brian Paul | 178a1c5 | 2000-04-22 01:05:00 +0000 | [diff] [blame] | 243 | extern void |
| 244 | gl_compile_error( GLcontext *ctx, GLenum error, const char *s ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 245 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 246 | |
| 247 | |
| Brian Paul | fa9df40 | 2000-02-02 19:16:46 +0000 | [diff] [blame] | 248 | extern void |
| 249 | _mesa_Finish( void ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 250 | |
| Brian Paul | fa9df40 | 2000-02-02 19:16:46 +0000 | [diff] [blame] | 251 | extern void |
| 252 | _mesa_Flush( void ); |
| 253 | |
| 254 | |
| 255 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 256 | #endif |