1 | /* $Id: vbfill.c,v 1.2 2000-03-01 18:49:39 jeroen 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 | #ifdef PC_HEADER
|
---|
30 | #include "all.h"
|
---|
31 | #else
|
---|
32 | #ifndef XFree86Server
|
---|
33 | #include <assert.h>
|
---|
34 | #include <math.h>
|
---|
35 | #include <stdio.h>
|
---|
36 | #else
|
---|
37 | #include "GL/xf86glx.h"
|
---|
38 | #endif
|
---|
39 | #include "types.h"
|
---|
40 | #include "context.h"
|
---|
41 | #include "enums.h"
|
---|
42 | #include "light.h"
|
---|
43 | #include "macros.h"
|
---|
44 | #include "matrix.h"
|
---|
45 | #include "mmath.h"
|
---|
46 | #include "varray.h"
|
---|
47 | #include "vb.h"
|
---|
48 | #include "vbcull.h"
|
---|
49 | #include "vbfill.h"
|
---|
50 | #include "vbrender.h"
|
---|
51 | #include "vbxform.h"
|
---|
52 | #include "xform.h"
|
---|
53 | #endif
|
---|
54 |
|
---|
55 |
|
---|
56 |
|
---|
57 | /* KW: The work of most of the functions which were in this file are
|
---|
58 | * now done directly by the GLVertex, GLTexCoord, GLIndex, ...,
|
---|
59 | * functions in api{1,2}.c. This is made possible by the fact
|
---|
60 | * that display lists and vertex buffers are now built the same
|
---|
61 | * way, so there is no need for the indirection and overhead of a
|
---|
62 | * function pointer.
|
---|
63 | */
|
---|
64 |
|
---|
65 |
|
---|
66 | void gl_Begin( GLcontext *ctx, GLenum p )
|
---|
67 | {
|
---|
68 | struct immediate *IM = ctx->input;
|
---|
69 | GLuint inflags, state;
|
---|
70 |
|
---|
71 | if (MESA_VERBOSE&VERBOSE_API) {
|
---|
72 | if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
|
---|
73 | fprintf(stderr, "glBegin(IM %d) %s\n", IM->id, gl_lookup_enum_by_nr(p));
|
---|
74 | else
|
---|
75 | fprintf(stderr, "<");
|
---|
76 | }
|
---|
77 |
|
---|
78 | if (ctx->NewState)
|
---|
79 | gl_update_state( ctx ); /* should already be flushed */
|
---|
80 |
|
---|
81 | /* if only a very few slots left, might as well flush now
|
---|
82 | */
|
---|
83 | if (IM->Count > VB_MAX-4) {
|
---|
84 | IM->maybe_transform_vb( IM );
|
---|
85 | IM = ctx->input;
|
---|
86 | }
|
---|
87 |
|
---|
88 | state = IM->BeginState;
|
---|
89 | inflags = state & (VERT_BEGIN_0|VERT_BEGIN_1);
|
---|
90 | state |= inflags << 2; /* set error conditions */
|
---|
91 |
|
---|
92 | if (MESA_VERBOSE&VERBOSE_API)
|
---|
93 | fprintf(stderr, "in gl_Begin(IM %d), BeginState is %x, errors %x",
|
---|
94 | IM->id,
|
---|
95 | state,
|
---|
96 | inflags<<2);
|
---|
97 |
|
---|
98 | if (inflags != (VERT_BEGIN_0|VERT_BEGIN_1))
|
---|
99 | {
|
---|
100 | GLuint count = IM->Count;
|
---|
101 | GLuint last = IM->LastPrimitive;
|
---|
102 |
|
---|
103 | state |= (VERT_BEGIN_0|VERT_BEGIN_1);
|
---|
104 | IM->Flag[count] |= VERT_BEGIN;
|
---|
105 | IM->Primitive[count] = p;
|
---|
106 |
|
---|
107 | IM->NextPrimitive[IM->LastPrimitive] = count;
|
---|
108 | IM->LastPrimitive = count;
|
---|
109 |
|
---|
110 | if (IM->FlushElt) {
|
---|
111 | gl_exec_array_elements( ctx, IM, last, count );
|
---|
112 | IM->FlushElt = 0;
|
---|
113 | }
|
---|
114 | }
|
---|
115 |
|
---|
116 | if (MESA_VERBOSE&VERBOSE_API)
|
---|
117 | fprintf(stderr, "in gl_Begin final state %x\n", state);
|
---|
118 |
|
---|
119 | IM->BeginState = state;
|
---|
120 | }
|
---|
121 |
|
---|
122 |
|
---|
123 |
|
---|