| Brian Paul | fa9df40 | 2000-02-02 19:16:46 +0000 | [diff] [blame^] | 1 | /* $Id: context.h,v 1.13 2000/02/02 19:16:46 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 | */ |
| 60 | extern GLvisual *gl_create_visual( GLboolean rgbFlag, |
| 61 | GLboolean alphaFlag, |
| 62 | GLboolean dbFlag, |
| 63 | GLboolean stereoFlag, |
| 64 | GLint depthBits, |
| 65 | GLint stencilBits, |
| 66 | GLint accumBits, |
| 67 | GLint indexBits, |
| 68 | GLint redBits, |
| 69 | GLint greenBits, |
| 70 | GLint blueBits, |
| 71 | GLint alphaBits ); |
| 72 | |
| 73 | extern void gl_destroy_visual( GLvisual *vis ); |
| 74 | |
| 75 | |
| 76 | /* |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 77 | * Create/destroy a GLframebuffer. A GLframebuffer is like a GLX drawable. |
| 78 | * It bundles up the depth buffer, stencil buffer and accum buffers into a |
| 79 | * single entity. |
| 80 | */ |
| 81 | extern GLframebuffer *gl_create_framebuffer( GLvisual *visual, |
| 82 | GLboolean softwareDepth, |
| 83 | GLboolean softwareStencil, |
| 84 | GLboolean softwareAccum, |
| 85 | GLboolean softwareAlpha ); |
| 86 | |
| 87 | extern void gl_destroy_framebuffer( GLframebuffer *buffer ); |
| 88 | |
| 89 | |
| 90 | |
| 91 | /* |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 92 | * Create/destroy a GLcontext. A GLcontext is like a GLX context. It |
| 93 | * contains the rendering state. |
| 94 | */ |
| 95 | extern GLcontext *gl_create_context( GLvisual *visual, |
| 96 | GLcontext *share_list, |
| 97 | void *driver_ctx, |
| 98 | GLboolean direct); |
| 99 | |
| Brian Paul | 4d053dd | 2000-01-14 04:45:47 +0000 | [diff] [blame] | 100 | extern GLboolean gl_initialize_context_data( GLcontext *ctx, |
| 101 | GLvisual *visual, |
| 102 | GLcontext *share_list, |
| 103 | void *driver_ctx, |
| 104 | GLboolean direct ); |
| 105 | |
| 106 | extern void gl_free_context_data( GLcontext *ctx ); |
| 107 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 108 | extern void gl_destroy_context( GLcontext *ctx ); |
| 109 | |
| Brian Paul | 4d053dd | 2000-01-14 04:45:47 +0000 | [diff] [blame] | 110 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 111 | extern void gl_context_initialize( GLcontext *ctx ); |
| 112 | |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 113 | |
| 114 | extern void gl_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask); |
| 115 | |
| 116 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 117 | extern void gl_make_current( GLcontext *ctx, GLframebuffer *buffer ); |
| 118 | |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 119 | |
| Brian Paul | 3f02f90 | 1999-11-24 18:48:30 +0000 | [diff] [blame] | 120 | extern void gl_make_current2( GLcontext *ctx, GLframebuffer *drawBuffer, |
| 121 | GLframebuffer *readBuffer ); |
| 122 | |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 123 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 124 | extern GLcontext *gl_get_current_context(void); |
| 125 | |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 126 | |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 127 | /* |
| 128 | * Macros for fetching current context, input buffer, etc. |
| 129 | */ |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 130 | #ifdef THREADS |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 131 | |
| Brian Paul | f9b97d9 | 2000-01-28 20:17:42 +0000 | [diff] [blame] | 132 | #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] | 133 | |
| Brian Paul | f9b97d9 | 2000-01-28 20:17:42 +0000 | [diff] [blame] | 134 | #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] | 135 | |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 136 | #define SET_IMMEDIATE(ctx, im) \ |
| 137 | do { \ |
| 138 | ctx->input = im; \ |
| 139 | } while (0) |
| 140 | |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 141 | #else |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 142 | |
| Brian Paul | 5666c63 | 2000-01-18 17:36:16 +0000 | [diff] [blame] | 143 | extern struct immediate *_mesa_CurrentInput; |
| Brian Paul | 26e14d2 | 2000-01-05 04:36:17 +0000 | [diff] [blame] | 144 | |
| Brian Paul | f9b97d9 | 2000-01-28 20:17:42 +0000 | [diff] [blame] | 145 | #define GET_CURRENT_CONTEXT(C) GLcontext *C = _glapi_Context |
| Brian Paul | 26e14d2 | 2000-01-05 04:36:17 +0000 | [diff] [blame] | 146 | |
| Brian Paul | 5666c63 | 2000-01-18 17:36:16 +0000 | [diff] [blame] | 147 | #define GET_IMMEDIATE struct immediate *IM = _mesa_CurrentInput |
| Brian Paul | 26e14d2 | 2000-01-05 04:36:17 +0000 | [diff] [blame] | 148 | |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 149 | #define SET_IMMEDIATE(ctx, im) \ |
| 150 | do { \ |
| 151 | ctx->input = im; \ |
| Brian Paul | 5666c63 | 2000-01-18 17:36:16 +0000 | [diff] [blame] | 152 | _mesa_CurrentInput = im; \ |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 153 | } while (0) |
| 154 | |
| Brian Paul | 0498682 | 1999-11-19 22:26:52 +0000 | [diff] [blame] | 155 | #endif |
| 156 | |
| 157 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 158 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 159 | extern void |
| 160 | _mesa_swapbuffers(GLcontext *ctx); |
| 161 | |
| Brian Paul | 0003778 | 1999-12-17 14:52:35 +0000 | [diff] [blame] | 162 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 163 | extern struct _glapi_table * |
| 164 | _mesa_get_dispatch(GLcontext *ctx); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 165 | |
| 166 | |
| 167 | |
| 168 | /* |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 169 | * Miscellaneous |
| 170 | */ |
| 171 | |
| 172 | extern void gl_problem( const GLcontext *ctx, const char *s ); |
| 173 | |
| 174 | extern void gl_warning( const GLcontext *ctx, const char *s ); |
| 175 | |
| 176 | extern void gl_error( GLcontext *ctx, GLenum error, const char *s ); |
| 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 | extern void gl_compile_error( GLcontext *ctx, GLenum error, const char *s ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 179 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 180 | |
| 181 | |
| Brian Paul | fa9df40 | 2000-02-02 19:16:46 +0000 | [diff] [blame^] | 182 | extern void |
| 183 | _mesa_Finish( void ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 184 | |
| Brian Paul | fa9df40 | 2000-02-02 19:16:46 +0000 | [diff] [blame^] | 185 | extern void |
| 186 | _mesa_Flush( void ); |
| 187 | |
| 188 | |
| 189 | |
| 190 | extern void |
| 191 | _mesa_init_no_op_table(struct _glapi_table *exec); |
| 192 | |
| 193 | extern void |
| 194 | _mesa_init_exec_table(struct _glapi_table *exec); |
| 195 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 196 | |
| 197 | |
| 198 | #ifdef PROFILE |
| 199 | extern GLdouble gl_time( void ); |
| 200 | #endif |
| 201 | |
| 202 | |
| 203 | #endif |