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