-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgl_warp.c
More file actions
133 lines (106 loc) · 3.5 KB
/
Copy pathgl_warp.c
File metadata and controls
133 lines (106 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// gl_warp.c -- warping animation support
#include "quakedef.h"
cvar_t r_waterquality = {"r_waterquality", "12", CVAR_NONE};
/*
==============================================================================
RENDER-TO-FRAMEBUFFER WATER (adapted from fitzquake)
==============================================================================
*/
// speed up sin calculations - Ed
float turbsin[] =
{
#include "gl_warp_sin.h"
};
/*
=============
R_UpdateWarpTextures
each frame, update warping textures
=============
*/
void R_UpdateWarpTextures (void)
{
texture_t *tx;
int i;
float x, y, x2, warptess;
warptess = 128.0 / CLAMP(4.0, floor(r_waterquality.value), 64.0);
for (i=0; i<cl.worldmodel->numtextures; i++)
{
if (!(tx = cl.worldmodel->textures[i]))
continue;
if (tx->name[0] != '*')
continue;
if (!tx->update_warp)
continue;
// render warp
glViewport (glx, gly + glheight - warpimage_size, warpimage_size * (tx->glow ? 2 : 1), warpimage_size);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho (0, 128 * (tx->glow ? 2 : 1), 0, 128, -99999, 99999);
// glOrtho (0, 128, 0, 128, -99999, 99999);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
glDisable (GL_ALPHA_TEST); //FX new
GL_BindTexture (tx->base);
for (x=0.0; x<128.0; x=x2)
{
x2 = x + warptess;
glBegin (GL_TRIANGLE_STRIP);
for (y=0.0; y<128.01; y+=warptess) // .01 for rounding errors
{
glTexCoord2f (WARPCALC(x,y), WARPCALC(y,x));
glVertex2f (x,y);
glTexCoord2f (WARPCALC(x2,y), WARPCALC(y,x2));
glVertex2f (x2,y);
}
glEnd ();
}
if (tx->glow)
{
GL_BindTexture (tx->glow);
for (x=128.0; x<256.0; x=x2)
{
x2 = x + warptess;
glBegin (GL_TRIANGLE_STRIP);
for (y=0.0; y<128.01; y+=warptess) // .01 for rounding errors
{
glTexCoord2f (WARPCALC(x,y), WARPCALC(y,x));
glVertex2f (x,y);
glTexCoord2f (WARPCALC(x2,y), WARPCALC(y,x2));
glVertex2f (x2,y);
}
glEnd ();
}
}
glEnable (GL_ALPHA_TEST); //FX new
// copy to texture
GL_BindTexture (tx->warpbase);
glCopyTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, glx, gly + glheight - warpimage_size, warpimage_size, warpimage_size);
if (qglGenerateMipmap)
qglGenerateMipmap (GL_TEXTURE_2D);
if (tx->glow)
{
GL_BindTexture (tx->warpglow);
glCopyTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, glx + warpimage_size, gly + glheight - warpimage_size, warpimage_size, warpimage_size);
if (qglGenerateMipmap)
qglGenerateMipmap (GL_TEXTURE_2D);
}
tx->update_warp = false;
}
// if warp render went down into sbar territory, we need to be sure to refresh it next frame
if (warpimage_size + sb_lines > vid.height)
Sbar_Changed ();
}