| 1 | /* $Id: context.h,v 1.3 2000-03-02 13:27:30 sandervl Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Mesa 3-D graphics library
|
|---|
| 5 | * Version: 3.1
|
|---|
| 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 |
|
|---|
| 37 | #ifdef THREADS
|
|---|
| 38 | /*
|
|---|
| 39 | * A seperate GLcontext for each thread
|
|---|
| 40 | */
|
|---|
| 41 | extern GLcontext *gl_get_thread_context( void );
|
|---|
| 42 | #else
|
|---|
| 43 | /*
|
|---|
| 44 | * All threads use same pointer to current context.
|
|---|
| 45 | */
|
|---|
| 46 | extern GLcontext *CC;
|
|---|
| 47 | extern struct immediate *CURRENT_INPUT;
|
|---|
| 48 | #endif
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 | /*
|
|---|
| 53 | * There are three Mesa datatypes which are meant to be used by device
|
|---|
| 54 | * drivers:
|
|---|
| 55 | * GLcontext: this contains the Mesa rendering state
|
|---|
| 56 | * GLvisual: this describes the color buffer (rgb vs. ci), whether
|
|---|
| 57 | * or not there's a depth buffer, stencil buffer, etc.
|
|---|
| 58 | * GLframebuffer: contains pointers to the depth buffer, stencil
|
|---|
| 59 | * buffer, accum buffer and alpha buffers.
|
|---|
| 60 | *
|
|---|
| 61 | * These types should be encapsulated by corresponding device driver
|
|---|
| 62 | * datatypes. See xmesa.h and xmesaP.h for an example.
|
|---|
| 63 | *
|
|---|
| 64 | * In OOP terms, GLcontext, GLvisual, and GLframebuffer are base classes
|
|---|
| 65 | * which the device driver must derive from.
|
|---|
| 66 | *
|
|---|
| 67 | * The following functions create and destroy these datatypes.
|
|---|
| 68 | */
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 | /*
|
|---|
| 72 | * Create/destroy a GLvisual. A GLvisual is like a GLX visual. It describes
|
|---|
| 73 | * the colorbuffer, depth buffer, stencil buffer and accum buffer which will
|
|---|
| 74 | * be used by the GL context and framebuffer.
|
|---|
| 75 | */
|
|---|
| 76 | extern GLvisual *gl_create_visual( GLboolean rgbFlag,
|
|---|
| 77 | GLboolean alphaFlag,
|
|---|
| 78 | GLboolean dbFlag,
|
|---|
| 79 | GLboolean stereoFlag,
|
|---|
| 80 | GLint depthBits,
|
|---|
| 81 | GLint stencilBits,
|
|---|
| 82 | GLint accumBits,
|
|---|
| 83 | GLint indexBits,
|
|---|
| 84 | GLint redBits,
|
|---|
| 85 | GLint greenBits,
|
|---|
| 86 | GLint blueBits,
|
|---|
| 87 | GLint alphaBits );
|
|---|
| 88 |
|
|---|
| 89 | extern void gl_destroy_visual( GLvisual *vis );
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 | /*
|
|---|
| 93 | * Create/destroy a GLcontext. A GLcontext is like a GLX context. It
|
|---|
| 94 | * contains the rendering state.
|
|---|
| 95 | */
|
|---|
| 96 | extern GLcontext *gl_create_context( GLvisual *visual,
|
|---|
| 97 | GLcontext *share_list,
|
|---|
| 98 | void *driver_ctx,
|
|---|
| 99 | GLboolean direct);
|
|---|
| 100 |
|
|---|
| 101 | extern void gl_destroy_context( GLcontext *ctx );
|
|---|
| 102 |
|
|---|
| 103 | /* Called by the driver after both the context and driver are fully
|
|---|
| 104 | * initialized. Currently just reads the config file.
|
|---|
| 105 | */
|
|---|
| 106 | extern void gl_context_initialize( GLcontext *ctx );
|
|---|
| 107 |
|
|---|
| 108 | /*
|
|---|
| 109 | * Create/destroy a GLframebuffer. A GLframebuffer is like a GLX drawable.
|
|---|
| 110 | * It bundles up the depth buffer, stencil buffer and accum buffers into a
|
|---|
| 111 | * single entity.
|
|---|
| 112 | */
|
|---|
| 113 | extern GLframebuffer *gl_create_framebuffer( GLvisual *visual );
|
|---|
| 114 |
|
|---|
| 115 | extern void gl_destroy_framebuffer( GLframebuffer *buffer );
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 | extern void gl_make_current( GLcontext *ctx, GLframebuffer *buffer );
|
|---|
| 120 |
|
|---|
| 121 | extern GLcontext *gl_get_current_context(void);
|
|---|
| 122 |
|
|---|
| 123 | extern void gl_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask);
|
|---|
| 124 |
|
|---|
| 125 | extern void gl_set_api_table( GLcontext *ctx, const struct gl_api_table *api );
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 | /*
|
|---|
| 130 | * GL_MESA_resize_buffers extension
|
|---|
| 131 | */
|
|---|
| 132 | extern void gl_ResizeBuffersMESA( GLcontext *ctx );
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 | /*
|
|---|
| 137 | * Miscellaneous
|
|---|
| 138 | */
|
|---|
| 139 |
|
|---|
| 140 | extern void gl_problem( const GLcontext *ctx, const char *s );
|
|---|
| 141 |
|
|---|
| 142 | extern void gl_warning( const GLcontext *ctx, const char *s );
|
|---|
| 143 |
|
|---|
| 144 | extern void gl_error( GLcontext *ctx, GLenum error, const char *s );
|
|---|
| 145 | extern void gl_compile_error( GLcontext *ctx, GLenum error, const char *s );
|
|---|
| 146 |
|
|---|
| 147 | extern GLenum gl_GetError( GLcontext *ctx );
|
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 | extern void gl_update_state( GLcontext *ctx );
|
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 | /* for debugging */
|
|---|
| 154 | extern void gl_print_state( const char *msg, GLuint state );
|
|---|
| 155 |
|
|---|
| 156 | /* for debugging */
|
|---|
| 157 | extern void gl_print_enable_flags( const char *msg, GLuint flags );
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 | #ifdef PROFILE
|
|---|
| 161 | extern GLdouble gl_time( void );
|
|---|
| 162 | #endif
|
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 | #endif
|
|---|