2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 void R_InitTextures (void)
36 // create a simple checkerboard texture for the default
37 r_notexture_mip = Hunk_AllocName (sizeof(texture_t) + 16*16+8*8+4*4+2*2, "notexture");
39 r_notexture_mip->width = r_notexture_mip->height = 16;
40 r_notexture_mip->offsets[0] = sizeof(texture_t);
41 r_notexture_mip->offsets[1] = r_notexture_mip->offsets[0] + 16*16;
42 r_notexture_mip->offsets[2] = r_notexture_mip->offsets[1] + 8*8;
43 r_notexture_mip->offsets[3] = r_notexture_mip->offsets[2] + 4*4;
44 r_notexture_mip->transparent = FALSE;
48 dest = (byte *)r_notexture_mip + r_notexture_mip->offsets[m];
49 for (y=0 ; y< (16>>m) ; y++)
50 for (x=0 ; x< (16>>m) ; x++)
52 if ( (y< (8>>m) ) ^ (x< (8>>m) ) )
64 Grab six views for environment mapping tests
67 void R_Envmap_f (void)
69 byte buffer[256*256*4];
74 glDrawBuffer (GL_FRONT);
75 glReadBuffer (GL_FRONT);
80 r_refdef.vrect.width = 256;
81 r_refdef.vrect.height = 256;
83 r_refdef.viewangles[0] = 0;
84 r_refdef.viewangles[1] = 0;
85 r_refdef.viewangles[2] = 0;
86 GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
88 glReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
89 COM_WriteFile ("env0.rgb", buffer, sizeof(buffer));
91 r_refdef.viewangles[1] = 90;
92 GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
94 glReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
95 COM_WriteFile ("env1.rgb", buffer, sizeof(buffer));
97 r_refdef.viewangles[1] = 180;
98 GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
100 glReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
101 COM_WriteFile ("env2.rgb", buffer, sizeof(buffer));
103 r_refdef.viewangles[1] = 270;
104 GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
106 glReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
107 COM_WriteFile ("env3.rgb", buffer, sizeof(buffer));
109 r_refdef.viewangles[0] = -90;
110 r_refdef.viewangles[1] = 0;
111 GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
113 glReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
114 COM_WriteFile ("env4.rgb", buffer, sizeof(buffer));
116 r_refdef.viewangles[0] = 90;
117 r_refdef.viewangles[1] = 0;
118 GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
120 glReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
121 COM_WriteFile ("env5.rgb", buffer, sizeof(buffer));
124 glDrawBuffer (GL_BACK);
125 glReadBuffer (GL_BACK);
129 void R_InitParticles (void);
135 void gl_misc_shutdown()
144 void GL_Misc_Init (void)
146 Cmd_AddCommand ("timerefresh", R_TimeRefresh_f);
147 Cmd_AddCommand ("envmap", R_Envmap_f);
148 Cmd_AddCommand ("pointfile", R_ReadPointFile_f);
150 Cvar_RegisterVariable (&r_drawentities);
151 Cvar_RegisterVariable (&r_drawviewmodel);
152 Cvar_RegisterVariable (&r_shadows);
153 Cvar_RegisterVariable (&r_wateralpha);
154 Cvar_RegisterVariable (&r_dynamic);
155 Cvar_RegisterVariable (&r_novis);
156 Cvar_RegisterVariable (&r_speeds);
157 Cvar_RegisterVariable (&r_waterripple); // LordHavoc: added waterripple
159 R_RegisterModule("GL_Misc", gl_misc_start, gl_misc_shutdown);
162 //qboolean VID_Is8bit(void);
163 //void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap, qboolean alpha);
165 void R_ClearParticles (void);
166 void GL_BuildLightmaps (void);
173 void SHOWLMP_clear();
178 for (i=0 ; i<256 ; i++)
179 d_lightstylevalue[i] = 264; // normal light value
181 memset (&r_worldentity, 0, sizeof(r_worldentity));
182 r_worldentity.model = cl.worldmodel;
183 currententity = &r_worldentity;
185 // clear out efrags in case the level hasn't been reloaded
186 // FIXME: is this one short?
187 for (i=0 ; i<cl.worldmodel->numleafs ; i++)
188 cl.worldmodel->leafs[i].efrags = NULL;
193 GL_BuildLightmaps ();
195 // identify sky texture
197 for (i=0 ; i<cl.worldmodel->numtextures ; i++)
199 if (!cl.worldmodel->textures[i])
201 if (!strncmp(cl.worldmodel->textures[i]->name,"sky",3) )
203 cl.worldmodel->textures[i]->texturechain = NULL;
213 For program optimization
216 qboolean intimerefresh = 0;
217 void R_TimeRefresh_f (void)
220 float start, stop, time;
223 start = Sys_FloatTime ();
224 for (i=0 ; i<128 ; i++)
226 r_refdef.viewangles[1] = i/128.0*360.0;
230 stop = Sys_FloatTime ();
233 Con_Printf ("%f seconds (%f fps)\n", time, 128/time);