00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __R_PROGRAM_H__
00023 #define __R_PROGRAM_H__
00024
00025 #include "r_gl.h"
00026
00027
00028 typedef struct r_shader_s {
00029 GLenum type;
00030 GLuint id;
00031 char name[MAX_QPATH];
00032 } r_shader_t;
00033
00034 #define GL_UNIFORM 1
00035 #define GL_ATTRIBUTE 2
00036
00037 typedef struct r_progvar_s {
00038 GLint type;
00039 char name[MAX_QPATH];
00040 GLint location;
00041 } r_progvar_t;
00042
00043
00044
00045 #define MAX_PROGRAM_VARS 32
00046
00047
00048 typedef struct r_program_s {
00049 GLuint id;
00050 char name[MAX_VAR];
00051 r_shader_t *v;
00052 r_shader_t *f;
00053 r_progvar_t vars[MAX_PROGRAM_VARS];
00054 void (*init)(struct r_program_s *prog);
00055 void (*use)(struct r_program_s *prog);
00056 void *userdata;
00057 } r_program_t;
00058
00059 #define MAX_PROGRAMS 16
00060 #define MAX_SHADERS MAX_PROGRAMS * 2
00061
00062 void R_UseProgram(r_program_t *prog);
00063 void R_ShutdownPrograms(void);
00064 void R_InitPrograms(void);
00065
00067 #ifdef DEBUG
00068
00069 #define R_AttributePointer(x, y, z) R_AttributePointer_Debug(x, y, z, __FILE__, __LINE__)
00070 #define R_EnableAttribute(x) R_EnableAttribute_Debug(x, __FILE__, __LINE__)
00071 #define R_DisableAttribute(x) R_DisableAttribute_Debug(x, __FILE__, __LINE__)
00072
00073 #define R_ProgramParameter1f(x, y) R_ProgramParameter1f_Debug(x, y, __FILE__, __LINE__)
00074 #define R_ProgramParameter1fvs(x, y, z) R_ProgramParameter1fvs_Debug(x, y, z, __FILE__, __LINE__)
00075 #define R_ProgramParameter1i(x, y) R_ProgramParameter1i_Debug(x, y, __FILE__, __LINE__)
00076 #define R_ProgramParameter2fv(x, y) R_ProgramParameter2fv_Debug(x, y, __FILE__, __LINE__)
00077 #define R_ProgramParameter2fvs(x, y, z) R_ProgramParameter2fvs_Debug(x, y, z, __FILE__, __LINE__)
00078 #define R_ProgramParameter3fv(x, y) R_ProgramParameter3fv_Debug(x, y, __FILE__, __LINE__)
00079 #define R_ProgramParameter4fv(x, y) R_ProgramParameter4fv_Debug(x, y, __FILE__, __LINE__)
00080
00081 void R_AttributePointer_Debug(const char *name, GLuint size, const GLvoid *array , const char *file, int line);
00082 void R_EnableAttribute_Debug(const char *name , const char *file, int line);
00083 void R_DisableAttribute_Debug(const char *name , const char *file, int line);
00084
00085 void R_ProgramParameter1f_Debug(const char *name, GLfloat value , const char *file, int line);
00086 void R_ProgramParameter1fvs_Debug(const char *name, GLint size, GLfloat *value , const char *file, int line);
00087 void R_ProgramParameter1i_Debug(const char *name, GLint value , const char *file, int line);
00088 void R_ProgramParameter2fv_Debug(const char *name, GLfloat *value , const char *file, int line);
00089 void R_ProgramParameter2fvs_Debug(const char *name, GLint size, GLfloat *value , const char *file, int line);
00090 void R_ProgramParameter3fv_Debug(const char *name, GLfloat *value , const char *file, int line);
00091 void R_ProgramParameter4fv_Debug(const char *name, GLfloat *value , const char *file, int line);
00092
00093 #else
00094
00095 void R_AttributePointer(const char *name, GLuint size, const GLvoid *array);
00096 void R_EnableAttribute(const char *name);
00097 void R_DisableAttribute(const char *name);
00098
00099 void R_ProgramParameter1f(const char *name, GLfloat value);
00100 void R_ProgramParameter1fvs(const char *name, GLint size, GLfloat *value);
00101 void R_ProgramParameter1i(const char *name, GLint value);
00102 void R_ProgramParameter2fv(const char *name, GLfloat *value);
00103 void R_ProgramParameter2fvs(const char *name, GLint size, GLfloat *value);
00104 void R_ProgramParameter3fv(const char *name, GLfloat *value);
00105 void R_ProgramParameter4fv(const char *name, GLfloat *value);
00106
00107 #endif
00108
00109 void R_InitParticleProgram(r_program_t *prog);
00110 void R_UseParticleProgram(r_program_t *prog);
00111
00112 r_program_t *R_LoadProgram(const char *name, void *init, void *use);
00113 void R_RestartPrograms_f(void);
00114
00115 #endif