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