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