blob: 540b0a6ff44ee5d8cdb11cfa9883987f5b2ce380 [file] [log] [blame]
Brian Paul53a36fc1999-12-17 17:01:31 +00001/* $Id: context.h,v 1.8 1999/12/17 17:01:31 brianp Exp $ */
jtgafb833d1999-08-19 00:55:39 +00002
3/*
4 * Mesa 3-D graphics library
Brian Paulfbd8f211999-11-11 01:22:25 +00005 * Version: 3.3
jtgafb833d1999-08-19 00:55:39 +00006 *
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
jtgafb833d1999-08-19 00:55:39 +000028#ifndef CONTEXT_H
29#define CONTEXT_H
30
31
Brian Paul00037781999-12-17 14:52:35 +000032#include "glapi.h"
jtgafb833d1999-08-19 00:55:39 +000033#include "types.h"
34
35
jtgafb833d1999-08-19 00:55:39 +000036/*
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 */
60extern 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
73extern void gl_destroy_visual( GLvisual *vis );
74
75
76/*
Brian Paul00037781999-12-17 14:52:35 +000077 * 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 */
81extern GLframebuffer *gl_create_framebuffer( GLvisual *visual,
82 GLboolean softwareDepth,
83 GLboolean softwareStencil,
84 GLboolean softwareAccum,
85 GLboolean softwareAlpha );
86
87extern void gl_destroy_framebuffer( GLframebuffer *buffer );
88
89
90
91/*
jtgafb833d1999-08-19 00:55:39 +000092 * Create/destroy a GLcontext. A GLcontext is like a GLX context. It
93 * contains the rendering state.
94 */
95extern GLcontext *gl_create_context( GLvisual *visual,
96 GLcontext *share_list,
97 void *driver_ctx,
98 GLboolean direct);
99
100extern void gl_destroy_context( GLcontext *ctx );
101
102/* Called by the driver after both the context and driver are fully
103 * initialized. Currently just reads the config file.
104 */
105extern void gl_context_initialize( GLcontext *ctx );
106
Brian Paul04986821999-11-19 22:26:52 +0000107
108extern void gl_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask);
109
110
jtgafb833d1999-08-19 00:55:39 +0000111extern void gl_make_current( GLcontext *ctx, GLframebuffer *buffer );
112
Brian Paul00037781999-12-17 14:52:35 +0000113
Brian Paul3f02f901999-11-24 18:48:30 +0000114extern void gl_make_current2( GLcontext *ctx, GLframebuffer *drawBuffer,
115 GLframebuffer *readBuffer );
116
Brian Paul00037781999-12-17 14:52:35 +0000117
jtgafb833d1999-08-19 00:55:39 +0000118extern GLcontext *gl_get_current_context(void);
119
Brian Paul04986821999-11-19 22:26:52 +0000120
Brian Paul00037781999-12-17 14:52:35 +0000121/*
122 * Macros for fetching current context, input buffer, etc.
123 */
Brian Paul04986821999-11-19 22:26:52 +0000124#ifdef THREADS
Brian Paul04986821999-11-19 22:26:52 +0000125
Brian Paul00037781999-12-17 14:52:35 +0000126#define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) (_glapi_ThreadSafe ? _glapi_get_current_context() : _glapi_CurrentContext)
127
Brian Paul53a36fc1999-12-17 17:01:31 +0000128#define GET_IMMEDIATE struct immediate *IM = ((GLcontext *) (_glapi_ThreadSafe ? _glapi_get_current_context() : _glapi_CurrentContext))->input;
Brian Paul04986821999-11-19 22:26:52 +0000129#define SET_IMMEDIATE(ctx, im) \
130do { \
131 ctx->input = im; \
132} while (0)
133
Brian Paul04986821999-11-19 22:26:52 +0000134#else
Brian Paul04986821999-11-19 22:26:52 +0000135
Brian Paulc6336931999-12-17 12:21:38 +0000136extern struct immediate *CURRENT_INPUT;
Brian Paul00037781999-12-17 14:52:35 +0000137#define GET_CURRENT_CONTEXT(C) GLcontext *C = _glapi_CurrentContext
Brian Paul04986821999-11-19 22:26:52 +0000138#define GET_IMMEDIATE struct immediate *IM = CURRENT_INPUT
139#define SET_IMMEDIATE(ctx, im) \
140do { \
141 ctx->input = im; \
142 CURRENT_INPUT = im; \
143} while (0)
144
Brian Paul04986821999-11-19 22:26:52 +0000145#endif
146
147
jtgafb833d1999-08-19 00:55:39 +0000148
Brian Paulfbd8f211999-11-11 01:22:25 +0000149extern void
150_mesa_swapbuffers(GLcontext *ctx);
151
Brian Paul00037781999-12-17 14:52:35 +0000152
Brian Paulfbd8f211999-11-11 01:22:25 +0000153extern struct _glapi_table *
154_mesa_get_dispatch(GLcontext *ctx);
jtgafb833d1999-08-19 00:55:39 +0000155
156
157
158/*
159 * GL_MESA_resize_buffers extension
160 */
Brian Paulfbd8f211999-11-11 01:22:25 +0000161extern void _mesa_ResizeBuffersMESA( void );
jtgafb833d1999-08-19 00:55:39 +0000162
163
164
165/*
166 * Miscellaneous
167 */
168
169extern void gl_problem( const GLcontext *ctx, const char *s );
170
171extern void gl_warning( const GLcontext *ctx, const char *s );
172
173extern void gl_error( GLcontext *ctx, GLenum error, const char *s );
jtgafb833d1999-08-19 00:55:39 +0000174
Brian Paul00037781999-12-17 14:52:35 +0000175extern void gl_compile_error( GLcontext *ctx, GLenum error, const char *s );
jtgafb833d1999-08-19 00:55:39 +0000176
177extern void gl_update_state( GLcontext *ctx );
178
179
180/* for debugging */
181extern void gl_print_state( const char *msg, GLuint state );
182
183/* for debugging */
184extern void gl_print_enable_flags( const char *msg, GLuint flags );
185
186
187#ifdef PROFILE
188extern GLdouble gl_time( void );
189#endif
190
191
192#endif