1 /* $Id: context.h,v 1.9 1997/09/29 22:25:28 brianp Exp $ */ 2 3 /* 4 * Mesa 3-D graphics library 5 * Version: 2.5 6 * Copyright (C) 1995-1997 Brian Paul 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Library General Public 10 * License as published by the Free Software Foundation; either 11 * version 2 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Library General Public License for more details. 17 * 18 * You should have received a copy of the GNU Library General Public 19 * License along with this library; if not, write to the Free 20 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 */ 22 23 24 /* 25 * $Log: context.h,v $ 26 * Revision 1.9 1997/09/29 22:25:28 brianp 27 * added const to a few function parameters 28 * 29 * Revision 1.8 1997/05/26 21:14:13 brianp 30 * gl_create_visual() now takes red/green/blue/alpha_bits arguments 31 * 32 * Revision 1.7 1997/04/16 23:55:06 brianp 33 * added gl_set_api_table() 34 * 35 * Revision 1.6 1997/04/12 17:12:43 brianp 36 * added gl_get_current_context() 37 * 38 * Revision 1.5 1997/02/27 19:57:38 brianp 39 * added gl_problem() function 40 * 41 * Revision 1.4 1997/02/10 19:49:50 brianp 42 * added gl_ResizeBuffersMESA() 43 * 44 * Revision 1.3 1996/09/19 03:14:49 brianp 45 * now just one parameter for gl_create_framebuffer() 46 * 47 * Revision 1.2 1996/09/15 14:20:22 brianp 48 * added new functions for GLframebuffer and GLvisual support 49 * 50 * Revision 1.1 1996/09/13 01:38:16 brianp 51 * Initial revision 52 * 53 */ 54 55 56 #ifndef CONTEXT_H 57 #define CONTEXT_H 58 59 60 #include "types.h" 61 62 63 64 #ifdef THREADS 65 /* 66 * A seperate GLcontext for each thread 67 */ 68 extern GLcontext *gl_get_thread_context( void ); 69 #else 70 /* 71 * All threads use same pointer to current context. 72 */ 73 extern GLcontext *CC; 74 #endif 75 76 77 78 /* 79 * There are three Mesa datatypes which are meant to be used by device 80 * drivers: 81 * GLcontext: this contains the Mesa rendering state 82 * GLvisual: this describes the color buffer (rgb vs. ci), whether 83 * or not there's a depth buffer, stencil buffer, etc. 84 * GLframebuffer: contains pointers to the depth buffer, stencil 85 * buffer, accum buffer and alpha buffers. 86 * 87 * These types should be encapsulated by corresponding device driver 88 * datatypes. See xmesa.h and xmesaP.h for an example. 89 * 90 * The following functions create and destroy these datatypes. 91 */ 92 93 94 /* 95 * Create/destroy a GLvisual. A GLvisual is like a GLX visual. It describes 96 * the colorbuffer, depth buffer, stencil buffer and accum buffer which will 97 * be used by the GL context and framebuffer. 98 */ 99 extern GLvisual *gl_create_visual( GLboolean rgb_flag, 100 GLboolean alpha_flag, 101 GLboolean db_flag, 102 GLint depth_bits, 103 GLint stencil_bits, 104 GLint accum_bits, 105 GLint index_bits, 106 GLfloat red_scale, 107 GLfloat green_scale, 108 GLfloat blue_scale, 109 GLfloat alpha_scale, 110 GLint red_bits, 111 GLint green_bits, 112 GLint blue_bits, 113 GLint alpha_bits ); 114 115 extern void gl_destroy_visual( GLvisual *vis ); 116 117 118 /* 119 * Create/destroy a GLcontext. A GLcontext is like a GLX context. It 120 * contains the rendering state. 121 */ 122 extern GLcontext *gl_create_context( GLvisual *visual, 123 GLcontext *share_list, 124 void *driver_ctx ); 125 126 extern void gl_destroy_context( GLcontext *ctx ); 127 128 129 /* 130 * Create/destroy a GLframebuffer. A GLframebuffer is like a GLX drawable. 131 * It bundles up the depth buffer, stencil buffer and accum buffers into a 132 * single entity. 133 */ 134 extern GLframebuffer *gl_create_framebuffer( GLvisual *visual ); 135 136 extern void gl_destroy_framebuffer( GLframebuffer *buffer ); 137 138 139 140 extern void gl_make_current( GLcontext *ctx, GLframebuffer *buffer ); 141 142 extern GLcontext *gl_get_current_context(void); 143 144 extern void gl_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask); 145 146 extern void gl_set_api_table( GLcontext *ctx, const struct gl_api_table *api ); 147 148 149 150 /* 151 * GL_MESA_resize_buffers extension 152 */ 153 extern void gl_ResizeBuffersMESA( GLcontext *ctx ); 154 155 156 157 /* 158 * Miscellaneous 159 */ 160 161 extern void gl_problem( const GLcontext *ctx, const char *s ); 162 163 extern void gl_warning( const GLcontext *ctx, const char *s ); 164 165 extern void gl_error( GLcontext *ctx, GLenum error, const char *s ); 166 167 extern GLenum gl_GetError( GLcontext *ctx ); 168 169 170 extern void gl_update_state( GLcontext *ctx ); 171 172 173 174 #ifdef PROFILE 175 extern GLdouble gl_time( void ); 176 #endif 177 178 179 #endif 180