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()
139 void gl_misc_newmap()
148 void GL_Misc_Init (void)
150 Cmd_AddCommand ("envmap", R_Envmap_f);
151 Cmd_AddCommand ("timerefresh", R_TimeRefresh_f);
153 R_RegisterModule("GL_Misc", gl_misc_start, gl_misc_shutdown, gl_misc_newmap);
156 void R_ClearParticles (void);
157 void GL_BuildLightmaps (void);
164 void SHOWLMP_clear();
169 for (i=0 ; i<256 ; i++)
170 d_lightstylevalue[i] = 264; // normal light value
172 memset (&r_worldentity, 0, sizeof(r_worldentity));
173 r_worldentity.render.model = cl.worldmodel;
174 currententity = &r_worldentity;
176 // clear out efrags in case the level hasn't been reloaded
177 // FIXME: is this one short?
178 for (i=0 ; i<cl.worldmodel->numleafs ; i++)
179 cl.worldmodel->leafs[i].efrags = NULL;
184 GL_BuildLightmaps ();
186 // identify sky texture
188 for (i=0 ; i<cl.worldmodel->numtextures ; i++)
190 if (!cl.worldmodel->textures[i])
192 if (!strncmp(cl.worldmodel->textures[i]->name,"sky",3) )
194 cl.worldmodel->textures[i]->texturechain = NULL;
204 For program optimization
207 qboolean intimerefresh = 0;
208 void R_TimeRefresh_f (void)
211 float start, stop, time;
214 start = Sys_FloatTime ();
215 for (i=0 ; i<128 ; i++)
217 r_refdef.viewangles[1] = i/128.0*360.0;
221 stop = Sys_FloatTime ();
224 Con_Printf ("%f seconds (%f fps)\n", time, 128/time);