r_corona.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "r_local.h"
00023
00024 void R_AddCorona (const vec3_t org, float radius, const vec3_t color)
00025 {
00026 corona_t *c;
00027
00028 if (!r_coronas->value)
00029 return;
00030
00031 if (refdef.numCoronas == MAX_CORONAS)
00032 return;
00033
00034 c = &refdef.coronas[refdef.numCoronas++];
00035
00036 VectorCopy(org, c->org);
00037 c->radius = radius;
00038 VectorCopy(color, c->color);
00039 }
00040
00041 void R_DrawCoronas (void)
00042 {
00043 int i, j, k;
00044 vec3_t v;
00045
00046 if (!r_coronas->integer)
00047 return;
00048
00049 if (!refdef.numCoronas)
00050 return;
00051
00052 R_EnableTexture(&texunit_diffuse, qfalse);
00053
00054 R_EnableColorArray(qtrue);
00055
00056 R_ResetArrayState();
00057
00058 R_BlendFunc(GL_ONE, GL_ONE);
00059
00060 for (k = 0; k < refdef.numCoronas; k++) {
00061 const corona_t *c = &refdef.coronas[k];
00062 int verts, vertind;
00063
00064 if (!c->radius)
00065 continue;
00066
00067
00068 verts = 12 + c->radius / 8;
00069
00070 memcpy(&r_state.color_array[0], c->color, sizeof(vec3_t));
00071 r_state.color_array[3] = 1.0f;
00072
00073
00074 memset(&r_state.color_array[4], 0, verts * 2 * sizeof(vec4_t));
00075
00076 memcpy(&r_state.vertex_array_3d[0], c->org, sizeof(vec3_t));
00077 vertind = 3;
00078
00079 for (i = verts; i >= 0; i--) {
00080 const float a = (M_PI * 2 / verts) * i;
00081
00082 for (j = 0; j < 3; j++)
00083 v[j] = c->org[j] + r_locals.right[j] * (float) cos(a) * c->radius + r_locals.up[j] * (float) sin(a)
00084 * c->radius;
00085
00086 memcpy(&r_state.vertex_array_3d[vertind], v, sizeof(vec3_t));
00087 vertind += 3;
00088 }
00089
00090 glDrawArrays(GL_TRIANGLE_FAN, 0, vertind / 3);
00091 }
00092
00093 R_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00094
00095 R_EnableColorArray(qfalse);
00096
00097 R_EnableTexture(&texunit_diffuse, qtrue);
00098
00099 R_Color(NULL);
00100 }