b8d115cd8297a27bece00e9b8e6d789cfc9be6ef
[mesa.git] / src / mesa / main / dlist.h
1 /**
2 * \file dlist.h
3 * Display lists management.
4 */
5
6 /*
7 * Mesa 3-D graphics library
8 * Version: 4.1
9 *
10 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 */
29
30
31
32 #ifndef DLIST_H
33 #define DLIST_H
34
35
36 #include "mtypes.h"
37
38
39 /**
40 * Macro to assert that the API call was made outside the
41 * glBegin()/glEnd() pair, with return value.
42 *
43 * \param ctx GL context.
44 * \param retval value to return value in case the assertion fails.
45 */
46 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval) \
47 do { \
48 if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \
49 ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \
50 _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
51 return retval; \
52 } \
53 } while (0)
54
55 /**
56 * Macro to assert that the API call was made outside the
57 * glBegin()/glEnd() pair.
58 *
59 * \param ctx GL context.
60 */
61 #define ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx) \
62 do { \
63 if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \
64 ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \
65 _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
66 return; \
67 } \
68 } while (0)
69
70 /**
71 * Macro to assert that the API call was made outside the
72 * glBegin()/glEnd() pair and flush the vertices.
73 *
74 * \param ctx GL context.
75 */
76 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx) \
77 do { \
78 ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); \
79 FLUSH_VERTICES(ctx, 0); \
80 } while (0)
81
82 /**
83 * Macro to assert that the API call was made outside the
84 * glBegin()/glEnd() pair and flush the vertices, with return value.
85 *
86 * \param ctx GL context.
87 * \param retval value to return value in case the assertion fails.
88 */
89 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)\
90 do { \
91 ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval); \
92 FLUSH_VERTICES(ctx, 0); \
93 } while (0)
94
95
96 #if _HAVE_FULL_GL
97
98 extern void _mesa_init_lists( void );
99
100 extern void _mesa_destroy_list( GLcontext *ctx, GLuint list );
101
102 extern void _mesa_CallList( GLuint list );
103
104 extern void _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists );
105
106 extern void _mesa_DeleteLists( GLuint list, GLsizei range );
107
108 extern void _mesa_EndList( void );
109
110 extern GLuint _mesa_GenLists( GLsizei range );
111
112 extern GLboolean _mesa_IsList( GLuint list );
113
114 extern void _mesa_ListBase( GLuint base );
115
116 extern void _mesa_NewList( GLuint list, GLenum mode );
117
118 extern void _mesa_init_dlist_table( struct _glapi_table *table,
119 GLuint tableSize );
120
121 extern void _mesa_save_error( GLcontext *ctx, GLenum error, const char *s );
122
123 extern void _mesa_compile_error( GLcontext *ctx, GLenum error, const char *s );
124
125
126 extern void *_mesa_alloc_instruction( GLcontext *ctx, int opcode, GLint sz );
127
128 extern int _mesa_alloc_opcode( GLcontext *ctx, GLuint sz,
129 void (*execute)( GLcontext *, void * ),
130 void (*destroy)( GLcontext *, void * ),
131 void (*print)( GLcontext *, void * ) );
132
133 extern void _mesa_save_EvalMesh2(GLenum mode, GLint i1, GLint i2,
134 GLint j1, GLint j2 );
135 extern void _mesa_save_EvalMesh1( GLenum mode, GLint i1, GLint i2 );
136 extern void _mesa_save_CallLists( GLsizei n, GLenum type, const GLvoid *lists );
137 extern void _mesa_save_CallList( GLuint list );
138 extern void _mesa_init_display_list( GLcontext * ctx );
139
140 #else
141
142 /** No-op */
143 #define _mesa_init_lists() ((void)0)
144
145 /** No-op */
146 #define _mesa_destroy_list(c,l) ((void)0)
147
148 /** No-op */
149 #define _mesa_init_dlist_table(t,ts) ((void)0)
150
151 /** No-op */
152 #define _mesa_init_display_list(c) ((void)0)
153
154 #endif
155
156 #endif