2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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.
27 * Vertex and fragment program support functions.
33 * \mainpage Mesa vertex and fragment program module
35 * This module or directory contains most of the code for vertex and
36 * fragment programs and shaders, including state management, parsers,
37 * and (some) software routines for executing programs
46 /* for GL_ARB_v_p and GL_ARB_f_p SWZ instruction */
51 #define SWIZZLE_ZERO 4 /* keep these values together: KW */
52 #define SWIZZLE_ONE 5 /* keep these values together: KW */
60 _mesa_init_program(GLcontext
*ctx
);
63 _mesa_free_program_data(GLcontext
*ctx
);
66 _mesa_set_program_error(GLcontext
*ctx
, GLint pos
, const char *string
);
68 extern const GLubyte
*
69 _mesa_find_line_column(const GLubyte
*string
, const GLubyte
*pos
,
70 GLint
*line
, GLint
*col
);
73 extern struct program
*
74 _mesa_init_vertex_program( GLcontext
*ctx
,
75 struct vertex_program
*prog
,
79 extern struct program
*
80 _mesa_init_fragment_program( GLcontext
*ctx
,
81 struct fragment_program
*prog
,
85 extern struct program
*
86 _mesa_new_program(GLcontext
*ctx
, GLenum target
, GLuint id
);
89 _mesa_delete_program(GLcontext
*ctx
, struct program
*prog
);
94 * Used for describing GL state referenced from inside ARB vertex and
96 * A string such as "state.light[0].ambient" gets translated into a
97 * sequence of tokens such as [ STATE_LIGHT, 0, STATE_AMBIENT ].
103 STATE_LIGHTMODEL_AMBIENT
,
104 STATE_LIGHTMODEL_SCENECOLOR
,
115 STATE_POINT_ATTENUATION
,
123 STATE_MATRIX_INVERSE
,
124 STATE_MATRIX_TRANSPOSE
,
125 STATE_MATRIX_INVTRANS
,
136 STATE_SPOT_DIRECTION
,
142 STATE_TEXGEN_OBJECT_S
,
143 STATE_TEXGEN_OBJECT_T
,
144 STATE_TEXGEN_OBJECT_R
,
145 STATE_TEXGEN_OBJECT_Q
,
151 STATE_VERTEX_PROGRAM
,
152 STATE_FRAGMENT_PROGRAM
,
161 * Named program parameters
162 * Used for NV_fragment_program "DEFINE"d constants and "DECLARE"d parameters,
163 * and ARB_fragment_program global state references. For the later, Name
164 * might be "state.light[0].diffuse", for example.
175 struct program_parameter
177 const char *Name
; /* Null-terminated */
178 enum parameter_type Type
;
179 enum state_index StateIndexes
[6]; /* Global state reference */
184 struct program_parameter_list
186 GLuint NumParameters
;
187 struct program_parameter
*Parameters
;
192 * Program parameter functions
195 extern struct program_parameter_list
*
196 _mesa_new_parameter_list(void);
199 _mesa_free_parameter_list(struct program_parameter_list
*paramList
);
202 _mesa_free_parameters(struct program_parameter_list
*paramList
);
205 _mesa_add_named_parameter(struct program_parameter_list
*paramList
,
206 const char *name
, const GLfloat values
[4]);
209 _mesa_add_named_constant(struct program_parameter_list
*paramList
,
210 const char *name
, const GLfloat values
[4]);
213 _mesa_add_unnamed_constant(struct program_parameter_list
*paramList
,
214 const GLfloat values
[4]);
217 _mesa_add_state_reference(struct program_parameter_list
*paramList
,
221 _mesa_lookup_parameter_value(struct program_parameter_list
*paramList
,
222 GLsizei nameLen
, const char *name
);
225 _mesa_lookup_parameter_index(struct program_parameter_list
*paramList
,
226 GLsizei nameLen
, const char *name
);
229 _mesa_load_state_parameters(GLcontext
*ctx
,
230 struct program_parameter_list
*paramList
);
237 extern void GLAPIENTRY
238 _mesa_BindProgram(GLenum target
, GLuint id
);
240 extern void GLAPIENTRY
241 _mesa_DeletePrograms(GLsizei n
, const GLuint
*ids
);
243 extern void GLAPIENTRY
244 _mesa_GenPrograms(GLsizei n
, GLuint
*ids
);
246 extern GLboolean GLAPIENTRY
247 _mesa_IsProgram(GLuint id
);
252 * GL_MESA_program_debug
256 _mesa_ProgramCallbackMESA(GLenum target
, GLprogramcallbackMESA callback
,
260 _mesa_GetProgramRegisterfvMESA(GLenum target
, GLsizei len
,
261 const GLubyte
*registerName
, GLfloat
*v
);
264 #endif /* PROGRAM_H */