home *** CD-ROM | disk | FTP | other *** search
- #include "DisplayCCmds.h"
-
- #include "Renderer.h"
- #include "Display.h"
- #include "log.h"
- //#include "font.h"
- #include "TextureHandler.h"
-
-
- CCmdDisplayRestart::CCmdDisplayRestart():CCmd("display.restart"){
- usageStr="display.restart";
- infoStr="restarts the video subsystem";
- }
-
- CCmdDisplayRestart::~CCmdDisplayRestart(){
- if(console!=NULL)
- console->unregisterCCmd(this);
- }
-
- bool CCmdDisplayRestart::exec(int argc, char* argv[]){
- bool retVal;
-
- if(argc==0){
- if(Renderer::wasInit())
- Renderer::shutdown();
- if(Display::wasInit())
- Display::shutdown();
-
- retVal = Display::init() && Renderer::init();
- if(retVal){
- TextureHandler::reloadTextures();
- // FIXME: VBOs neu anlegen!!!
- // initLight(); // THINKABOUTME
- return true;
- }else{
- error("(in CCmdDisplayRestart::exec()): Couldn't restart video subsystem.\n\n");
- return false; // THINKABOUTME: quit??
- }
- }else{
- console->print("usage: %s\n", usageStr);
- return false;
- }
- }
-
-
-
- CCmdDisplaySetMode::CCmdDisplaySetMode():CCmd("display.setMode"){
- usageStr="display.setMode [XRESxYRES:BPP] [FULLSCREEN]";
- infoStr="sets a new video mode";
- }
-
- CCmdDisplaySetMode::~CCmdDisplaySetMode(){
- if(console!=NULL)
- console->unregisterCCmd(this);
- }
-
- bool CCmdDisplaySetMode::exec(int argc, char* argv[]){
- bool retVal;
-
- if(argc>=1){
- int xres, yres, bpp;
- char buff[128];
- int n = sscanf(argv[0], "%ix%i:%i", &xres, &yres, &bpp);
- if(n==2){
- sprintf(buff, "%i", xres); // FIXME: wir brauchen setVal fⁿr cvars!!
- Display::info.cvar.display_width->setValStr(buff);
- sprintf(buff, "%i", yres);
- Display::info.cvar.display_height->setValStr(buff);
- }else if(n==3){
- sprintf(buff, "%i", xres);
- Display::info.cvar.display_width->setValStr(buff);
- sprintf(buff, "%i", yres);
- Display::info.cvar.display_height->setValStr(buff);
- sprintf(buff, "%i", bpp);
- Display::info.cvar.display_bpp->setValStr(buff);
- }else{
- console->print("Wrong argument format, must be 'XRESxYRES:BPP' (e.g. '1024x768:32').\n");
- return false;
- }
-
- if(argc == 2){
- int b = atoi(argv[1]);
-
- sprintf(buff, "%i", b);
- Display::info.cvar.display_fullscreen->setValStr(buff);
-
- }
-
- if(Renderer::wasInit())
- Renderer::shutdown();
- if(Display::wasInit())
- Display::shutdown();
-
- retVal = Display::init() && Renderer::init();
- if(retVal){
- TextureHandler::reloadTextures();
- // initLight(); // THINKABOUTME
- return true;
- }else{
- fatal("(in CCmdDisplaySetMode::exec()): Couldn't restart video subsystem.\n\n");
- return false;
- }
- }else{
- console->print("usage: %s\n", usageStr);
- return false;
- }
- }
-
- CCmdDisplayVideoInfo::CCmdDisplayVideoInfo():CCmd("display.videoInfo"){
- usageStr="display.videoInfo";
- infoStr="prints information about the current video mode";
- }
-
- CCmdDisplayVideoInfo::~CCmdDisplayVideoInfo(){
- if(console!=NULL)
- console->unregisterCCmd(this);
- }
-
- bool CCmdDisplayVideoInfo::exec(int argc, char* argv[]){
- if(argc==0){
- console->print("videoMode: width: %i, height: %i, bpp: %i\n", Display::info.var.width, Display::info.var.height, Display::info.var.bpp);
- return true;
- }else{
- console->print("usage: %s\n", usageStr);
- return false;
- }
- }
-
-