]> icculus.org git repositories - btb/d2x.git/blob - arch/ogl/gr.c
Finished moving stuff to arch/blah. I know, it's ugly, but It'll be easier to sync...
[btb/d2x.git] / arch / ogl / gr.c
1 /*
2  * $Source: /cvs/cvsroot/d2x/arch/ogl/gr.c,v $
3  * $Revision: 1.1 $
4  * $Author: bradleyb $
5  * $Date: 2001-10-25 08:25:34 $
6  *
7  * // OGL video functions. - Added 9/15/99 Matthew Mueller
8  *
9  * $Log: not supported by cvs2svn $
10  * Revision 1.7  2001/10/25 02:23:48  bradleyb
11  * formatting fix
12  *
13  * Revision 1.6  2001/10/18 23:59:23  bradleyb
14  * Changed __ENV_LINUX__ to __linux__
15  *
16  * Revision 1.5  2001/10/12 00:18:40  bradleyb
17  * Switched from Cygwin to mingw32 on MS boxes.  Vastly improved compilability.
18  *
19  * Revision 1.4  2001/01/29 13:47:52  bradleyb
20  * Fixed build, some minor cleanups.
21  *
22  */
23
24 #ifdef HAVE_CONFIG_H
25 #include <conf.h>
26 #endif
27
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <string.h>
31 #ifdef __WINDOWS__
32 #include <windows.h>
33 #endif
34
35 //#include <GL/gl.h>
36 #include <unistd.h>
37 #include <sys/types.h>
38 #include <sys/stat.h>
39 #include <fcntl.h>
40 #include <errno.h>
41
42 #include "game.h"
43 #include "text.h"
44 #include "gr.h"
45 #include "gamefont.h"
46 #include "grdef.h"
47 #include "palette.h"
48 #include "u_mem.h"
49 #include "error.h"
50
51 #include "inferno.h"
52 #include "screens.h"
53
54 #include "strutil.h"
55 #include "mono.h"
56 #include "args.h"
57 #include "key.h"
58
59 #include "gamefont.h"
60
61 #define DECLARE_VARS
62 #include "ogl_init.h"
63 #include <GL/glu.h>
64
65 int ogl_voodoohack=0;
66
67 int gr_installed = 0;
68
69
70 void gr_palette_clear(); // Function prototype for gr_init;
71 int gl_initialized=0;
72 int gl_reticle=1;
73
74 int ogl_fullscreen=0;
75 int gr_check_fullscreen(void){
76         return ogl_fullscreen;
77 }
78 void gr_do_fullscreen(int f){
79         if (ogl_voodoohack)
80                 ogl_fullscreen=1;//force fullscreen mode on voodoos.
81         else
82                 ogl_fullscreen=f;
83         if (gl_initialized){
84                 ogl_do_fullscreen_internal();
85         }
86 }
87 int gr_toggle_fullscreen(void){
88         gr_do_fullscreen(!ogl_fullscreen);
89         //      grd_curscreen->sc_mode=0;//hack to get it to reset screen mode
90         return ogl_fullscreen;
91 }
92
93
94 void ogl_init_state(void){
95         /* select clearing (background) color   */
96         glClearColor(0.0, 0.0, 0.0, 0.0);
97         glShadeModel(GL_SMOOTH);
98
99         /* initialize viewing values */
100         glMatrixMode(GL_PROJECTION);
101         glLoadIdentity();
102         glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
103         glScalef(1.0, -1.0, 1.0);
104         glTranslatef(0.0, -1.0, 0.0);
105         gr_palette_step_up(0,0,0);//in case its left over from in game
106 }
107
108 int last_screen_mode=-1;
109 void ogl_set_screen_mode(void){
110         if (last_screen_mode==Screen_mode)
111                 return;
112         OGL_VIEWPORT(0,0,grd_curscreen->sc_w,grd_curscreen->sc_h);
113 //      OGL_VIEWPORT(grd_curcanv->cv_bitmap.bm_x,grd_curcanv->cv_bitmap.bm_y,grd_curcanv->cv_bitmap.bm_w,grd_curcanv->cv_bitmap.bm_h);
114         if (Screen_mode==SCREEN_GAME){
115                 glDrawBuffer(GL_BACK);
116         }else{
117                 glClearColor(0.0, 0.0, 0.0, 0.0);
118                 glDrawBuffer(GL_FRONT);
119                 glClear(GL_COLOR_BUFFER_BIT);
120                 glMatrixMode(GL_PROJECTION);
121                 glLoadIdentity();//clear matrix
122                 glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
123                 glMatrixMode(GL_MODELVIEW);
124                 glLoadIdentity();//clear matrix
125                 glEnable(GL_BLEND);
126                 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
127         }
128         last_screen_mode=Screen_mode;
129 }
130 void gr_update()
131 {
132         if (gl_initialized){
133
134                 if(Screen_mode != SCREEN_GAME){
135                         glFlush();
136                 }
137         }
138 }
139
140 const char *gl_vendor,*gl_renderer,*gl_version,*gl_extensions;
141 void ogl_get_verinfo(void){
142         int t;
143         gl_vendor=glGetString(GL_VENDOR);
144         gl_renderer=glGetString(GL_RENDERER);
145         gl_version=glGetString(GL_VERSION);
146         gl_extensions=glGetString(GL_EXTENSIONS);
147         
148         printf("gl vendor:%s renderer:%s version:%s extensions:%s\n",gl_vendor,gl_renderer,gl_version,gl_extensions);
149
150         ogl_intensity4_ok=1;ogl_luminance4_alpha4_ok=1;ogl_rgba2_ok=1;
151         
152         //add driver specific hacks here.  whee.
153         if (stricmp(gl_renderer,"Mesa NVIDIA RIVA 1.0\n")==0 && stricmp(gl_version,"1.2 Mesa 3.0")==0){
154                 ogl_intensity4_ok=0;//ignores alpha, always black background instead of transparent.
155                 ogl_readpixels_ok=0;//either just returns all black, or kills the X server entirely
156         }
157
158         //allow overriding of stuff.
159         if ((t=FindArg("-gl_intensity4_ok"))){
160                 ogl_intensity4_ok=atoi(Args[t+1]);
161         }
162         if ((t=FindArg("-gl_luminance4_alpha4_ok"))){
163                 ogl_luminance4_alpha4_ok=atoi(Args[t+1]);
164         }
165         if ((t=FindArg("-gl_rgba2_ok"))){
166                 ogl_rgba2_ok=atoi(Args[t+1]);
167         }
168         if ((t=FindArg("-gl_readpixels_ok"))){
169                 ogl_readpixels_ok=atoi(Args[t+1]);
170         }
171
172         printf("gl_intensity4:%i gl_luminance4_alpha4:%i gl_rgba2:%i gl_readpixels:%i\n",ogl_intensity4_ok,ogl_luminance4_alpha4_ok,ogl_rgba2_ok,ogl_readpixels_ok);
173 }
174
175 int gr_set_mode(u_int32_t mode)
176 {
177         unsigned int w,h;
178
179 #ifdef NOGRAPH
180 return 0;
181 #endif
182 //      mode=0;
183         if (mode<=0)
184                 return 0;
185
186         w=SM_W(mode);
187         h=SM_H(mode);
188
189         //if (screen != NULL) gr_palette_clear();
190
191 //      ogl_init_state();
192         
193         memset( grd_curscreen, 0, sizeof(grs_screen));
194         grd_curscreen->sc_mode = mode;
195         grd_curscreen->sc_w = w;
196         grd_curscreen->sc_h = h;
197         grd_curscreen->sc_aspect = fixdiv(grd_curscreen->sc_w*3,grd_curscreen->sc_h*4);
198         grd_curscreen->sc_canvas.cv_bitmap.bm_x = 0;
199         grd_curscreen->sc_canvas.cv_bitmap.bm_y = 0;
200         grd_curscreen->sc_canvas.cv_bitmap.bm_w = w;
201         grd_curscreen->sc_canvas.cv_bitmap.bm_h = h;
202         //grd_curscreen->sc_canvas.cv_bitmap.bm_rowsize = screen->pitch;
203         grd_curscreen->sc_canvas.cv_bitmap.bm_rowsize = w;
204         grd_curscreen->sc_canvas.cv_bitmap.bm_type = BM_OGL;
205         //grd_curscreen->sc_canvas.cv_bitmap.bm_data = (unsigned char *)screen->pixels;
206         grd_curscreen->sc_canvas.cv_bitmap.bm_data = realloc(grd_curscreen->sc_canvas.cv_bitmap.bm_data,w*h);
207         gr_set_current_canvas(NULL);
208         //gr_enable_default_palette_loading();
209         
210         ogl_init_window(w,h);//platform specific code
211
212         ogl_get_verinfo();
213
214         OGL_VIEWPORT(0,0,w,h);
215
216         ogl_set_screen_mode();
217
218         //gamefont_choose_game_font(w,h);
219         
220         return 0;
221 }
222
223 #define GLstrcmptestr(a,b) if (stricmp(a,#b)==0 || stricmp(a,"GL_" #b)==0)return GL_ ## b;
224 int ogl_atotexfilti(char *a,int min){
225         GLstrcmptestr(a,NEAREST);
226         GLstrcmptestr(a,LINEAR);
227         if (min){//mipmaps are valid only for the min filter
228                 GLstrcmptestr(a,NEAREST_MIPMAP_NEAREST);
229                 GLstrcmptestr(a,NEAREST_MIPMAP_LINEAR);
230                 GLstrcmptestr(a,LINEAR_MIPMAP_NEAREST);
231                 GLstrcmptestr(a,LINEAR_MIPMAP_LINEAR);
232         }
233         Error("unknown/invalid texture filter %s\n",a);
234 //      return GL_NEAREST;
235 }
236 int ogl_testneedmipmaps(int i){
237         switch (i){
238                 case GL_NEAREST:
239                 case GL_LINEAR:
240                         return 0;
241                 case GL_NEAREST_MIPMAP_NEAREST:
242                 case GL_NEAREST_MIPMAP_LINEAR:
243                 case GL_LINEAR_MIPMAP_NEAREST:
244                 case GL_LINEAR_MIPMAP_LINEAR:
245                         return 1;
246         }
247         Error("unknown texture filter %x\n",i);
248 //      return -1;
249 }
250 #ifdef OGL_RUNTIME_LOAD
251 #if defined(__WINDOWS__) || defined(__MINGW32__)
252 char *OglLibPath="opengl32.dll";
253 #else
254 char *OglLibPath="libGL.so";
255 #endif
256
257 int ogl_rt_loaded=0;
258 int ogl_init_load_library(void)
259 {
260         int retcode=0;
261         if (!ogl_rt_loaded){
262                 int t;
263                 if ((t=FindArg("-gl_library")))
264                         OglLibPath=Args[t+1];
265
266                 retcode = OpenGL_LoadLibrary(true);
267                 if(retcode)
268                 {
269                         mprintf((0,"Opengl loaded ok\n"));
270         
271                         if(!glEnd)
272                         {
273                                 Error("Opengl: Functions not imported\n");
274                         }
275                 }else{
276                         Error("Opengl: error loading %s\n",OglLibPath);
277                 }
278                 ogl_rt_loaded=1;
279         }
280         return retcode;
281 }
282 #endif
283
284 int gr_init()
285 {
286  int mode = SM(640,480);
287  int retcode,t,glt=0;
288         // Only do this function once!
289         if (gr_installed==1)
290                 return -1;
291
292
293 #ifdef OGL_RUNTIME_LOAD
294         ogl_init_load_library();
295 #endif
296
297 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
298         if (FindArg("-gl_voodoo")){
299                 ogl_voodoohack=1;
300                 gr_toggle_fullscreen();
301         }
302         if (FindArg("-fullscreen"))
303                 gr_toggle_fullscreen();
304 #endif
305         if ((glt=FindArg("-gl_alttexmerge")))
306                 ogl_alttexmerge=1;
307         if ((t=FindArg("-gl_stdtexmerge")))
308                 if (t>=glt)//allow overriding of earlier args
309                         ogl_alttexmerge=0;
310                         
311         if ((glt=FindArg("-gl_16bittextures")))
312                 ogl_rgba_format=GL_RGB5_A1;
313
314         if ((glt=FindArg("-gl_mipmap"))){
315                 GL_texmagfilt=GL_LINEAR;
316                 GL_texminfilt=GL_LINEAR_MIPMAP_NEAREST;
317         }
318         if ((t=FindArg("-gl_simple"))){
319                 if (t>=glt){//allow overriding of earlier args
320                         glt=t;
321                         GL_texmagfilt=GL_NEAREST;
322                         GL_texminfilt=GL_NEAREST;
323                 }
324         }
325         if ((t=FindArg("-gl_texmagfilt")) || (t=FindArg("-gl_texmagfilter"))){
326                 if (t>=glt)//allow overriding of earlier args
327                         GL_texmagfilt=ogl_atotexfilti(Args[t+1],0);
328         }
329         if ((t=FindArg("-gl_texminfilt")) || (t=FindArg("-gl_texminfilter"))){
330                 if (t>=glt)//allow overriding of earlier args
331                         GL_texminfilt=ogl_atotexfilti(Args[t+1],1);
332         }
333         GL_needmipmaps=ogl_testneedmipmaps(GL_texminfilt);
334         mprintf((0,"gr_init: texmagfilt:%x texminfilt:%x needmipmaps=%i\n",GL_texmagfilt,GL_texminfilt,GL_needmipmaps));
335         
336         if ((t=FindArg("-gl_vidmem"))){
337                 ogl_mem_target=atoi(Args[t+1])*1024*1024;
338         }
339         if ((t=FindArg("-gl_reticle"))){
340                 gl_reticle=atoi(Args[t+1]);
341         }
342         //printf("ogl_mem_target=%i\n",ogl_mem_target);
343         
344         ogl_init();//platform specific initialization
345
346         ogl_init_texture_list_internal();
347                 
348         MALLOC( grd_curscreen,grs_screen,1 );
349         memset( grd_curscreen, 0, sizeof(grs_screen));
350         grd_curscreen->sc_canvas.cv_bitmap.bm_data = NULL;
351
352         // Set the mode.
353         if ((retcode=gr_set_mode(mode)))
354         {
355                 return retcode;
356         }
357         grd_curscreen->sc_canvas.cv_color = 0;
358         grd_curscreen->sc_canvas.cv_drawmode = 0;
359         grd_curscreen->sc_canvas.cv_font = NULL;
360         grd_curscreen->sc_canvas.cv_font_fg_color = 0;
361         grd_curscreen->sc_canvas.cv_font_bg_color = 0;
362         gr_set_current_canvas( &grd_curscreen->sc_canvas );
363
364         gr_installed = 1;
365         
366         atexit(gr_close);
367
368         return 0;
369 }
370
371 void gr_close()
372 {
373 //      mprintf((0,"ogl init: %s %s %s - %s\n",glGetString(GL_VENDOR),glGetString(GL_RENDERER),glGetString(GL_VERSION),glGetString,(GL_EXTENSIONS)));
374
375         ogl_close();//platform specific code
376         if (grd_curscreen){
377                 if (grd_curscreen->sc_canvas.cv_bitmap.bm_data)
378                         d_free(grd_curscreen->sc_canvas.cv_bitmap.bm_data);
379                 d_free(grd_curscreen);
380         }
381 #ifdef OGL_RUNTIME_LOAD
382         if (ogl_rt_loaded)
383                 OpenGL_LoadLibrary(false);
384 #endif
385 }
386 extern int r_upixelc;
387 void ogl_upixelc(int x, int y, int c){
388         r_upixelc++;
389 //      printf("gr_upixelc(%i,%i,%i)%i\n",x,y,c,Function_mode==FMODE_GAME);
390 //      if(Function_mode != FMODE_GAME){
391 //              grd_curcanv->cv_bitmap.bm_data[y*grd_curscreen->sc_canvas.cv_bitmap.bm_w+x]=c;
392 //      }else{
393                 OGL_DISABLE(TEXTURE_2D);
394                 glPointSize(1.0);
395                 glBegin(GL_POINTS);
396 //              glBegin(GL_LINES);
397 //      ogl_pal=gr_current_pal;
398                 glColor3f(CPAL2Tr(c),CPAL2Tg(c),CPAL2Tb(c));
399 //      ogl_pal=gr_palette;
400                 glVertex2f((x+grd_curcanv->cv_bitmap.bm_x)/(float)last_width,1.0-(y+grd_curcanv->cv_bitmap.bm_y)/(float)last_height);
401 //              glVertex2f(x/((float)last_width+1),1.0-y/((float)last_height+1));
402                 glEnd();
403 //      }
404 }
405 void ogl_urect(int left,int top,int right,int bot){
406         GLfloat xo,yo,xf,yf;
407         int c=COLOR;
408         
409         xo=(left+grd_curcanv->cv_bitmap.bm_x)/(float)last_width;
410         xf=(right+grd_curcanv->cv_bitmap.bm_x)/(float)last_width;
411         yo=1.0-(top+grd_curcanv->cv_bitmap.bm_y)/(float)last_height;
412         yf=1.0-(bot+grd_curcanv->cv_bitmap.bm_y)/(float)last_height;
413         
414         OGL_DISABLE(TEXTURE_2D);
415         glColor3f(CPAL2Tr(c),CPAL2Tg(c),CPAL2Tb(c));
416         glBegin(GL_QUADS);
417         glVertex2f(xo,yo);
418         glVertex2f(xo,yf);
419         glVertex2f(xf,yf);
420         glVertex2f(xf,yo);
421         glEnd();
422 }
423 void ogl_ulinec(int left,int top,int right,int bot,int c){
424         GLfloat xo,yo,xf,yf;
425         
426         xo=(left+grd_curcanv->cv_bitmap.bm_x)/(float)last_width;
427         xf=(right+grd_curcanv->cv_bitmap.bm_x)/(float)last_width;
428         yo=1.0-(top+grd_curcanv->cv_bitmap.bm_y)/(float)last_height;
429         yf=1.0-(bot+grd_curcanv->cv_bitmap.bm_y)/(float)last_height;
430         
431         OGL_DISABLE(TEXTURE_2D);
432         glColor3f(CPAL2Tr(c),CPAL2Tg(c),CPAL2Tb(c));
433         glBegin(GL_LINES);
434         glVertex2f(xo,yo);
435         glVertex2f(xf,yf);
436         glEnd();
437 }
438         
439
440 GLfloat last_r=0, last_g=0, last_b=0;
441 int do_pal_step=0;
442 void ogl_do_palfx(void){
443 //      GLfloat r,g,b,a;
444         OGL_DISABLE(TEXTURE_2D);
445         if (gr_palette_faded_out){
446 /*              glEnable(GL_BLEND);
447                 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
448                 glColor3f(0,0,0);
449 //              r=g=b=0.0;a=1.0;
450         }else{
451                 if (do_pal_step){
452                         //glBlendFunc(GL_SRC_COLOR, GL_DST_COLOR);
453                         glEnable(GL_BLEND);
454                         glBlendFunc(GL_ONE,GL_ONE);
455                         glColor3f(last_r,last_g,last_b);
456 //                      r=f2fl(last_r);g=f2fl(last_g);b=f2fl(last_b);a=0.5;
457                 }else
458                         return;
459         }
460         
461         
462         glBegin(GL_QUADS);
463         glVertex2f(0,0);
464         glVertex2f(0,1);
465         glVertex2f(1,1);
466         glVertex2f(1,0);
467         glEnd();
468         
469         glEnable(GL_BLEND);     
470         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
471 }
472
473 void gr_palette_clear()
474 {
475         gr_palette_faded_out=1;
476 }
477
478
479 void gr_palette_step_up( int r, int g, int b )
480 {
481         if (gr_palette_faded_out) return;
482
483 //      if ( (r==last_r) && (g==last_g) && (b==last_b) ) return;
484
485 /*      last_r = r/63.0;
486         last_g = g/63.0;
487         last_b = b/63.0;
488         do_pal_step=(r || g || b);*/
489         
490         last_r = (r+gr_palette_gamma)/63.0;
491         last_g = (g+gr_palette_gamma)/63.0;
492         last_b = (b+gr_palette_gamma)/63.0;
493
494         do_pal_step=(r || g || b || gr_palette_gamma);
495         
496 }
497
498 //added on 980913 by adb to fix palette problems
499 // need a min without side effects...
500 #undef min
501 static inline int min(int x, int y) { return x < y ? x : y; }
502 //end changes by adb
503
504 void gr_palette_load( ubyte *pal )      
505 {
506  int i;//, j;
507
508  for (i=0; i<768; i++ ) {
509      gr_current_pal[i] = pal[i];
510      if (gr_current_pal[i] > 63) gr_current_pal[i] = 63;
511  }
512  //palette = screen->format->palette;
513
514  gr_palette_faded_out=0;
515
516  init_computed_colors();
517 }
518
519
520
521 int gr_palette_fade_out(ubyte *pal, int nsteps, int allow_keys)
522 {
523         gr_palette_faded_out=1;
524         return 0;
525 }
526
527
528
529 int gr_palette_fade_in(ubyte *pal, int nsteps, int allow_keys)
530 {
531         gr_palette_faded_out=0;
532         return 0;
533 }
534
535
536
537 void gr_palette_read(ubyte * pal)
538 {
539         int i;
540         for (i=0; i<768; i++ ) {
541                 pal[i]=gr_current_pal[i];
542                 if (pal[i] > 63) pal[i] = 63;
543         }
544 }
545
546 //writes out an uncompressed RGB .tga file
547 //if we got really spiffy, we could optionally link in libpng or something, and use that.
548 void write_bmp(char *savename,int w,int h,unsigned char *buf){
549         int f;
550 #if defined(__WINDOWS__) || defined(__MINGW32__)
551         f=open(savename,O_CREAT|O_EXCL|O_WRONLY,S_IRUSR|S_IWUSR);
552 #else
553         f=open(savename,O_CREAT|O_EXCL|O_WRONLY,S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
554 #endif
555         if (f>=0){
556                 GLubyte    targaMagic[12] = { 0, //no identification field
557                          0,//no colormap
558                          2,//RGB image (well, BGR, actually)
559                          0, 0, 0, 0, 0, 0, 0, 0, 0 };//no colormap or image origin stuff.
560                 GLubyte blah;
561                 int r;
562                 GLubyte *s;
563                 int x,y;
564                 
565                 //write .TGA header.
566                 write (f,targaMagic,sizeof(targaMagic));
567                 blah=w%256;write (f,&blah,1);//w, low
568                 blah=w/256;write (f,&blah,1);//w, high
569                 blah=h%256;write (f,&blah,1);//h, low
570                 blah=h/256;write (f,&blah,1);//h, high
571                 blah=24;write (f,&blah,1);//24 bpp
572                 blah=0;write (f,&blah,1);//no attribute bits, origin is lowerleft, no interleave
573                 
574                 s=buf;
575                 for (y=0;y<h;y++){//TGAs use BGR ordering of data.
576                         for (x=0;x<w;x++){
577                                 blah=s[0];
578                                 s[0]=s[2];
579                                 s[2]=blah;
580                                 s+=3;                           
581                         }
582                 }
583                 x=0;y=w*h*3;
584                 while (x<y){
585                         r=write(f,buf+x,y);
586                         if (r<=0){
587                                 mprintf((0,"screenshot error, couldn't write to %s (err %i)\n",savename,errno));
588                                 break;
589                         }
590                         x+=r;y-=r;
591                 }
592                 close(f);
593         }else{
594                 mprintf((0,"screenshot error, couldn't open %s (err %i)\n",savename,errno));
595         }
596 }
597 void save_screen_shot(int automap_flag)
598 {
599 //      fix t1;
600         char message[100];
601         static int savenum=0;
602         char savename[13];
603         unsigned char *buf;
604
605         if (!ogl_readpixels_ok){
606                 if (!automap_flag)
607 //                      hud_message(MSGC_GAME_FEEDBACK,"glReadPixels not supported on your configuration");
608                 return;
609         }
610
611         stop_time();
612
613 //added/changed on 10/31/98 by Victor Rachels to fix overwrite each new game
614         if ( savenum == 9999 ) savenum = 0;
615         sprintf(savename,"scrn%04d.tga",savenum++);
616
617         while(!access(savename,0))
618         {
619                 if ( savenum == 9999 ) savenum = 0;
620                 sprintf(savename,"scrn%04d.tga",savenum++);
621         }
622         sprintf( message, "%s '%s'", TXT_DUMPING_SCREEN, savename );
623 //end this section addition/change - Victor Rachels
624
625         if (automap_flag) {
626 //      save_font = grd_curcanv->cv_font;
627 //      gr_set_curfont(GAME_FONT);
628 //      gr_set_fontcolor(gr_find_closest_color_current(0,31,0),-1);
629 //      gr_get_string_size(message,&w,&h,&aw);
630 //              modex_print_message(32, 2, message);
631         } else {
632 //              hud_message(MSGC_GAME_FEEDBACK,message);
633         }
634         
635         buf = d_malloc(grd_curscreen->sc_w*grd_curscreen->sc_h*3);
636         glReadBuffer(GL_FRONT);
637         glReadPixels(0,0,grd_curscreen->sc_w,grd_curscreen->sc_h,GL_RGB,GL_UNSIGNED_BYTE,buf);
638         write_bmp(savename,grd_curscreen->sc_w,grd_curscreen->sc_h,buf);
639         d_free(buf);
640
641         key_flush();
642         start_time();
643 }