int gr_toggle_fullscreen(void) { if (sdl_video_flags & SDL_FULLSCREEN) sdl_video_flags &= ~SDL_FULLSCREEN; else sdl_video_flags |= SDL_FULLSCREEN; if (gl_initialized) { if (sdl_no_modeswitch == 0) { if (!SDL_VideoModeOK(SM_W(Game_screen_mode), SM_H(Game_screen_mode), GameArg.DbgBpp, sdl_video_flags)) { con_printf(CON_URGENT,"Cannot set %ix%i. Fallback to 640x480\n",SM_W(Game_screen_mode), SM_H(Game_screen_mode)); Game_screen_mode=SM(640,480); } if (!SDL_SetVideoMode(SM_W(Game_screen_mode), SM_H(Game_screen_mode), GameArg.DbgBpp, sdl_video_flags)) { Error("Could not set %dx%dx%d opengl video mode: %s\n", SM_W(Game_screen_mode), SM_H(Game_screen_mode), GameArg.DbgBpp, SDL_GetError()); } } #ifdef RPI if (rpi_setup_element(SM_W(Game_screen_mode), SM_H(Game_screen_mode), sdl_video_flags, 1)) { Error("RPi: Could not set up %dx%d element\n", SM_W(Game_screen_mode), SM_H(Game_screen_mode)); } #endif } gr_remap_color_fonts(); gr_remap_mono_fonts(); if (gl_initialized) // update viewing values for menus { glMatrixMode(GL_PROJECTION); glLoadIdentity(); #ifdef OGLES glOrthof(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); #else glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); #endif glMatrixMode(GL_MODELVIEW); glLoadIdentity();//clear matrix glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); ogl_smash_texture_list_internal();//if we are or were fullscreen, changing vid mode will invalidate current textures } GameCfg.WindowMode = (sdl_video_flags & SDL_FULLSCREEN)?0:1; return (sdl_video_flags & SDL_FULLSCREEN)?1:0; }
int GrSetMode (u_int32_t mode) { uint w, h; //int bForce = (nCurrentVGAMode < 0); if (mode <= 0) return 0; w = SM_W (mode); h = SM_H (mode); nCurrentVGAMode = mode; screen.Destroy (); screen.Init (); screen.SetMode (mode); screen.SetWidth (w); screen.SetHeight (h); //screen.Aspect () = FixDiv(screen.Width ()*3,screen.Height ()*4); screen.SetAspect (FixDiv (screen.Width (), (fix) (screen.Height () * ((double) w / (double) h)))); screen.Canvas ()->CBitmap::Init (BM_OGL, 0, 0, w, h, 1, NULL); screen.Canvas ()->CreateBuffer (); screen.Canvas ()->SetPalette (paletteManager.Default ()); //just need some valid palette here //screen.Canvas ()->props.rowSize = screen->pitch; //screen.Canvas ()->Buffer () = reinterpret_cast<ubyte*> (screen->pixels); CCanvas::SetCurrent (NULL); CCanvas::Current ()->SetFont (fontManager.Current ()); /***/PrintLog (" initializing OpenGL window\n"); if (!SdlGlInitWindow (w, h, 0)) //platform specific code return 0; /***/PrintLog (" initializing OpenGL view port\n"); ogl.Viewport (0, 0, w, h); /***/PrintLog (" initializing OpenGL screen mode\n"); ogl.SetScreenMode (); ogl.GetVerInfo (); GrUpdate (0); return 0; }
int vid_check_mode(uint32_t mode) { int w, h; w = SM_W(mode); h = SM_H(mode); return ogl_check_mode(w, h); // platform specific code }
int gr_check_mode(u_int32_t mode) { unsigned int w, h; w=SM_W(mode); h=SM_H(mode); if (sdl_no_modeswitch == 0) { return SDL_VideoModeOK(w, h, GameArg.DbgBpp, sdl_video_flags); } else { // just tell the caller that any mode is valid... return 32; } }
int gr_set_mode(u_int32_t mode) { unsigned int w,h; char *gr_bm_data; #ifdef NOGRAPH return 0; #endif // mode=0; if (mode<=0) return 0; w=SM_W(mode); h=SM_H(mode); //if (screen != NULL) gr_palette_clear(); // ogl_init_state(); gr_bm_data=grd_curscreen->sc_canvas.cv_bitmap.bm_data;//since we use realloc, we want to keep this pointer around. memset( grd_curscreen, 0, sizeof(grs_screen)); grd_curscreen->sc_mode = mode; grd_curscreen->sc_w = w; grd_curscreen->sc_h = h; grd_curscreen->sc_aspect = fixdiv(grd_curscreen->sc_w*3,grd_curscreen->sc_h*4); grd_curscreen->sc_canvas.cv_bitmap.bm_x = 0; grd_curscreen->sc_canvas.cv_bitmap.bm_y = 0; grd_curscreen->sc_canvas.cv_bitmap.bm_w = w; grd_curscreen->sc_canvas.cv_bitmap.bm_h = h; //grd_curscreen->sc_canvas.cv_bitmap.bm_rowsize = screen->pitch; grd_curscreen->sc_canvas.cv_bitmap.bm_rowsize = w; grd_curscreen->sc_canvas.cv_bitmap.bm_type = BM_OGL; //grd_curscreen->sc_canvas.cv_bitmap.bm_data = (unsigned char *)screen->pixels; // mprintf((0,"ogl/gr.c: reallocing %p to %i\n",grd_curscreen->sc_canvas.cv_bitmap.bm_data,w*h)); grd_curscreen->sc_canvas.cv_bitmap.bm_data = realloc(gr_bm_data,w*h); gr_set_current_canvas(NULL); //gr_enable_default_palette_loading(); ogl_init_window(w,h);//platform specific code ogl_get_verinfo(); OGL_VIEWPORT(0,0,w,h); ogl_set_screen_mode(); gamefont_choose_game_font(w,h); return 0; }
int WriteConfigFile() { PHYSFS_file *infile; GameCfg.GammaLevel = gr_palette_get_gamma(); infile = PHYSFSX_openWriteBuffered("descent.cfg"); if (infile == NULL) { return 1; } PHYSFSX_printf(infile, "%s=%d\n", DigiVolumeStr, GameCfg.DigiVolume); PHYSFSX_printf(infile, "%s=%d\n", MusicVolumeStr, GameCfg.MusicVolume); PHYSFSX_printf(infile, "%s=%d\n", ReverseStereoStr, GameCfg.ReverseStereo); PHYSFSX_printf(infile, "%s=%d\n", OrigTrackOrderStr, GameCfg.OrigTrackOrder); PHYSFSX_printf(infile, "%s=%d\n", MusicTypeStr, GameCfg.MusicType); PHYSFSX_printf(infile, "%s=%d\n", CMLevelMusicPlayOrderStr, GameCfg.CMLevelMusicPlayOrder); PHYSFSX_printf(infile, "%s=%d\n", CMLevelMusicTrack0Str, GameCfg.CMLevelMusicTrack[0]); PHYSFSX_printf(infile, "%s=%d\n", CMLevelMusicTrack1Str, GameCfg.CMLevelMusicTrack[1]); PHYSFSX_printf(infile, "%s=%s\n", CMLevelMusicPathStr, GameCfg.CMLevelMusicPath); PHYSFSX_printf(infile, "%s=%s\n", CMMiscMusic0Str, GameCfg.CMMiscMusic[SONG_TITLE]); PHYSFSX_printf(infile, "%s=%s\n", CMMiscMusic1Str, GameCfg.CMMiscMusic[SONG_BRIEFING]); PHYSFSX_printf(infile, "%s=%s\n", CMMiscMusic2Str, GameCfg.CMMiscMusic[SONG_ENDLEVEL]); PHYSFSX_printf(infile, "%s=%s\n", CMMiscMusic3Str, GameCfg.CMMiscMusic[SONG_ENDGAME]); PHYSFSX_printf(infile, "%s=%s\n", CMMiscMusic4Str, GameCfg.CMMiscMusic[SONG_CREDITS]); PHYSFSX_printf(infile, "%s=%d\n", GammaLevelStr, GameCfg.GammaLevel); PHYSFSX_printf(infile, "%s=%s\n", LastPlayerStr, Players[Player_num].callsign); PHYSFSX_printf(infile, "%s=%s\n", LastMissionStr, GameCfg.LastMission); PHYSFSX_printf(infile, "%s=%i\n", ResolutionXStr, SM_W(Game_screen_mode)); PHYSFSX_printf(infile, "%s=%i\n", ResolutionYStr, SM_H(Game_screen_mode)); PHYSFSX_printf(infile, "%s=%i\n", AspectXStr, GameCfg.AspectX); PHYSFSX_printf(infile, "%s=%i\n", AspectYStr, GameCfg.AspectY); PHYSFSX_printf(infile, "%s=%i\n", WindowModeStr, GameCfg.WindowMode); PHYSFSX_printf(infile, "%s=%i\n", TexFiltStr, GameCfg.TexFilt); PHYSFSX_printf(infile, "%s=%i\n", VSyncStr, GameCfg.VSync); PHYSFSX_printf(infile, "%s=%i\n", MultisampleStr, GameCfg.Multisample); PHYSFSX_printf(infile, "%s=%i\n", FPSIndicatorStr, GameCfg.FPSIndicator); PHYSFSX_printf(infile, "%s=%i\n", GrabinputStr, GameCfg.Grabinput); PHYSFS_close(infile); return 0; }
int gr_set_mode(u_int32_t mode) { unsigned int w, h; char *gr_bm_data; if (mode<=0) return 0; w=SM_W(mode); h=SM_H(mode); if (!gr_check_mode(mode)) { con_printf(CON_URGENT,"Cannot set %ix%i. Fallback to 640x480\n",w,h); w=640; h=480; Game_screen_mode=mode=SM(w,h); } gr_bm_data=(char *)grd_curscreen->sc_canvas.cv_bitmap.bm_data;//since we use realloc, we want to keep this pointer around. memset( grd_curscreen, 0, sizeof(grs_screen)); grd_curscreen->sc_mode = mode; grd_curscreen->sc_w = w; grd_curscreen->sc_h = h; grd_curscreen->sc_aspect = fixdiv(grd_curscreen->sc_w*GameCfg.AspectX,grd_curscreen->sc_h*GameCfg.AspectY); gr_init_canvas(&grd_curscreen->sc_canvas, d_realloc(gr_bm_data,w*h), BM_OGL, w, h); gr_set_current_canvas(NULL); ogl_init_window(w,h);//platform specific code ogl_get_verinfo(); OGL_VIEWPORT(0,0,w,h); ogl_init_state(); gamefont_choose_game_font(w,h); gr_remap_color_fonts(); gr_remap_mono_fonts(); return 0; }
int vid_set_mode(uint32_t mode) { short w, h; #ifdef NOGRAPH return 0; #endif // mode=0; if (mode<=0) return 0; if (mode == Vid_current_mode) return 0; w=SM_W(mode); h=SM_H(mode); Vid_current_mode = mode; //if (screen != NULL) gr_palette_clear(); // ogl_init_state(); gr_init_screen(BM_OGL, w, h, 0, 0, w, NULL); //gr_enable_default_palette_loading(); ogl_init_window(w,h);//platform specific code ogl_get_verinfo(); OGL_VIEWPORT(0,0,w,h); ogl_set_screen_mode(); // gamefont_choose_game_font(w,h); return 0; }
void change_res() { //edited 05/27/99 Matt Mueller - ingame fullscreen changing newmenu_item m[11]; u_int32_t modes[11]; int i=0, mc=0, num_presets=0; char customres[16]; #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE int fullscreenc; #endif //end edit -MM u_int32_t screen_mode = 0; int screen_width = 0; int screen_height = 0; int vr_mode = VR_NONE; int screen_compatible = 0; int use_double_buffer = 0; //changed 6/15/1999 by Owen Evans to fix some platform-related problems #ifdef __MSDOS__ m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x100"; m[mc].value=(Game_screen_mode==SM(320,100)); m[mc].group=0; modes[mc] = SM(320,100); mc++; #endif m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x200"; m[mc].value=(Game_screen_mode==SM(320,200)); m[mc].group=0; modes[mc] = SM(320,200); mc++; m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x240"; m[mc].value=(Game_screen_mode==SM(320,240)); m[mc].group=0; modes[mc] = SM(320,240); mc++; m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x400"; m[mc].value=(Game_screen_mode==SM(320,400)); m[mc].group=0; modes[mc] = SM(320,400); mc++; //#ifndef __LINUX__ - heh? 640x400 is perfectly fine on linux m[mc].type = NM_TYPE_RADIO; m[mc].text = "640x400"; m[mc].value=(Game_screen_mode==SM(640,400)); m[mc].group=0; modes[mc] = SM(640,400); mc++; //#endif m[mc].type = NM_TYPE_RADIO; m[mc].text = "640x480"; m[mc].value=(Game_screen_mode==SM(640,480)); m[mc].group=0; modes[mc] = SM(640,480); mc++; m[mc].type = NM_TYPE_RADIO; m[mc].text = "800x600"; m[mc].value=(Game_screen_mode==SM(800,600)); m[mc].group=0; modes[mc] = SM(800,600); mc++; m[mc].type = NM_TYPE_RADIO; m[mc].text = "1024x768"; m[mc].value=(Game_screen_mode==SM(1024,768)); m[mc].group=0; modes[mc] = SM(1024,768); mc++; //end section - OE num_presets = mc; for (i=0; i<mc; i++) if (m[mc].value) break; m[mc].type = NM_TYPE_RADIO; m[mc].text = "custom:"; m[mc].value=(i==mc); m[mc].group=0; modes[mc] = 0; mc++; sprintf(customres, "%ix%i", SM_W(Game_screen_mode), SM_H(Game_screen_mode)); m[mc].type = NM_TYPE_INPUT; m[mc].text = customres; m[mc].text_len=11; modes[mc] = 0; mc++; // m[mc].type = NM_TYPE_CHECK; m[mc].text = "No Doublebuffer"; m[mc].value = use_double_buffer; //added 05/27/99 Matt Mueller - ingame fullscreen changing #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE fullscreenc=mc;m[mc].type = NM_TYPE_CHECK; m[mc].text = "Fullscreen"; m[mc].value = gr_check_fullscreen();mc++; #endif //end addition -MM i=newmenu_do1( NULL, "Screen Resolution", mc, m, &change_res_poll, 0); //added 05/27/99 Matt Mueller - ingame fullscreen changing #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE if (m[fullscreenc].value != gr_check_fullscreen()){ gr_toggle_fullscreen(); Game_screen_mode = -1; } #endif //end addition -MM for(i=0;(m[i].value==0)&&(i<num_presets);i++); if (modes[i]==0){ char *h=strchr(customres, 'x'); if (!h) return; screen_mode = SM(atoi(customres), atoi(h+1)); }else{ screen_mode = modes[i]; } screen_width = SM_W(screen_mode); screen_height = SM_H(screen_mode); if (screen_height<=0 || screen_width<=0) return; switch(screen_mode) { case SM(320,100)://19: screen_compatible = 0; use_double_buffer = 0; break; case SM(320,200)://SM_320x200C: screen_compatible = 1; use_double_buffer = 0; break; default: screen_compatible = 0; use_double_buffer = 1; break; } #ifdef __MSDOS__ if ( FindArg( "-nodoublebuffer" ) ) #endif use_double_buffer = 0; //added 6/15/1999 by Owen Evans to eliminate unneccesary mode modification if (Game_screen_mode == screen_mode) return; // gr_set_mode(Game_screen_mode); //end section - OE VR_offscreen_buffer = 0; //Disable VR (so that VR_Screen_mode doesnt mess us up Game_screen_mode = screen_mode; Game_window_w=screen_width; Game_window_h=screen_height; game_init_render_buffers(screen_mode, screen_width, screen_height, use_double_buffer, vr_mode, screen_compatible); mprintf( (0, "\nInitializing palette system..." )); gr_use_palette_table( "PALETTE.256" ); mprintf( (0, "\nInitializing font system..." )); gamefont_init(); // must load after palette data loaded. reset_palette_add(); init_cockpit(); last_drawn_cockpit[0]=-1; last_drawn_cockpit[1]=-1; // init_gauges(); vr_reset_display(); }
int gr_set_mode(u_int32_t mode) { int w,h; #ifdef NOGRAPH return 0; #endif if (mode<=0) return 0; w=SM_W(mode); h=SM_H(mode); if (screen != NULL) gr_palette_clear(); //added on 11/06/98 by Matt Mueller to set the title bar. (moved from below) //sekmu: might wanna copy this litte blurb to one of the text files or something //we want to set it here so that X window manager "Style" type commands work //for example, in fvwm2 or fvwm95: //Style "D1X*" NoTitle, NoHandles, BorderWidth 0 //if you can't use -fullscreen like me (crashes X), this is a big help in //getting the window centered correctly (if you use SmartPlacement) SDL_WM_SetCaption(DESCENT_VERSION " " D1X_DATE, "Descent"); //end addition -MM //edited 10/05/98 by Matt Mueller - make fullscreen mode optional // changed by adb on 980913: added SDL_HWPALETTE (should be option?) // changed by someone on 980923 to add SDL_FULLSCREEN if(!checkvidmodeok || SDL_VideoModeOK(w,h,8,sdl_video_flags)){ screen = SDL_SetVideoMode(w, h, 8, sdl_video_flags); } else { screen=NULL; } // end changes by someone // end changes by adb //end edit -MM if (screen == NULL) { Error("Could not set %dx%dx8 video mode\n",w,h); exit(1); } memset( grd_curscreen, 0, sizeof(grs_screen)); grd_curscreen->sc_mode = mode; grd_curscreen->sc_w = w; grd_curscreen->sc_h = h; grd_curscreen->sc_aspect = fixdiv(grd_curscreen->sc_w*3,grd_curscreen->sc_h*4); grd_curscreen->sc_canvas.cv_bitmap.bm_x = 0; grd_curscreen->sc_canvas.cv_bitmap.bm_y = 0; grd_curscreen->sc_canvas.cv_bitmap.bm_w = w; grd_curscreen->sc_canvas.cv_bitmap.bm_h = h; grd_curscreen->sc_canvas.cv_bitmap.bm_rowsize = screen->pitch; grd_curscreen->sc_canvas.cv_bitmap.bm_type = BM_LINEAR; grd_curscreen->sc_canvas.cv_bitmap.bm_data = (unsigned char *)screen->pixels; gr_set_current_canvas(NULL); //gr_enable_default_palette_loading(); //added on 9/30/98 by Matt Mueller to hide the mouse if its over the game window SDL_ShowCursor(0); //end addition -MM //--moved up--added on 9/30/98 by Matt Mueller to set the title bar. Woohoo! //--moved up-- SDL_WM_SetCaption(DESCENT_VERSION " " D1X_DATE, NULL); //--moved up--end addition -MM gamefont_choose_game_font(w,h); return 0; }
int gr_set_mode(u_int32_t mode) { unsigned int w, h; ggi_mode other_mode; #ifdef NOGRAPH return 0; #endif if (mode<=0) return 0; w=SM_W(mode); h=SM_H(mode); gr_palette_clear(); if(ggiCheckGraphMode(screenvis, w, h, GGI_AUTO, GGI_AUTO, GT_8BIT, &other_mode)) ggiSetMode(screenvis, &other_mode); else ggiSetGraphMode(screenvis, w, h, GGI_AUTO, GGI_AUTO, GT_8BIT); ggiSetFlags(screenvis, GGIFLAG_ASYNC); if (!ggiDBGetNumBuffers(screenvis)) use_directbuffer = 0; else { dbuffer = ggiDBGetBuffer(screenvis, 0); if (!(dbuffer->type & GGI_DB_SIMPLE_PLB)) use_directbuffer = 0; else use_directbuffer = 1; } memset(grd_curscreen, 0, sizeof(grs_screen)); grd_curscreen->sc_mode = mode; grd_curscreen->sc_w = w; grd_curscreen->sc_h = h; grd_curscreen->sc_aspect = fixdiv(grd_curscreen->sc_w*3,grd_curscreen->sc_h*4); grd_curscreen->sc_canvas.cv_bitmap.bm_x = 0; grd_curscreen->sc_canvas.cv_bitmap.bm_y = 0; grd_curscreen->sc_canvas.cv_bitmap.bm_w = w; grd_curscreen->sc_canvas.cv_bitmap.bm_h = h; grd_curscreen->sc_canvas.cv_bitmap.bm_type = BM_LINEAR; if (use_directbuffer) { grd_curscreen->sc_canvas.cv_bitmap.bm_data = dbuffer->write; grd_curscreen->sc_canvas.cv_bitmap.bm_rowsize = dbuffer->buffer.plb.stride; } else { free(screenbuffer); screenbuffer = malloc (w * h); grd_curscreen->sc_canvas.cv_bitmap.bm_data = screenbuffer; grd_curscreen->sc_canvas.cv_bitmap.bm_rowsize = w; } gr_set_current_canvas(NULL); gamefont_choose_game_font(w,h); return 0; }
int GrVideoModeOK (u_int32_t mode) { return SdlGlVideoModeOK (SM_W (mode), SM_H (mode)); // platform specific code }
int gr_set_mode(u_int32_t mode) { unsigned int w, h; char vgamode[16]; vga_modeinfo *modeinfo; int modenum, rowsize; void *framebuffer; #ifdef NOGRAPH return 0; #endif if (mode<=0) return 0; w=SM_W(mode); h=SM_H(mode); gr_palette_clear(); sprintf(vgamode, "G%dx%dx256", w, h); modenum = vga_getmodenumber(vgamode); vga_setmode(modenum); #ifdef SVGALIB_INPUT mouse_seteventhandler(mouse_handler); #endif modeinfo = vga_getmodeinfo(modenum); if (modeinfo->flags & CAPABLE_LINEAR) { usebuffer = 0; vga_setlinearaddressing(); // Set up physical screen only gl_setcontextvga(modenum); physicalscreen = gl_allocatecontext(); gl_getcontext(physicalscreen); screenbuffer = physicalscreen; framebuffer = physicalscreen->vbuf; rowsize = physicalscreen->bytewidth; } else { usebuffer = 1; // Set up the physical screen gl_setcontextvga(modenum); physicalscreen = gl_allocatecontext(); gl_getcontext(physicalscreen); // Set up the virtual screen gl_setcontextvgavirtual(modenum); screenbuffer = gl_allocatecontext(); gl_getcontext(screenbuffer); framebuffer = screenbuffer->vbuf; rowsize = screenbuffer->bytewidth; } memset(grd_curscreen, 0, sizeof(grs_screen)); grd_curscreen->sc_mode = mode; grd_curscreen->sc_w = w; grd_curscreen->sc_h = h; grd_curscreen->sc_aspect = fixdiv(grd_curscreen->sc_w*3,grd_curscreen->sc_h*4); grd_curscreen->sc_canvas.cv_bitmap.bm_x = 0; grd_curscreen->sc_canvas.cv_bitmap.bm_y = 0; grd_curscreen->sc_canvas.cv_bitmap.bm_w = w; grd_curscreen->sc_canvas.cv_bitmap.bm_h = h; grd_curscreen->sc_canvas.cv_bitmap.bm_rowsize = rowsize; grd_curscreen->sc_canvas.cv_bitmap.bm_type = BM_LINEAR; grd_curscreen->sc_canvas.cv_bitmap.bm_data = framebuffer; gr_set_current_canvas(NULL); gamefont_choose_game_font(w,h); return 0; }