r_program.h

Go to the documentation of this file.
00001 /*
00002 * Copyright(c) 1997-2001 Id Software, Inc.
00003 * Copyright(c) 2002 The Quakeforge Project.
00004 * Copyright(c) 2006 Quake2World.
00005 *
00006 * This program is free software; you can redistribute it and/or
00007 * modify it under the terms of the GNU General Public License
00008 * as published by the Free Software Foundation; either version 2
00009 * of the License, or(at your option) any later version.
00010 *
00011 * This program is distributed in the hope that it will be useful,
00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00014 *
00015 * See the GNU General Public License for more details.
00016 *
00017 * You should have received a copy of the GNU General Public License
00018 * along with this program; if not, write to the Free Software
00019 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020 */
00021 
00022 #ifndef __R_PROGRAM_H__
00023 #define __R_PROGRAM_H__
00024 
00025 #include "r_gl.h"
00026 
00027 /* glsl vertex and fragment shaders */
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 /* program variables */
00037 typedef struct r_progvar_s {
00038     GLint type;
00039     char name[MAX_QPATH];
00040     GLint location;
00041 } r_progvar_t;
00042 
00043 /* NOTE: OpenGL spec says we must be able to have at 
00044  * least 64 uniforms; may be more.  glGet(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS) */
00045 #define MAX_PROGRAM_VARS 32
00046 
00047 /* and glsl programs */
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 /* don't pass file-line numbers for debugging */
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

Generated by  doxygen 1.6.2