04106264ff261afb5c02998490795bcfe249bdc1
[mesa.git] / src / mesa / tnl / t_vertex.h
1 /*
2 * Copyright 2003 Tungsten Graphics, inc.
3 * All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Keith Whitwell <keithw@tungstengraphics.com>
26 */
27
28 #ifndef _TNL_VERTEX_H
29 #define _TNL_VERTEX_H
30
31 /* New mechanism to specify hardware vertices so that tnl can build
32 * and manipulate them directly.
33 */
34
35
36 /* It will probably be necessary to allow drivers to specify new
37 * emit-styles to cover all the wierd and wacky things out there.
38 */
39 enum tnl_attr_format {
40 EMIT_1F,
41 EMIT_2F,
42 EMIT_3F,
43 EMIT_4F,
44 EMIT_2F_VIEWPORT, /* do viewport transform and emit */
45 EMIT_3F_VIEWPORT, /* do viewport transform and emit */
46 EMIT_4F_VIEWPORT, /* do viewport transform and emit */
47 EMIT_3F_XYW, /* for projective texture */
48 EMIT_1UB_1F, /* for fog coordinate */
49 EMIT_3UB_3F_BGR, /* for specular color */
50 EMIT_3UB_3F_RGB, /* for specular color */
51 EMIT_4UB_4F_BGRA, /* for color */
52 EMIT_4UB_4F_RGBA, /* for color */
53 EMIT_4CHAN_4F_RGBA, /* for swrast color */
54 EMIT_PAD, /* leave a hole of 'offset' bytes */
55 EMIT_MAX
56 };
57
58 struct tnl_attr_map {
59 GLuint attrib; /* _TNL_ATTRIB_ enum */
60 enum tnl_attr_format format;
61 GLuint offset;
62 };
63
64
65
66 /* Interpolate between two vertices to produce a third:
67 */
68 extern void _tnl_interp( GLcontext *ctx,
69 GLfloat t,
70 GLuint edst, GLuint eout, GLuint ein,
71 GLboolean force_boundary );
72
73 /* Copy colors from one vertex to another:
74 */
75 extern void _tnl_copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc );
76
77
78 /* Extract a named attribute from a hardware vertex. Will have to
79 * reverse any viewport transformation, swizzling or other conversions
80 * which may have been applied:
81 */
82 extern void _tnl_get_attr( GLcontext *ctx, const void *vertex, GLenum attrib,
83 GLfloat *dest );
84
85 /* Complementary to the above.
86 */
87 extern void _tnl_set_attr( GLcontext *ctx, void *vout, GLenum attrib,
88 const GLfloat *src );
89
90
91 extern void *_tnl_get_vertex( GLcontext *ctx, GLuint nr );
92
93
94 /*
95 */
96 extern GLuint _tnl_install_attrs( GLcontext *ctx,
97 const struct tnl_attr_map *map,
98 GLuint nr, const GLfloat *vp,
99 GLuint unpacked_size );
100
101
102
103
104
105 extern void _tnl_free_vertices( GLcontext *ctx );
106
107 extern void _tnl_init_vertices( GLcontext *ctx,
108 GLuint vb_size,
109 GLuint max_vertex_size );
110
111 extern void *_tnl_emit_vertices_to_buffer( GLcontext *ctx,
112 GLuint start,
113 GLuint end,
114 void *dest );
115
116 extern void _tnl_build_vertices( GLcontext *ctx,
117 GLuint start,
118 GLuint end,
119 GLuint newinputs );
120
121 extern void _tnl_invalidate_vertices( GLcontext *ctx, GLuint newinputs );
122
123 extern void _tnl_invalidate_vertex_state( GLcontext *ctx, GLuint new_state );
124
125
126 #endif