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.
29 Grab six views for environment mapping tests
32 void R_Envmap_f (void)
34 byte buffer[256*256*4];
39 glDrawBuffer (GL_FRONT);
40 glReadBuffer (GL_FRONT);
45 r_refdef.vrect.width = 256;
46 r_refdef.vrect.height = 256;
48 r_refdef.viewangles[0] = 0;
49 r_refdef.viewangles[1] = 0;
50 r_refdef.viewangles[2] = 0;
52 glReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
53 COM_WriteFile ("env0.rgb", buffer, sizeof(buffer));
55 r_refdef.viewangles[1] = 90;
57 glReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
58 COM_WriteFile ("env1.rgb", buffer, sizeof(buffer));
60 r_refdef.viewangles[1] = 180;
62 glReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
63 COM_WriteFile ("env2.rgb", buffer, sizeof(buffer));
65 r_refdef.viewangles[1] = 270;
66 GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
68 glReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
69 COM_WriteFile ("env3.rgb", buffer, sizeof(buffer));
71 r_refdef.viewangles[0] = -90;
72 r_refdef.viewangles[1] = 0;
74 glReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
75 COM_WriteFile ("env4.rgb", buffer, sizeof(buffer));
77 r_refdef.viewangles[0] = 90;
78 r_refdef.viewangles[1] = 0;
80 glReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
81 COM_WriteFile ("env5.rgb", buffer, sizeof(buffer));
84 glDrawBuffer (GL_BACK);
85 glReadBuffer (GL_BACK);
89 void R_InitParticles (void);
91 void gl_misc_start(void)
95 void gl_misc_shutdown(void)
99 void gl_misc_newmap(void)
108 void GL_Misc_Init (void)
110 Cmd_AddCommand ("envmap", R_Envmap_f);
111 Cmd_AddCommand ("timerefresh", R_TimeRefresh_f);
113 R_RegisterModule("GL_Misc", gl_misc_start, gl_misc_shutdown, gl_misc_newmap);
116 extern void R_ClearParticles (void);
117 extern void GL_BuildLightmaps (void);
128 for (i=0 ; i<256 ; i++)
129 d_lightstylevalue[i] = 264; // normal light value
134 GL_BuildLightmaps ();
144 For program optimization
147 qboolean intimerefresh = 0;
148 void R_TimeRefresh_f (void)
151 float start, stop, time;
154 start = Sys_DoubleTime ();
155 for (i = 0;i < 128;i++)
157 r_refdef.viewangles[0] = 0;
158 r_refdef.viewangles[1] = i/128.0*360.0;
159 r_refdef.viewangles[2] = 0;
163 stop = Sys_DoubleTime ();
166 Con_Printf ("%f seconds (%f fps)\n", time, 128/time);