UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
r_program.h
Go to the documentation of this file.
1 /*
2 * Copyright(c) 1997-2001 Id Software, Inc.
3 * Copyright(c) 2002 The Quakeforge Project.
4 * Copyright(c) 2006 Quake2World.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or(at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 *
15 * See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21 
22 #pragma once
23 
24 #include "r_gl.h"
25 
26 /* glsl vertex and fragment shaders */
27 typedef struct r_shader_s {
30  char name[MAX_QPATH];
31 } r_shader_t;
32 
33 #ifndef GL_UNIFORM
34 #define GL_UNIFORM 1
35 #endif
36 #define GL_ATTRIBUTE 2
37 /* program variables */
38 typedef struct r_progvar_s {
40  char name[MAX_QPATH];
42 } r_progvar_t;
43 
44 /* NOTE: OpenGL spec says we must be able to have at
45  * least 64 uniforms; may be more. glGet(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS) */
46 #define MAX_PROGRAM_VARS 32
47 
48 struct r_program_s;
49 
50 typedef void (*programInitFunc_t)(struct r_program_s* prog);
51 typedef void (*programUseFunc_t)(struct r_program_s* prog);
52 
53 /* and glsl programs */
54 typedef struct r_program_s {
56  char name[MAX_VAR];
62  void* userdata;
63 } r_program_t;
64 
65 #define MAX_PROGRAMS 16
66 #define MAX_SHADERS MAX_PROGRAMS * 2
67 
68 void R_UseProgram(r_program_t* prog);
69 void R_ShutdownPrograms(void);
70 void R_InitPrograms(void);
71 
72 void R_AttributePointer(const char* name, GLuint size, const GLvoid* array);
73 void R_EnableAttribute(const char* name);
74 void R_DisableAttribute(const char* name);
75 
76 void R_ProgramParameter1f(const char* name, GLfloat value);
77 void R_ProgramParameter1fvs(const char* name, GLint size, GLfloat* value);
78 void R_ProgramParameter1i(const char* name, GLint value);
79 void R_ProgramParameter2fv(const char* name, GLfloat* value);
80 void R_ProgramParameter2fvs(const char* name, GLint size, GLfloat* value);
81 void R_ProgramParameter3fv(const char* name, GLfloat* value);
82 void R_ProgramParameter3fvs(const char* name, GLint size, GLfloat* value);
83 void R_ProgramParameter4fv(const char* name, GLfloat* value);
84 void R_ProgramParameter4fvs(const char* name, GLint size, GLfloat* value);
85 void R_ProgramParameterMatrix4fv(const char* name, GLfloat* value);
86 
89 
91 void R_RestartPrograms_f(void);
void R_UseProgram(r_program_t *prog)
Definition: r_program.cpp:43
void R_ProgramParameter4fv(const char *name, GLfloat *value)
Definition: r_program.cpp:181
programInitFunc_t init
Definition: r_program.h:60
void * userdata
Definition: r_program.h:62
char name[MAX_QPATH]
Definition: r_program.h:30
programUseFunc_t use
Definition: r_program.h:61
void R_RestartPrograms_f(void)
Reloads the glsl shaders.
Definition: r_program.cpp:1058
void R_ProgramParameter1f(const char *name, GLfloat value)
Definition: r_program.cpp:121
r_shader_t * f
Definition: r_program.h:58
GLint location
Definition: r_program.h:41
const GLenum *typedef GLint
Definition: r_gl.h:205
void R_ProgramParameter2fvs(const char *name, GLint size, GLfloat *value)
Definition: r_program.cpp:151
char name[MAX_VAR]
Definition: r_program.h:56
void R_ProgramParameter3fv(const char *name, GLfloat *value)
Definition: r_program.cpp:161
void R_ProgramParameter1fvs(const char *name, GLint size, GLfloat *value)
Definition: r_program.cpp:131
GLint type
Definition: r_program.h:39
char name[MAX_QPATH]
Definition: r_program.h:40
void R_ProgramParameter1i(const char *name, GLint value)
Definition: r_program.cpp:111
void R_ShutdownPrograms(void)
Definition: r_program.cpp:265
QGL_EXTERN GLuint
Definition: r_gl.h:124
const GLuint *typedef GLuint *typedef GLenum
Definition: r_gl.h:190
void R_ProgramParameter2fv(const char *name, GLfloat *value)
Definition: r_program.cpp:141
r_progvar_t vars[MAX_PROGRAM_VARS]
Definition: r_program.h:59
r_shader_t * v
Definition: r_program.h:57
void(* programInitFunc_t)(struct r_program_s *prog)
Definition: r_program.h:50
void R_ProgramParameterMatrix4fv(const char *name, GLfloat *value)
Definition: r_program.cpp:201
GLsizei size
Definition: r_gl.h:152
#define MAX_VAR
Definition: shared.h:36
GLuint id
Definition: r_program.h:55
GLenum type
Definition: r_program.h:28
void R_InitPrograms(void)
Definition: r_program.cpp:1022
void(* programUseFunc_t)(struct r_program_s *prog)
Definition: r_program.h:51
struct r_shader_s r_shader_t
r_program_t * R_LoadProgram(const char *name, programInitFunc_t init, programUseFunc_t use)
Definition: r_program.cpp:684
struct r_progvar_s r_progvar_t
void R_AttributePointer(const char *name, GLuint size, const GLvoid *array)
Definition: r_program.cpp:211
void R_DisableAttribute(const char *name)
Definition: r_program.cpp:231
const GLuint *typedef void(APIENTRY *GenRenderbuffersEXT_t)(GLsizei
Definition: r_gl.h:189
void R_ProgramParameter3fvs(const char *name, GLint size, GLfloat *value)
Definition: r_program.cpp:171
void R_ProgramParameter4fvs(const char *name, GLint size, GLfloat *value)
Definition: r_program.cpp:191
struct r_program_s r_program_t
#define MAX_QPATH
Definition: filesys.h:40
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
void R_EnableAttribute(const char *name)
Definition: r_program.cpp:221
void R_InitParticleProgram(r_program_t *prog)
Definition: r_program.cpp:1012
void R_UseParticleProgram(r_program_t *prog)
Definition: r_program.cpp:1017
#define MAX_PROGRAM_VARS
Definition: r_program.h:46
GLuint id
Definition: r_program.h:29
OpenGL bindings.