void R_AttributePointer (const char* name, GLuint size, const GLvoid* array) { r_progvar_t* v; if (!(v = R_ProgramVariable(GL_ATTRIBUTE, name))) return; qglVertexAttribPointer(v->location, size, GL_FLOAT, GL_FALSE, 0, array); }
void R_DisableAttribute (const char* name) { r_progvar_t* v; if (!(v = R_ProgramVariable(GL_ATTRIBUTE, name))) return; qglDisableVertexAttribArray(v->location); }
void R_ProgramParameter4fvs (const char* name, GLint size, GLfloat* value) { r_progvar_t* v; if (!(v = R_ProgramVariable(GL_UNIFORM, name))) return; qglUniform4fv(v->location, size, value); }
void R_ProgramParameterMatrix4fv (const char* name, GLfloat* value) { r_progvar_t* v; if (!(v = R_ProgramVariable(GL_UNIFORM, name))) return; qglUniformMatrix4fv(v->location, 1, GL_FALSE, value); }
/* * @brief */ void R_AttributePointer(const char *name, GLuint size, GLvoid *array) { r_attribute_t attribute; R_ProgramVariable(&attribute, R_ATTRIBUTE, name); qglVertexAttribPointer(attribute.location, size, GL_FLOAT, GL_FALSE, 0, array); R_GetError(name); }
void R_ProgramParameter1f (const char* name, GLfloat value) { r_progvar_t* v; if (!(v = R_ProgramVariable(GL_UNIFORM, name))) return; qglUniform1f(v->location, value); }
/** * @brief */ void R_InitProgram_shell(r_program_t *program) { r_shell_program_t *p = &r_shell_program; R_ProgramVariable(&program->attributes[R_ATTRIB_POSITION], R_ATTRIBUTE, "POSITION", true); R_ProgramVariable(&program->attributes[R_ATTRIB_NORMAL], R_ATTRIBUTE, "NORMAL", true); R_ProgramVariable(&program->attributes[R_ATTRIB_DIFFUSE], R_ATTRIBUTE, "TEXCOORD", true); R_ProgramVariable(&program->attributes[R_ATTRIB_NEXT_POSITION], R_ATTRIBUTE, "NEXT_POSITION", true); R_ProgramVariable(&program->attributes[R_ATTRIB_NEXT_NORMAL], R_ATTRIBUTE, "NEXT_NORMAL", true); R_ProgramVariable(&p->offset, R_UNIFORM_FLOAT, "OFFSET", true); R_ProgramParameter1f(&p->offset, 0.0); R_ProgramVariable(&p->shell_offset, R_UNIFORM_FLOAT, "SHELL_OFFSET", true); R_ProgramParameter1f(&p->shell_offset, 0.0); R_ProgramVariable(&p->sampler0, R_SAMPLER_2D, "SAMPLER0", true); R_ProgramParameter1i(&p->sampler0, R_TEXUNIT_DIFFUSE); R_ProgramVariable(&p->time_fraction, R_UNIFORM_FLOAT, "TIME_FRACTION", true); R_ProgramParameter1f(&p->time_fraction, 0.0f); }
/** * @brief */ void R_InitProgram_stain(r_program_t *program) { R_ProgramVariable(&program->attributes[R_ATTRIB_POSITION], R_ATTRIBUTE, "POSITION", true); R_ProgramVariable(&program->attributes[R_ATTRIB_COLOR], R_ATTRIBUTE, "COLOR", true); R_ProgramVariable(&program->attributes[R_ATTRIB_DIFFUSE], R_ATTRIBUTE, "TEXCOORD", true); }
/** * @brief */ void R_InitProgram_default(r_program_t *program) { r_default_program_t *p = &r_default_program; p->program = program; R_ProgramVariable(&program->attributes[R_ARRAY_POSITION], R_ATTRIBUTE, "POSITION", true); R_ProgramVariable(&program->attributes[R_ARRAY_COLOR], R_ATTRIBUTE, "COLOR", true); R_ProgramVariable(&program->attributes[R_ARRAY_DIFFUSE], R_ATTRIBUTE, "TEXCOORD0", true); R_ProgramVariable(&program->attributes[R_ARRAY_LIGHTMAP], R_ATTRIBUTE, "TEXCOORD1", true); R_ProgramVariable(&program->attributes[R_ARRAY_NORMAL], R_ATTRIBUTE, "NORMAL", true); R_ProgramVariable(&program->attributes[R_ARRAY_TANGENT], R_ATTRIBUTE, "TANGENT", true); R_ProgramVariable(&program->attributes[R_ARRAY_NEXT_POSITION], R_ATTRIBUTE, "NEXT_POSITION", true); R_ProgramVariable(&program->attributes[R_ARRAY_NEXT_NORMAL], R_ATTRIBUTE, "NEXT_NORMAL", true); R_ProgramVariable(&program->attributes[R_ARRAY_NEXT_TANGENT], R_ATTRIBUTE, "NEXT_TANGENT", true); R_ProgramVariable(&p->diffuse, R_UNIFORM_INT, "DIFFUSE", true); R_ProgramVariable(&p->lightmap, R_UNIFORM_INT, "LIGHTMAP", true); R_ProgramVariable(&p->normalmap, R_UNIFORM_INT, "NORMALMAP", true); R_ProgramVariable(&p->glossmap, R_UNIFORM_INT, "GLOSSMAP", true); R_ProgramVariable(&p->bump, R_UNIFORM_FLOAT, "BUMP", true); R_ProgramVariable(&p->parallax, R_UNIFORM_FLOAT, "PARALLAX", true); R_ProgramVariable(&p->hardness, R_UNIFORM_FLOAT, "HARDNESS", true); R_ProgramVariable(&p->specular, R_UNIFORM_FLOAT, "SPECULAR", true); R_ProgramVariable(&p->sampler0, R_SAMPLER_2D, "SAMPLER0", true); R_ProgramVariable(&p->sampler1, R_SAMPLER_2D, "SAMPLER1", true); R_ProgramVariable(&p->sampler2, R_SAMPLER_2D, "SAMPLER2", true); R_ProgramVariable(&p->sampler3, R_SAMPLER_2D, "SAMPLER3", true); R_ProgramVariable(&p->sampler4, R_SAMPLER_2D, "SAMPLER4", true); R_ProgramVariable(&p->fog.start, R_UNIFORM_FLOAT, "FOG.START", true); R_ProgramVariable(&p->fog.end, R_UNIFORM_FLOAT, "FOG.END", true); R_ProgramVariable(&p->fog.color, R_UNIFORM_VEC3, "FOG.COLOR", true); R_ProgramVariable(&p->fog.density, R_UNIFORM_FLOAT, "FOG.DENSITY", true); if (r_state.max_active_lights) { p->lights = Mem_TagMalloc(sizeof(r_uniform_light_t) * r_state.max_active_lights, MEM_TAG_RENDERER); for (int32_t i = 0; i < r_state.max_active_lights; ++i) { R_ProgramVariable(&p->lights[i].origin, R_UNIFORM_VEC3, va("LIGHTS.ORIGIN[%i]", i), true); R_ProgramVariable(&p->lights[i].color, R_UNIFORM_VEC3, va("LIGHTS.COLOR[%i]", i), true); R_ProgramVariable(&p->lights[i].radius, R_UNIFORM_FLOAT, va("LIGHTS.RADIUS[%i]", i), true); } R_ProgramParameter1f(&p->lights[0].radius, 0.0); } else { p->lights = NULL; } R_ProgramVariable(&p->caustic.enable, R_UNIFORM_INT, "CAUSTIC.ENABLE", true); R_ProgramVariable(&p->caustic.color, R_UNIFORM_VEC3, "CAUSTIC.COLOR", true); R_ProgramVariable(&p->normal_mat, R_UNIFORM_MAT4, "NORMAL_MAT", true); R_ProgramVariable(&p->alpha_threshold, R_UNIFORM_FLOAT, "ALPHA_THRESHOLD", true); R_ProgramVariable(&p->time_fraction, R_UNIFORM_FLOAT, "TIME_FRACTION", true); R_ProgramVariable(&p->time, R_UNIFORM_FLOAT, "TIME", true); R_ProgramParameter1i(&p->lightmap, 0); R_ProgramParameter1i(&p->normalmap, 0); R_ProgramParameter1i(&p->glossmap, 0); R_ProgramParameter1f(&p->bump, 1.0); R_ProgramParameter1f(&p->parallax, 1.0); R_ProgramParameter1f(&p->hardness, 1.0); R_ProgramParameter1f(&p->specular, 1.0); R_ProgramParameter1i(&p->sampler0, R_TEXUNIT_DIFFUSE); R_ProgramParameter1i(&p->sampler1, R_TEXUNIT_LIGHTMAP); R_ProgramParameter1i(&p->sampler2, R_TEXUNIT_DELUXEMAP); R_ProgramParameter1i(&p->sampler3, R_TEXUNIT_NORMALMAP); R_ProgramParameter1i(&p->sampler4, R_TEXUNIT_SPECULARMAP); R_ProgramParameter1f(&p->fog.density, 0.0); R_ProgramParameter1f(&p->alpha_threshold, ALPHA_TEST_DISABLED_THRESHOLD); R_ProgramParameter1i(&p->caustic.enable, 0); R_ProgramParameter1f(&p->time_fraction, 0.0f); R_ProgramParameter1f(&p->time, 0.0f); }
/** * @brief */ void R_InitProgram_null(r_program_t *program) { r_null_program_t *p = &r_null_program; R_ProgramVariable(&program->attributes[R_ATTRIB_POSITION], R_ATTRIBUTE, "POSITION", true); R_ProgramVariable(&program->attributes[R_ATTRIB_COLOR], R_ATTRIBUTE, "COLOR", true); R_ProgramVariable(&program->attributes[R_ATTRIB_DIFFUSE], R_ATTRIBUTE, "TEXCOORD", true); R_ProgramVariable(&program->attributes[R_ATTRIB_NEXT_POSITION], R_ATTRIBUTE, "NEXT_POSITION", true); R_ProgramVariable(&p->tintmap, R_UNIFORM_INT, "TINTMAP", true); R_ProgramVariable(&p->sampler0, R_SAMPLER_2D, "SAMPLER0", true); R_ProgramVariable(&p->sampler6, R_SAMPLER_2D, "SAMPLER6", true); R_ProgramVariable(&p->fog.start, R_UNIFORM_FLOAT, "FOG.START", true); R_ProgramVariable(&p->fog.end, R_UNIFORM_FLOAT, "FOG.END", true); R_ProgramVariable(&p->fog.color, R_UNIFORM_VEC3, "FOG.COLOR", true); R_ProgramVariable(&p->fog.density, R_UNIFORM_FLOAT, "FOG.DENSITY", true); for (int32_t i = 0; i < TINT_TOTAL; i++) { R_ProgramVariable(&p->tints[i], R_UNIFORM_VEC4, va("TINTS[%i]", i), true); } R_ProgramVariable(&p->time_fraction, R_UNIFORM_FLOAT, "TIME_FRACTION", true); R_ProgramParameter1i(&p->tintmap, 0); R_ProgramParameter1i(&p->sampler0, R_TEXUNIT_DIFFUSE); R_ProgramParameter1i(&p->sampler6, R_TEXUNIT_TINTMAP); R_ProgramParameter1f(&p->fog.density, 0.0); R_ProgramParameter1f(&p->time_fraction, 0.0f); }
/** * @brief */ void R_InitProgram_null(r_program_t *program) { r_null_program_t *p = &r_null_program; R_ProgramVariable(&program->attributes[R_ARRAY_POSITION], R_ATTRIBUTE, "POSITION", true); R_ProgramVariable(&program->attributes[R_ARRAY_COLOR], R_ATTRIBUTE, "COLOR", true); R_ProgramVariable(&program->attributes[R_ARRAY_DIFFUSE], R_ATTRIBUTE, "TEXCOORD", true); R_ProgramVariable(&program->attributes[R_ARRAY_NEXT_POSITION], R_ATTRIBUTE, "NEXT_POSITION", true); R_ProgramVariable(&p->sampler0, R_SAMPLER_2D, "SAMPLER0", true); R_ProgramVariable(&p->fog.start, R_UNIFORM_FLOAT, "FOG.START", true); R_ProgramVariable(&p->fog.end, R_UNIFORM_FLOAT, "FOG.END", true); R_ProgramVariable(&p->fog.color, R_UNIFORM_VEC3, "FOG.COLOR", true); R_ProgramVariable(&p->fog.density, R_UNIFORM_FLOAT, "FOG.DENSITY", true); R_ProgramVariable(&p->current_color, R_UNIFORM_VEC4, "GLOBAL_COLOR", true); R_ProgramVariable(&p->time_fraction, R_UNIFORM_FLOAT, "TIME_FRACTION", true); R_ProgramParameter1i(&p->sampler0, R_TEXUNIT_DIFFUSE); R_ProgramParameter1f(&p->fog.density, 0.0); const vec4_t white = { 1.0, 1.0, 1.0, 1.0 }; R_ProgramParameter4fv(&p->current_color, white); R_ProgramParameter1f(&p->time_fraction, 0.0f); }