| 1 | /* $Id: context.h,v 1.4 2000-05-21 20:26:33 jeroen Exp $ */ | 
|---|
| 2 |  | 
|---|
| 3 | /* | 
|---|
| 4 | * Mesa 3-D graphics library | 
|---|
| 5 | * Version:  3.3 | 
|---|
| 6 | * | 
|---|
| 7 | * Copyright (C) 1999  Brian Paul   All Rights Reserved. | 
|---|
| 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 |  | 
|---|
| 28 |  | 
|---|
| 29 |  | 
|---|
| 30 |  | 
|---|
| 31 | #ifndef CONTEXT_H | 
|---|
| 32 | #define CONTEXT_H | 
|---|
| 33 |  | 
|---|
| 34 |  | 
|---|
| 35 | #include "types.h" | 
|---|
| 36 | #include "glapi.h" | 
|---|
| 37 |  | 
|---|
| 38 | /* | 
|---|
| 39 | * There are three Mesa datatypes which are meant to be used by device | 
|---|
| 40 | * drivers: | 
|---|
| 41 | *   GLcontext:  this contains the Mesa rendering state | 
|---|
| 42 | *   GLvisual:  this describes the color buffer (rgb vs. ci), whether | 
|---|
| 43 | *              or not there's a depth buffer, stencil buffer, etc. | 
|---|
| 44 | *   GLframebuffer:  contains pointers to the depth buffer, stencil | 
|---|
| 45 | *                   buffer, accum buffer and alpha buffers. | 
|---|
| 46 | * | 
|---|
| 47 | * These types should be encapsulated by corresponding device driver | 
|---|
| 48 | * datatypes.  See xmesa.h and xmesaP.h for an example. | 
|---|
| 49 | * | 
|---|
| 50 | * In OOP terms, GLcontext, GLvisual, and GLframebuffer are base classes | 
|---|
| 51 | * which the device driver must derive from. | 
|---|
| 52 | * | 
|---|
| 53 | * The following functions create and destroy these datatypes. | 
|---|
| 54 | */ | 
|---|
| 55 |  | 
|---|
| 56 |  | 
|---|
| 57 | /* | 
|---|
| 58 | * Create/destroy a GLvisual.  A GLvisual is like a GLX visual.  It describes | 
|---|
| 59 | * the colorbuffer, depth buffer, stencil buffer and accum buffer which will | 
|---|
| 60 | * be used by the GL context and framebuffer. | 
|---|
| 61 | */ | 
|---|
| 62 | extern GLvisual *gl_create_visual( GLboolean rgbFlag, | 
|---|
| 63 | GLboolean alphaFlag, | 
|---|
| 64 | GLboolean dbFlag, | 
|---|
| 65 | GLboolean stereoFlag, | 
|---|
| 66 | GLint depthBits, | 
|---|
| 67 | GLint stencilBits, | 
|---|
| 68 | GLint accumBits, | 
|---|
| 69 | GLint indexBits, | 
|---|
| 70 | GLint redBits, | 
|---|
| 71 | GLint greenBits, | 
|---|
| 72 | GLint blueBits, | 
|---|
| 73 | GLint alphaBits ); | 
|---|
| 74 |  | 
|---|
| 75 | extern void gl_destroy_visual( GLvisual *vis ); | 
|---|
| 76 |  | 
|---|
| 77 |  | 
|---|
| 78 | /* | 
|---|
| 79 | * Create/destroy a GLframebuffer.  A GLframebuffer is like a GLX drawable. | 
|---|
| 80 | * It bundles up the depth buffer, stencil buffer and accum buffers into a | 
|---|
| 81 | * single entity. | 
|---|
| 82 | */ | 
|---|
| 83 | extern GLframebuffer *gl_create_framebuffer( GLvisual *visual, | 
|---|
| 84 | GLboolean softwareDepth, | 
|---|
| 85 | GLboolean softwareStencil, | 
|---|
| 86 | GLboolean softwareAccum, | 
|---|
| 87 | GLboolean softwareAlpha ); | 
|---|
| 88 |  | 
|---|
| 89 | extern void gl_destroy_framebuffer( GLframebuffer *buffer ); | 
|---|
| 90 |  | 
|---|
| 91 |  | 
|---|
| 92 |  | 
|---|
| 93 | /* | 
|---|
| 94 | * Create/destroy a GLcontext.  A GLcontext is like a GLX context.  It | 
|---|
| 95 | * contains the rendering state. | 
|---|
| 96 | */ | 
|---|
| 97 | extern GLcontext *gl_create_context( GLvisual *visual, | 
|---|
| 98 | GLcontext *share_list, | 
|---|
| 99 | void *driver_ctx, | 
|---|
| 100 | GLboolean direct); | 
|---|
| 101 |  | 
|---|
| 102 | extern GLboolean gl_initialize_context_data( GLcontext *ctx, | 
|---|
| 103 | GLvisual *visual, | 
|---|
| 104 | GLcontext *share_list, | 
|---|
| 105 | void *driver_ctx, | 
|---|
| 106 | GLboolean direct ); | 
|---|
| 107 |  | 
|---|
| 108 | extern void gl_free_context_data( GLcontext *ctx ); | 
|---|
| 109 |  | 
|---|
| 110 | extern void gl_destroy_context( GLcontext *ctx ); | 
|---|
| 111 |  | 
|---|
| 112 |  | 
|---|
| 113 | extern void gl_context_initialize( GLcontext *ctx ); | 
|---|
| 114 |  | 
|---|
| 115 |  | 
|---|
| 116 | extern void gl_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask); | 
|---|
| 117 |  | 
|---|
| 118 |  | 
|---|
| 119 | extern void gl_make_current( GLcontext *ctx, GLframebuffer *buffer ); | 
|---|
| 120 |  | 
|---|
| 121 |  | 
|---|
| 122 | extern void gl_make_current2( GLcontext *ctx, GLframebuffer *drawBuffer, | 
|---|
| 123 | GLframebuffer *readBuffer ); | 
|---|
| 124 |  | 
|---|
| 125 |  | 
|---|
| 126 | extern GLcontext *gl_get_current_context(void); | 
|---|
| 127 |  | 
|---|
| 128 |  | 
|---|
| 129 | /* | 
|---|
| 130 | * Macros for fetching current context, input buffer, etc. | 
|---|
| 131 | */ | 
|---|
| 132 | #ifdef THREADS | 
|---|
| 133 |  | 
|---|
| 134 | #define GET_CURRENT_CONTEXT(C)  GLcontext *C = (GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context()) | 
|---|
| 135 |  | 
|---|
| 136 | #define GET_IMMEDIATE  struct immediate *IM = ((GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context()))->input | 
|---|
| 137 |  | 
|---|
| 138 | #define SET_IMMEDIATE(ctx, im)          \ | 
|---|
| 139 | do {                                    \ | 
|---|
| 140 | ctx->input = im;                     \ | 
|---|
| 141 | } while (0) | 
|---|
| 142 |  | 
|---|
| 143 | #else | 
|---|
| 144 |  | 
|---|
| 145 | extern struct immediate *_mesa_CurrentInput; | 
|---|
| 146 |  | 
|---|
| 147 | #define GET_CURRENT_CONTEXT(C)  GLcontext *C = (GLcontext *) _glapi_Context | 
|---|
| 148 |  | 
|---|
| 149 | #define GET_IMMEDIATE struct immediate *IM = _mesa_CurrentInput | 
|---|
| 150 |  | 
|---|
| 151 | #define SET_IMMEDIATE(ctx, im)          \ | 
|---|
| 152 | do {                                    \ | 
|---|
| 153 | ctx->input = im;                     \ | 
|---|
| 154 | _mesa_CurrentInput = im;             \ | 
|---|
| 155 | } while (0) | 
|---|
| 156 |  | 
|---|
| 157 | #endif | 
|---|
| 158 |  | 
|---|
| 159 |  | 
|---|
| 160 |  | 
|---|
| 161 | extern void | 
|---|
| 162 | _mesa_swapbuffers(GLcontext *ctx); | 
|---|
| 163 |  | 
|---|
| 164 |  | 
|---|
| 165 | extern struct _glapi_table * | 
|---|
| 166 | _mesa_get_dispatch(GLcontext *ctx); | 
|---|
| 167 |  | 
|---|
| 168 |  | 
|---|
| 169 |  | 
|---|
| 170 | /* | 
|---|
| 171 | * Miscellaneous | 
|---|
| 172 | */ | 
|---|
| 173 |  | 
|---|
| 174 | extern void gl_problem( const GLcontext *ctx, const char *s ); | 
|---|
| 175 |  | 
|---|
| 176 | extern void gl_warning( const GLcontext *ctx, const char *s ); | 
|---|
| 177 |  | 
|---|
| 178 | extern void gl_error( GLcontext *ctx, GLenum error, const char *s ); | 
|---|
| 179 |  | 
|---|
| 180 | extern void gl_compile_error( GLcontext *ctx, GLenum error, const char *s ); | 
|---|
| 181 |  | 
|---|
| 182 |  | 
|---|
| 183 |  | 
|---|
| 184 | extern void | 
|---|
| 185 | _mesa_Finish( void ); | 
|---|
| 186 |  | 
|---|
| 187 | extern void | 
|---|
| 188 | _mesa_Flush( void ); | 
|---|
| 189 |  | 
|---|
| 190 |  | 
|---|
| 191 |  | 
|---|
| 192 | extern void | 
|---|
| 193 | _mesa_init_no_op_table(struct _glapi_table *exec); | 
|---|
| 194 |  | 
|---|
| 195 | extern void | 
|---|
| 196 | _mesa_init_exec_table(struct _glapi_table *exec); | 
|---|
| 197 |  | 
|---|
| 198 |  | 
|---|
| 199 |  | 
|---|
| 200 | #ifdef PROFILE | 
|---|
| 201 | extern GLdouble gl_time( void ); | 
|---|
| 202 | #endif | 
|---|
| 203 |  | 
|---|
| 204 |  | 
|---|
| 205 | #endif | 
|---|