UFO: Alien Invasion
Toggle main menu visibility
Loading...
Searching...
No Matches
r_corona.cpp
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
#include "
r_local.h
"
23
24
void
R_AddCorona
(
const
vec3_t
org,
float
radius,
const
vec3_t
color)
25
{
26
corona_t
* c;
27
28
if
(!
r_coronas
->integer)
29
return
;
30
31
if
(
refdef
.numCoronas ==
MAX_CORONAS
)
32
return
;
33
34
c = &
refdef
.coronas[
refdef
.numCoronas++];
35
36
VectorCopy
(org, c->
org
);
37
c->
radius
= radius;
38
VectorCopy
(color, c->
color
);
39
}
40
41
void
R_DrawCoronas
(
void
)
42
{
43
if
(!
r_coronas
->integer)
44
return
;
45
46
if
(!
refdef
.numCoronas)
47
return
;
48
49
R_EnableTexture
(&
texunit_diffuse
,
false
);
50
51
R_EnableColorArray
(
true
);
52
53
R_ResetArrayState
();
54
55
R_BlendFunc
(GL_ONE, GL_ONE);
56
57
for
(
int
k = 0; k <
refdef
.numCoronas; k++) {
58
const
corona_t
* c = &
refdef
.coronas[k];
59
int
verts, vertind;
60
61
if
(!c->
radius
)
62
continue
;
63
64
/* use at least 12 verts, more for larger coronas */
65
verts = 12 + c->
radius
/ 8;
66
67
memcpy(&
r_state
.color_array[0], c->
color
,
sizeof
(
vec3_t
));
68
r_state
.color_array[3] = 1.0f;
/* set origin color */
69
70
/* and the corner colors */
71
memset(&
r_state
.color_array[4], 0, verts * 2 *
sizeof
(
vec4_t
));
72
73
memcpy(&
r_state
.vertex_array_3d[0], c->
org
,
sizeof
(
vec3_t
));
74
vertind = 3;
/* and the origin */
75
76
for
(
int
i
= verts;
i
>= 0;
i
--) {
/* now draw the corners */
77
const
float
a = (
M_PI
* 2 / verts) *
i
;
78
vec3_t
v
;
79
80
for
(
int
j = 0; j < 3; j++)
81
v
[j] = c->
org
[j] +
r_locals
.right[j] * (
float
) cos(a) * c->
radius
+
r_locals
.up[j] * (float) sin(a)
82
* c->
radius
;
83
84
memcpy(&
r_state
.vertex_array_3d[vertind],
v
,
sizeof
(
vec3_t
));
85
vertind += 3;
86
}
87
88
glDrawArrays(GL_TRIANGLE_FAN, 0, vertind / 3);
89
90
refdef
.batchCount++;
91
}
92
93
R_BlendFunc
(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
94
95
R_EnableColorArray
(
false
);
96
97
R_EnableTexture
(&
texunit_diffuse
,
true
);
98
99
R_Color
(
nullptr
);
100
}
refdef
rendererData_t refdef
Definition
r_main.cpp:45
MAX_CORONAS
#define MAX_CORONAS
Definition
cl_renderer.h:53
R_Color
void R_Color(const vec4_t rgba)
Change the color to given value.
Definition
r_state.cpp:1011
M_PI
#define M_PI
Definition
mathlib.h:34
R_ResetArrayState
void R_ResetArrayState(void)
Definition
r_array.cpp:185
R_AddCorona
void R_AddCorona(const vec3_t org, float radius, const vec3_t color)
Definition
r_corona.cpp:24
R_DrawCoronas
void R_DrawCoronas(void)
Definition
r_corona.cpp:41
v
QGL_EXTERN int GLboolean GLfloat * v
Definition
r_gl.h:120
i
QGL_EXTERN GLint i
Definition
r_gl.h:113
r_local.h
local graphics definitions
r_coronas
cvar_t * r_coronas
Definition
r_main.cpp:109
r_locals
rlocals_t r_locals
Definition
r_main.cpp:49
r_state
rstate_t r_state
Definition
r_main.cpp:48
R_EnableTexture
void R_EnableTexture(gltexunit_t *texunit, bool enable)
Definition
r_state.cpp:303
R_BlendFunc
void R_BlendFunc(GLenum src, GLenum dest)
Definition
r_state.cpp:232
R_EnableColorArray
void R_EnableColorArray(bool enable)
Definition
r_state.cpp:332
texunit_diffuse
#define texunit_diffuse
Definition
r_state.h:68
corona_t
coronas are soft, alpha-blended, rounded polys
Definition
cl_renderer.h:47
corona_t::color
vec3_t color
Definition
cl_renderer.h:50
corona_t::org
vec3_t org
Definition
cl_renderer.h:48
corona_t::radius
float radius
Definition
cl_renderer.h:49
vec3_t
vec_t vec3_t[3]
Definition
ufotypes.h:39
vec4_t
vec_t vec4_t[4]
Definition
ufotypes.h:40
VectorCopy
#define VectorCopy(src, dest)
Definition
vector.h:51
src
client
renderer
r_corona.cpp
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.17.0