3
* Mesa 3-D graphics library
6
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
8
* Permission is hereby granted, free of charge, to any person obtaining a
9
* copy of this software and associated documentation files (the "Software"),
10
* to deal in the Software without restriction, including without limitation
11
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
* and/or sell copies of the Software, and to permit persons to whom the
13
* Software is furnished to do so, subject to the following conditions:
15
* The above copyright notice and this permission notice shall be included
16
* in all copies or substantial portions of the Software.
18
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34
#include "math/m_eval.h"
36
#include "t_eval_api.h"
37
#include "t_imm_api.h"
38
#include "t_imm_alloc.h"
39
#include "t_imm_exec.h"
45
/* KW: If are compiling, we don't know whether eval will produce a
46
* vertex when it is run in the future. If this is pure immediate
47
* mode, eval is a noop if neither vertex map is enabled.
49
* Thus we need to have a check in the display list code or
50
* elsewhere for eval(1,2) vertices in the case where
51
* map(1,2)_vertex is disabled, and to purge those vertices from
55
_tnl_exec_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
57
GET_CURRENT_CONTEXT(ctx);
61
ASSERT_OUTSIDE_BEGIN_END(ctx);
63
/* fprintf(stderr, "%s\n", __FUNCTION__); */
73
_mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh1(mode)" );
77
/* No effect if vertex maps disabled.
79
if (!ctx->Eval.Map1Vertex4 && !ctx->Eval.Map1Vertex3)
82
du = ctx->Eval.MapGrid1du;
83
u = ctx->Eval.MapGrid1u1 + i1 * du;
85
/* Need to turn off compilation -- this is already saved, and the
86
* coordinates generated and the test above depend on state that
87
* may change before the list is executed.
89
* TODO: Anaylse display lists to determine if this state is
94
* - map state for each enabled map, including control points
97
* Could alternatively cache individual maps in arrays, rather than
98
* building immediates.
101
GLboolean compiling = ctx->CompileFlag;
102
TNLcontext *tnl = TNL_CONTEXT(ctx);
103
struct immediate *im = TNL_CURRENT_IM(ctx);
104
GLboolean (*NotifyBegin)(GLcontext *ctx, GLenum p);
106
NotifyBegin = tnl->Driver.NotifyBegin;
107
tnl->Driver.NotifyBegin = 0;
110
struct immediate *IM = _tnl_alloc_immediate( ctx );
111
FLUSH_VERTICES( ctx, 0 );
112
SET_IMMEDIATE( ctx, IM );
114
ctx->CompileFlag = GL_FALSE;
118
for (i=i1;i<=i2;i++,u+=du) {
119
_tnl_eval_coord1f( ctx, u );
123
/* Need this for replay *and* compile:
125
FLUSH_VERTICES( ctx, 0 );
126
tnl->Driver.NotifyBegin = NotifyBegin;
129
TNL_CURRENT_IM(ctx)->ref_count--;
130
ASSERT( TNL_CURRENT_IM(ctx)->ref_count == 0 );
131
_tnl_free_immediate( ctx, TNL_CURRENT_IM(ctx) );
132
SET_IMMEDIATE( ctx, im );
133
ctx->CompileFlag = GL_TRUE;
141
_tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
143
GET_CURRENT_CONTEXT(ctx);
145
GLfloat u, du, v, dv, v1, u1;
146
ASSERT_OUTSIDE_BEGIN_END(ctx);
148
/* fprintf(stderr, "%s\n", __FUNCTION__); */
150
/* No effect if vertex maps disabled.
152
if (!ctx->Eval.Map2Vertex4 && !ctx->Eval.Map2Vertex3)
156
du = ctx->Eval.MapGrid2du;
157
dv = ctx->Eval.MapGrid2dv;
158
v1 = ctx->Eval.MapGrid2v1 + j1 * dv;
159
u1 = ctx->Eval.MapGrid2u1 + i1 * du;
161
/* Need to turn off compilation -- this is already saved, and the
162
* coordinates generated and the test above depend on state that
163
* may change before the list is executed.
166
GLboolean compiling = ctx->CompileFlag;
167
struct immediate *im = TNL_CURRENT_IM(ctx);
168
TNLcontext *tnl = TNL_CONTEXT(ctx);
169
GLboolean (*NotifyBegin)(GLcontext *ctx, GLenum p);
171
NotifyBegin = tnl->Driver.NotifyBegin;
172
tnl->Driver.NotifyBegin = 0;
175
struct immediate *IM = _tnl_alloc_immediate( ctx );
176
FLUSH_VERTICES( ctx, 0 );
177
SET_IMMEDIATE( ctx, IM );
179
ctx->CompileFlag = GL_FALSE;
184
_tnl_Begin( GL_POINTS );
185
for (v=v1,j=j1;j<=j2;j++,v+=dv) {
186
for (u=u1,i=i1;i<=i2;i++,u+=du) {
187
_tnl_eval_coord2f( ctx, u, v );
193
for (v=v1,j=j1;j<=j2;j++,v+=dv) {
194
_tnl_Begin( GL_LINE_STRIP );
195
for (u=u1,i=i1;i<=i2;i++,u+=du) {
196
_tnl_eval_coord2f( ctx, u, v );
200
for (u=u1,i=i1;i<=i2;i++,u+=du) {
201
_tnl_Begin( GL_LINE_STRIP );
202
for (v=v1,j=j1;j<=j2;j++,v+=dv) {
203
_tnl_eval_coord2f( ctx, u, v );
209
for (v=v1,j=j1;j<j2;j++,v+=dv) {
210
_tnl_Begin( GL_TRIANGLE_STRIP );
211
for (u=u1,i=i1;i<=i2;i++,u+=du) {
212
_tnl_eval_coord2f( ctx, u, v );
213
_tnl_eval_coord2f( ctx, u, v+dv );
219
_mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" );
223
/* Need this for replay *and* compile:
225
FLUSH_VERTICES( ctx, 0 );
226
tnl->Driver.NotifyBegin = NotifyBegin;
229
TNL_CURRENT_IM(ctx)->ref_count--;
230
_tnl_free_immediate( ctx, TNL_CURRENT_IM( ctx ) );
231
SET_IMMEDIATE( ctx, im );
232
ctx->CompileFlag = GL_TRUE;
239
void _tnl_eval_init( GLcontext *ctx )
241
GLvertexformat *vfmt = &(TNL_CONTEXT(ctx)->vtxfmt);
242
vfmt->EvalMesh1 = _tnl_exec_EvalMesh1;
243
vfmt->EvalMesh2 = _tnl_exec_EvalMesh2;