source: trunk/src/opengl/mesa/vector.h

Last change on this file was 3597, checked in by jeroen, 25 years ago

* empty log message *

File size: 5.2 KB
Line 
1/* $Id: vector.h,v 1.2 2000-05-23 20:35:00 jeroen Exp $ */
2
3/*
4 * Mesa 3-D graphics library
5 * Version: 3.3
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 * New (3.1) transformation code written by Keith Whitwell.
29 */
30
31
32#ifndef _VECTOR_H_
33#define _VECTOR_H_
34
35/* Wrap all the information about vertices up in a struct. Has
36 * additional fields compared to the other vectors to help us track of
37 * different vertex sizes, and whether we need to clean columns out
38 * because they contain non-(0,0,0,1) values.
39 *
40 * The start field is used to reserve data for copied vertices at the
41 * end of gl_transform_vb, and avoids the need for a multiplication in
42 * the transformation routines.
43 */
44typedef struct {
45 GLfloat (*data)[4]; /* may be malloced or point to client data */
46 GLfloat *start;
47 GLuint count;
48 GLuint stride; /* start to start */
49 GLuint size; /* 2-4 for vertices and 1-4 for texcoords */
50 GLuint flags; /* which columns are dirty */
51 void *storage;
52} GLvector4f;
53
54
55extern void gl_vector4f_print( GLvector4f *v, GLubyte *, GLboolean );
56extern void gl_vector4f_init( GLvector4f *v, GLuint flags,
57 GLfloat (*storage)[4] );
58extern void gl_vector4f_alloc( GLvector4f *v, GLuint sz, GLuint flags,
59 GLuint count, GLuint alignment );
60extern void gl_vector4f_free( GLvector4f *v );
61extern void gl_vector4f_clean_elem( GLvector4f *vec, GLuint nr, GLuint elt );
62
63
64#define VEC_DIRTY_0 0x1 /* dirty flags not really used any more */
65#define VEC_DIRTY_1 0x2
66#define VEC_DIRTY_2 0x4
67#define VEC_DIRTY_3 0x8
68#define VEC_MALLOC 0x10
69#define VEC_WRITABLE 0x20 /* keep both + and - bits for easy testing */
70#define VEC_NOT_WRITABLE 0x40
71#define VEC_GOOD_STRIDE 0x80
72#define VEC_BAD_STRIDE 0x100
73
74#define VEC_WRITABLE_FLAGS (VEC_WRITABLE|VEC_NOT_WRITABLE)
75#define VEC_STRIDE_FLAGS (VEC_GOOD_STRIDE|VEC_BAD_STRIDE)
76
77
78#define VEC_SIZE_1 VEC_DIRTY_0
79#define VEC_SIZE_2 (VEC_DIRTY_0|VEC_DIRTY_1)
80#define VEC_SIZE_3 (VEC_DIRTY_0|VEC_DIRTY_1|VEC_DIRTY_2)
81#define VEC_SIZE_4 (VEC_DIRTY_0|VEC_DIRTY_1|VEC_DIRTY_2|VEC_DIRTY_3)
82
83
84/* Could use a single vector type for normals and vertices, but
85 * this way avoids some casts.
86 */
87typedef struct {
88 GLfloat (*data)[3];
89 GLfloat *start;
90 GLuint count;
91 GLuint stride;
92 GLuint flags;
93 void *storage;
94} GLvector3f;
95
96extern void gl_vector3f_print( GLvector3f *v, GLubyte *, GLboolean );
97extern void gl_vector3f_free( GLvector3f *v );
98extern void gl_vector3f_init( GLvector3f *v, GLuint flags, GLfloat (*)[3] );
99extern void gl_vector3f_alloc( GLvector3f *v, GLuint flags, GLuint count,
100 GLuint alignment );
101
102
103/* For 4ub rgba values.
104 */
105typedef struct {
106 GLubyte (*data)[4];
107 GLubyte *start;
108 GLuint count;
109 GLuint stride;
110 GLuint flags;
111 void *storage;
112} GLvector4ub;
113
114extern void gl_vector4ub_init( GLvector4ub *v, GLuint flags,
115 GLubyte (*storage)[4] );
116extern void gl_vector4ub_free( GLvector4ub * );
117extern void gl_vector4ub_alloc( GLvector4ub *v, GLuint flags, GLuint count,
118 GLuint alignment );
119
120
121
122
123/* For 1ub values, eg edgeflag.
124 */
125typedef struct {
126 GLubyte *data;
127 GLubyte *start;
128 GLuint count;
129 GLuint stride;
130 GLuint flags;
131 void *storage;
132} GLvector1ub;
133
134extern void gl_vector1ub_init( GLvector1ub *v, GLuint flags, GLubyte *storage);
135extern void gl_vector1ub_free( GLvector1ub * );
136extern void gl_vector1ub_alloc( GLvector1ub *v, GLuint flags, GLuint count,
137 GLuint alignment );
138
139
140
141
142/* For, eg Index, Array element.
143 */
144typedef struct {
145 GLuint *data;
146 GLuint *start;
147 GLuint count;
148 GLuint stride;
149 GLuint flags;
150 void *storage;
151} GLvector1ui;
152
153extern void gl_vector1ui_init( GLvector1ui *v, GLuint flags, GLuint *storage );
154extern void gl_vector1ui_free( GLvector1ui * );
155extern void gl_vector1ui_alloc( GLvector1ui *v, GLuint flags, GLuint count,
156 GLuint alignment );
157
158
159
160/* End up doing a lot of slow imuls if not careful.
161 */
162#define VEC_ELT( v, t, i ) ((t *) (((GLbyte *)((v)->data))+(i)*(v)->stride) )
163
164
165#endif
Note: See TracBrowser for help on using the repository browser.