Difference for arch/ogl/gr.c from version 1.11 to 1.12


version 1.11 version 1.12
Line 8
 
Line 8
 #endif  #endif
 #include <GL/gl.h>  #include <GL/gl.h>
 #include <GL/glu.h>  #include <GL/glu.h>
   #include <unistd.h>
   #include <sys/types.h>
   #include <sys/stat.h>
   #include <fcntl.h>
   #include <errno.h>
   
   #include "hudmsg.h"
   #include "game.h"
   #include "text.h"
 #include "gr.h"  #include "gr.h"
   #include "gamefont.h"
 #include "grdef.h"  #include "grdef.h"
 #include "palette.h"  #include "palette.h"
 #include "u_mem.h"  #include "u_mem.h"
Line 369
 
Line 379
   
 void gr_palette_read(ubyte * pal)  void gr_palette_read(ubyte * pal)
 {  {
   }
   
   //writes out a raw bitmap file.  Eventually it could be made to write a "real" bmp with header, or tiff, etc. (if I ever get the screen shot func to produce any data)
   //if we got really spiffy, we could optionally link in libpng or something, and use that.
   void write_bmp(char *savename,int w,int h,unsigned char *buf){
    int f;
    f=open(savename,O_CREAT|O_EXCL|O_WRONLY,S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
    if (f>=0){
    int r;
    int i=w*h*3;
    while (i>0){
    r=write(f,buf,i);
    if (r<=0){
    mprintf((0,"screeshot error, couldn't write to %s (err %i)\n",savename,errno));
    break;
    }
    i-=r;
    buf+=r;
    }
    close(f);
    }else{
    mprintf((0,"screeshot error, couldn't open %s (err %i)\n",savename,errno));
    }
   }
   //OGL screenshot code.  Doesn't work for me, but I hear the glReadPixels is broken for mesa/glx at least with the beta tnt2 drivers.  all I get is a bunch of zeros.
   void save_screen_shot(int automap_flag)
   {
    fix t1;
    char message[100];
   // grs_canvas *screen_canv=&grd_curscreen->sc_canvas;
    grs_font *save_font;
    static int savenum=0;
   // grs_canvas *temp_canv,*save_canv
    char savename[13];
    unsigned char *buf;
   // ubyte pal[768];
    int w,h,aw,x,y;
   
    // Can't do screen shots in VR modes.
   // if ( VR_render_mode != VR_NONE )
   // return;
   
    stop_time();
   
   // save_canv = grd_curcanv;
   // temp_canv = gr_create_canvas(screen_canv->cv_bitmap.bm_w,screen_canv->cv_bitmap.bm_h);
   // gr_set_current_canvas(temp_canv);
   // gr_ubitmap(0,0,&screen_canv->cv_bitmap);*/
   
   
   //added/changed on 10/31/98 by Victor Rachels to fix overwrite each new game
    if ( savenum == 9999 ) savenum = 0;
    sprintf(savename,"scrn%04d.raw",savenum++);
   
    while(!access(savename,0))
    {
    if ( savenum == 9999 ) savenum = 0;
    sprintf(savename,"scrn%04d.raw",savenum++);
    }
    sprintf( message, "%s '%s'", TXT_DUMPING_SCREEN, savename );
   //end this section addition/change - Victor Rachels
   
   // gr_set_current_canvas(&VR_screen_pages[VR_current_page]);
   // x = (VR_screen_pages[VR_current_page].cv_w-w)/2;
   // y = (VR_screen_pages[VR_current_page].cv_h-h)/2;
   
    if (automap_flag) {
    save_font = grd_curcanv->cv_font;
    gr_set_curfont(GAME_FONT);
    gr_set_fontcolor(gr_find_closest_color_current(0,31,0),-1);
    gr_get_string_size(message,&w,&h,&aw);
    modex_print_message(32, 2, message);
    } else {
   // gr_setcolor(gr_find_closest_color_current(0,0,0));
   // gr_rect(x-2,y-2,x+w+2,y+h+2);
   // gr_printf(x,y,message);
   // gr_set_curfont(save_font);
    hud_message(MSGC_GAME_FEEDBACK,message);
    }
   // t1 = timer_get_fixed_seconds() + F1_0;
    buf = malloc(grd_curscreen->sc_w*grd_curscreen->sc_h*3);
    glReadBuffer(GL_FRONT);
    glReadPixels(0,0,grd_curscreen->sc_w,grd_curscreen->sc_h,GL_RGB,GL_UNSIGNED_BYTE,buf);
    write_bmp(savename,grd_curscreen->sc_w,grd_curscreen->sc_h,buf);
    free(buf);
   
   // gr_palette_read(pal); //get actual palette from the hardware
   // pcx_write_bitmap(savename,&temp_canv->cv_bitmap,pal);
   
   // while ( timer_get_fixed_seconds() < t1 ); // Wait so that messag stays up at least 1 second.
   
   // gr_set_current_canvas(screen_canv);
   
   // if (!automap_flag)
   // gr_ubitmap(0,0,&temp_canv->cv_bitmap);
   
   // gr_free_canvas(temp_canv);
   
   // gr_set_current_canvas(save_canv);
    key_flush();
    start_time();
 }  }
   

Legend:
line(s) removed in v.1.11 
line(s) changed
 line(s) added in v.1.12