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];
71 glDrawBuffer (GL_FRONT);
72 glReadBuffer (GL_FRONT);
77 r_refdef.vrect.width = 256;
78 r_refdef.vrect.height = 256;
80 r_refdef.viewangles[0] = 0;
81 r_refdef.viewangles[1] = 0;
82 r_refdef.viewangles[2] = 0;
83 GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
85 glReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
86 COM_WriteFile ("env0.rgb", buffer, sizeof(buffer));
88 r_refdef.viewangles[1] = 90;
89 GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
91 glReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
92 COM_WriteFile ("env1.rgb", buffer, sizeof(buffer));
94 r_refdef.viewangles[1] = 180;
95 GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
97 glReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
98 COM_WriteFile ("env2.rgb", buffer, sizeof(buffer));
100 r_refdef.viewangles[1] = 270;
101 GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
103 glReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
104 COM_WriteFile ("env3.rgb", buffer, sizeof(buffer));
106 r_refdef.viewangles[0] = -90;
107 r_refdef.viewangles[1] = 0;
108 GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
110 glReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
111 COM_WriteFile ("env4.rgb", buffer, sizeof(buffer));
113 r_refdef.viewangles[0] = 90;
114 r_refdef.viewangles[1] = 0;
115 GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
117 glReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
118 COM_WriteFile ("env5.rgb", buffer, sizeof(buffer));
121 glDrawBuffer (GL_BACK);
122 glReadBuffer (GL_BACK);
126 void R_InitParticles (void);
132 void gl_misc_shutdown()
141 void GL_Misc_Init (void)
143 Cmd_AddCommand ("timerefresh", R_TimeRefresh_f);
144 Cmd_AddCommand ("envmap", R_Envmap_f);
145 Cmd_AddCommand ("pointfile", R_ReadPointFile_f);
147 Cvar_RegisterVariable (&r_drawentities);
148 Cvar_RegisterVariable (&r_drawviewmodel);
149 Cvar_RegisterVariable (&r_shadows);
150 Cvar_RegisterVariable (&r_wateralpha);
151 Cvar_RegisterVariable (&r_dynamic);
152 Cvar_RegisterVariable (&r_novis);
153 Cvar_RegisterVariable (&r_speeds);
154 Cvar_RegisterVariable (&r_waterripple); // LordHavoc: added waterripple
156 R_RegisterModule("GL_Misc", gl_misc_start, gl_misc_shutdown);
159 //qboolean VID_Is8bit(void);
160 //void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap, qboolean alpha);
162 void R_ClearParticles (void);
163 void GL_BuildLightmaps (void);
170 void SHOWLMP_clear();
175 for (i=0 ; i<256 ; i++)
176 d_lightstylevalue[i] = 264; // normal light value
178 memset (&r_worldentity, 0, sizeof(r_worldentity));
179 r_worldentity.model = cl.worldmodel;
180 currententity = &r_worldentity;
182 // clear out efrags in case the level hasn't been reloaded
183 // FIXME: is this one short?
184 for (i=0 ; i<cl.worldmodel->numleafs ; i++)
185 cl.worldmodel->leafs[i].efrags = NULL;
190 GL_BuildLightmaps ();
192 // identify sky texture
194 for (i=0 ; i<cl.worldmodel->numtextures ; i++)
196 if (!cl.worldmodel->textures[i])
198 if (!strncmp(cl.worldmodel->textures[i]->name,"sky",3) )
200 cl.worldmodel->textures[i]->texturechain = NULL;
210 For program optimization
213 qboolean intimerefresh = 0;
214 void R_TimeRefresh_f (void)
217 float start, stop, time;
220 start = Sys_FloatTime ();
221 for (i=0 ; i<128 ; i++)
223 r_refdef.viewangles[1] = i/128.0*360.0;
227 stop = Sys_FloatTime ();
230 Con_Printf ("%f seconds (%f fps)\n", time, 128/time);