Added GLAPIENTRY decorations for all first level OpenGL API function entry
[mesa.git] / src / mesa / main / program.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 5.1
4 *
5 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 /**
26 * \file program.c
27 * Vertex and fragment program support functions.
28 * \author Brian Paul
29 */
30
31
32 #ifndef PROGRAM_H
33 #define PROGRAM_H
34
35 #include "mtypes.h"
36
37
38 /* for GL_ARB_v_p and GL_ARB_f_p SWZ instruction */
39 #define SWIZZLE_ZERO 100
40 #define SWIZZLE_ONE 101
41
42
43 /*
44 * Internal functions
45 */
46
47 extern void
48 _mesa_init_program(GLcontext *ctx);
49
50 extern void
51 _mesa_set_program_error(GLcontext *ctx, GLint pos, const char *string);
52
53 extern const GLubyte *
54 _mesa_find_line_column(const GLubyte *string, const GLubyte *pos,
55 GLint *line, GLint *col);
56
57 extern struct program *
58 _mesa_alloc_program(GLcontext *ctx, GLenum target, GLuint id);
59
60 extern void
61 _mesa_delete_program(GLcontext *ctx, struct program *prog);
62
63
64
65 /*
66 * Used for describing GL state referenced from inside ARB vertex and
67 * fragment programs.
68 * A string such as "state.light[0].ambient" gets translated into a
69 * sequence of tokens such as [ STATE_LIGHT, 0, STATE_AMBIENT ].
70 */
71 enum state_index {
72 STATE_MATERIAL,
73
74 STATE_LIGHT,
75 STATE_LIGHTMODEL_AMBIENT,
76 STATE_LIGHTMODEL_SCENECOLOR,
77 STATE_LIGHTPROD,
78
79 STATE_TEXGEN,
80
81 STATE_FOG_COLOR,
82 STATE_FOG_PARAMS,
83
84 STATE_CLIPPLANE,
85
86 STATE_POINT_SIZE,
87 STATE_POINT_ATTENUATION,
88
89 STATE_MATRIX,
90 STATE_MODELVIEW,
91 STATE_PROJECTION,
92 STATE_MVP,
93 STATE_TEXTURE,
94 STATE_PROGRAM,
95 STATE_MATRIX_INVERSE,
96 STATE_MATRIX_TRANSPOSE,
97 STATE_MATRIX_INVTRANS,
98
99 STATE_AMBIENT,
100 STATE_DIFFUSE,
101 STATE_SPECULAR,
102 STATE_EMISSION,
103 STATE_SHININESS,
104 STATE_HALF,
105
106 STATE_POSITION,
107 STATE_ATTENUATION,
108 STATE_SPOT_DIRECTION,
109
110 STATE_TEXGEN_EYE_S,
111 STATE_TEXGEN_EYE_T,
112 STATE_TEXGEN_EYE_R,
113 STATE_TEXGEN_EYE_Q,
114 STATE_TEXGEN_OBJECT_S,
115 STATE_TEXGEN_OBJECT_T,
116 STATE_TEXGEN_OBJECT_R,
117 STATE_TEXGEN_OBJECT_Q,
118
119 STATE_TEXENV_COLOR,
120
121 STATE_DEPTH_RANGE,
122
123 STATE_VERTEX_PROGRAM,
124 STATE_FRAGMENT_PROGRAM,
125
126 STATE_ENV,
127 STATE_LOCAL
128 };
129
130
131
132 /*
133 * Named program parameters
134 * Used for NV_fragment_program "DEFINE"d constants and "DECLARE"d parameters,
135 * and ARB_fragment_program global state references. For the later, Name
136 * might be "state.light[0].diffuse", for example.
137 */
138
139 enum parameter_type
140 {
141 NAMED_PARAMETER,
142 CONSTANT,
143 STATE
144 };
145
146
147 struct program_parameter
148 {
149 const char *Name; /* Null-terminated */
150 enum parameter_type Type;
151 enum state_index StateIndexes[6]; /* Global state reference */
152 GLfloat Values[4];
153 };
154
155
156 struct program_parameter_list
157 {
158 GLuint NumParameters;
159 struct program_parameter *Parameters;
160 };
161
162
163 /*
164 * Program parameter functions
165 */
166
167 extern struct program_parameter_list *
168 _mesa_new_parameter_list(void);
169
170 extern void
171 _mesa_free_parameter_list(struct program_parameter_list *paramList);
172
173 extern void
174 _mesa_free_parameters(struct program_parameter_list *paramList);
175
176 extern GLint
177 _mesa_add_named_parameter(struct program_parameter_list *paramList,
178 const char *name, const GLfloat values[4]);
179
180 extern GLint
181 _mesa_add_named_constant(struct program_parameter_list *paramList,
182 const char *name, const GLfloat values[4]);
183
184 extern GLint
185 _mesa_add_unnamed_constant(struct program_parameter_list *paramList,
186 const GLfloat values[4]);
187
188 extern GLint
189 _mesa_add_state_reference(struct program_parameter_list *paramList,
190 GLint *stateTokens);
191
192 extern GLfloat *
193 _mesa_lookup_parameter_value(struct program_parameter_list *paramList,
194 GLsizei nameLen, const char *name);
195
196 extern GLint
197 _mesa_lookup_parameter_index(struct program_parameter_list *paramList,
198 GLsizei nameLen, const char *name);
199
200 extern void
201 _mesa_load_state_parameters(GLcontext *ctx,
202 struct program_parameter_list *paramList);
203
204
205 /*
206 * API functions
207 */
208
209 extern void GLAPIENTRY
210 _mesa_BindProgram(GLenum target, GLuint id);
211
212 extern void GLAPIENTRY
213 _mesa_DeletePrograms(GLsizei n, const GLuint *ids);
214
215 extern void GLAPIENTRY
216 _mesa_GenPrograms(GLsizei n, GLuint *ids);
217
218 extern GLboolean GLAPIENTRY
219 _mesa_IsProgram(GLuint id);
220
221
222
223 /*
224 * GL_MESA_program_debug
225 */
226
227 extern void
228 _mesa_ProgramCallbackMESA(GLenum target, GLprogramcallbackMESA callback,
229 GLvoid *data);
230
231 extern void
232 _mesa_GetProgramRegisterfvMESA(GLenum target, GLsizei len,
233 const GLubyte *registerName, GLfloat *v);
234
235
236 #endif /* PROGRAM_H */