home *** CD-ROM | disk | FTP | other *** search
/ Enter 2005 March / ENTER.ISO / files / fwp-0.0.6-win32-installer.exe / DisplayCCmds.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2004-12-06  |  3.2 KB  |  129 lines

  1. #include "DisplayCCmds.h"
  2.  
  3. #include "Renderer.h"
  4. #include "Display.h"
  5. #include "log.h"
  6. //#include "font.h"
  7. #include "TextureHandler.h"
  8.  
  9.  
  10. CCmdDisplayRestart::CCmdDisplayRestart():CCmd("display.restart"){
  11.     usageStr="display.restart";
  12.     infoStr="restarts the video subsystem";
  13. }
  14.  
  15. CCmdDisplayRestart::~CCmdDisplayRestart(){
  16.     if(console!=NULL)
  17.         console->unregisterCCmd(this);
  18. }
  19.  
  20. bool CCmdDisplayRestart::exec(int argc, char* argv[]){
  21.     bool retVal;
  22.  
  23.     if(argc==0){
  24.         if(Renderer::wasInit())
  25.             Renderer::shutdown();
  26.         if(Display::wasInit())
  27.             Display::shutdown();
  28.  
  29.         retVal = Display::init() && Renderer::init();
  30.         if(retVal){
  31.             TextureHandler::reloadTextures();
  32.             // FIXME: VBOs neu anlegen!!!
  33. //            initLight();    // THINKABOUTME
  34.             return true;
  35.         }else{
  36.             error("(in CCmdDisplayRestart::exec()): Couldn't restart video subsystem.\n\n");
  37.             return false;    // THINKABOUTME: quit??
  38.         }
  39.     }else{
  40.         console->print("usage: %s\n", usageStr);
  41.         return false;
  42.     }
  43. }
  44.  
  45.  
  46.  
  47. CCmdDisplaySetMode::CCmdDisplaySetMode():CCmd("display.setMode"){
  48.     usageStr="display.setMode [XRESxYRES:BPP] [FULLSCREEN]";
  49.     infoStr="sets a new video mode";
  50. }
  51.  
  52. CCmdDisplaySetMode::~CCmdDisplaySetMode(){
  53.     if(console!=NULL)
  54.         console->unregisterCCmd(this);
  55. }
  56.  
  57. bool CCmdDisplaySetMode::exec(int argc, char* argv[]){
  58.     bool retVal;
  59.  
  60.     if(argc>=1){
  61.         int xres, yres, bpp;
  62.         char buff[128];
  63.         int n = sscanf(argv[0], "%ix%i:%i", &xres, &yres, &bpp);
  64.         if(n==2){
  65.             sprintf(buff, "%i", xres);    // FIXME: wir brauchen setVal fⁿr cvars!!
  66.             Display::info.cvar.display_width->setValStr(buff);
  67.             sprintf(buff, "%i", yres);
  68.             Display::info.cvar.display_height->setValStr(buff);
  69.         }else if(n==3){
  70.             sprintf(buff, "%i", xres);
  71.             Display::info.cvar.display_width->setValStr(buff);
  72.             sprintf(buff, "%i", yres);
  73.             Display::info.cvar.display_height->setValStr(buff);
  74.             sprintf(buff, "%i", bpp);
  75.             Display::info.cvar.display_bpp->setValStr(buff);
  76.         }else{
  77.             console->print("Wrong argument format, must be 'XRESxYRES:BPP' (e.g. '1024x768:32').\n");
  78.             return false;
  79.         }
  80.  
  81.         if(argc == 2){
  82.             int b = atoi(argv[1]);
  83.             
  84.             sprintf(buff, "%i", b);
  85.             Display::info.cvar.display_fullscreen->setValStr(buff);
  86.  
  87.         }
  88.  
  89.         if(Renderer::wasInit())
  90.             Renderer::shutdown();
  91.         if(Display::wasInit())
  92.             Display::shutdown();
  93.  
  94.         retVal = Display::init() && Renderer::init();
  95.         if(retVal){
  96.             TextureHandler::reloadTextures();
  97. //            initLight();    // THINKABOUTME
  98.             return true;
  99.         }else{
  100.             fatal("(in CCmdDisplaySetMode::exec()): Couldn't restart video subsystem.\n\n");
  101.             return false;
  102.         }
  103.     }else{
  104.         console->print("usage: %s\n", usageStr);
  105.         return false;
  106.     }
  107. }
  108.  
  109. CCmdDisplayVideoInfo::CCmdDisplayVideoInfo():CCmd("display.videoInfo"){
  110.     usageStr="display.videoInfo";
  111.     infoStr="prints information about the current video mode";
  112. }
  113.  
  114. CCmdDisplayVideoInfo::~CCmdDisplayVideoInfo(){
  115.     if(console!=NULL)
  116.         console->unregisterCCmd(this);
  117. }
  118.  
  119. bool CCmdDisplayVideoInfo::exec(int argc, char* argv[]){
  120.     if(argc==0){
  121.         console->print("videoMode: width: %i, height: %i, bpp: %i\n", Display::info.var.width, Display::info.var.height, Display::info.var.bpp);
  122.         return true;
  123.     }else{
  124.         console->print("usage: %s\n", usageStr);
  125.         return false;
  126.     }
  127. }
  128.  
  129.