Applied Hendrik's patch:

Adding command line option --renderer.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4023 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2009-09-15 04:48:14 +00:00
parent 6fd6063bcd
commit 0a84da2726
4 changed files with 107 additions and 15 deletions

View File

@ -227,6 +227,11 @@ namespace UserConfigParams
PARAM_PREFIX IntUserConfigParam m_max_fps
PARAM_DEFAULT( IntUserConfigParam(120, "max_fps", &m_video_group, "Maximum fps, should be at least 60") );
// Renderer type (OpenGL, Direct3D9, Direct3D8, Software, etc)
PARAM_PREFIX IntUserConfigParam m_renderer
PARAM_DEFAULT( IntUserConfigParam(0, "renderer", &m_video_group,
"Type of the renderer.") );
// ---- Debug
PARAM_PREFIX BoolUserConfigParam m_gamepad_debug PARAM_DEFAULT( BoolUserConfigParam(false, "gamepad_debug") );
PARAM_PREFIX IntUserConfigParam m_track_debug PARAM_DEFAULT( IntUserConfigParam(false, "track_debug") );

View File

@ -93,15 +93,36 @@ void IrrDriver::initDevice()
firstTime = false;
} // end if firstTime
int numDrivers = 5;
// Test if user has chosen a driver or if we should try all to find a woring
// one.
if( UserConfigParams::m_renderer != 0 )
{
numDrivers = 1;
}
// ---- open device
// Try different drivers: start with opengl, then DirectX
for(int driver_type=0; driver_type<3; driver_type++)
for(int driver_type=0; driver_type<numDrivers; driver_type++)
{
video::E_DRIVER_TYPE type = driver_type==0
? video::EDT_OPENGL
: (driver_type==1
? video::EDT_DIRECT3D9
: video::EDT_DIRECT3D8);
video::E_DRIVER_TYPE type;
// Test if user has chosen a driver or if we should try all to find a
// woring one.
if( UserConfigParams::m_renderer != 0 )
{
// Get the correct type.
type = getEngineDriverType( UserConfigParams::m_renderer );
} else {
// Get the correct type.
type = getEngineDriverType( driver_type );
}
// Try 32 and, upon failure, 24 then 16 bit per pixels
for(int bits=32; bits>15; bits -=8)
{
@ -129,7 +150,15 @@ void IrrDriver::initDevice()
exit(-1);
}
m_device->getVideoDriver()->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS,true);
m_device->getVideoDriver()->setTextureCreationFlag(
video::ETCF_CREATE_MIP_MAPS,
true);
// m_device->getVideoDriver()->setTextureCreationFlag(
// video::ETCF_OPTIMIZED_FOR_SPEED ,
// true);
// m_device->getVideoDriver()->setTextureCreationFlag(
// video::ETCF_ALWAYS_16_BIT ,
// true);
// Stores the new file system pointer.
file_manager->setDevice(m_device);
@ -141,6 +170,54 @@ void IrrDriver::initDevice()
m_race_font = m_gui_env->getFont(font.c_str());
}
//-----------------------------------------------------------------------------
video::E_DRIVER_TYPE IrrDriver::getEngineDriverType( int index )
{
video::E_DRIVER_TYPE type;
std::string rendererName = "";
// Choose the driver type.
switch(index)
{
// TODO Change default renderer dependen on operating system?
// Direct3D9 for Windows and OpenGL for Unix like systems?
case 0:
type = video::EDT_OPENGL;
rendererName = "OpenGL";
break;
case 1:
type = video::EDT_OPENGL;
rendererName = "OpenGL";
break;
case 2:
type = video::EDT_DIRECT3D9;
rendererName = "Direct3D9";
break;
case 3:
type = video::EDT_DIRECT3D8;
rendererName = "Direct3D8";
break;
case 4:
type = video::EDT_SOFTWARE;
rendererName = "Software";
break;
case 5:
type = video::EDT_BURNINGSVIDEO;
rendererName = "Burning's Video Software";
break;
default:
type = video::EDT_NULL;
rendererName = "Null Device";
}
// Ouput which render will be tried.
std::cout << "Trying " << rendererName << " rendering." << std::endl;
return type;
}
//-----------------------------------------------------------------------------
void IrrDriver::showPointer()
{

View File

@ -54,6 +54,7 @@ private:
void renderBulletDebugView();
void displayFPS();
video::E_DRIVER_TYPE getEngineDriverType(int index);
public:
IrrDriver();
~IrrDriver();

View File

@ -100,6 +100,10 @@ void cmdLineHelp (char* invocation)
" -s, --screensize WxH Set the screen size (e.g. 320x200).\n"
" -v, --version Show version of SuperTuxKart.\n"
" --trackdir DIR A directory from which additional tracks are loaded.\n"
" --renderer NUM Choose the renderer. Valid renderers are:"
" (Default: 0, OpenGL: 1, Direct3D9: 2, \n"
" Direct3D8: 3, Software: 4, \n"
" Burning's Software: 5, Null device: 6).\n"
// should not be used by unaware users:u
// " --profile Enable automatic driven profile mode for 20 seconds.\n"
// " --profile=n Enable automatic driven profile mode for n seconds.\n"
@ -171,6 +175,12 @@ int handleCmdLinePreliminary(int argc, char **argv)
UserConfigParams::m_fullscreen = false;
}
#endif
else if( !strcmp(argv[i], "--renderer") && (i+1 < argc) )
{
std::cout << "You chose renderer " << atoi(argv[i+1]) << std::endl;
UserConfigParams::m_renderer = atoi(argv[i+1]);
i++;
}
else if ( (!strcmp(argv[i], "--screensize") || !strcmp(argv[i], "-s") )
&& i+1<argc)
{
@ -455,14 +465,13 @@ int handleCmdLine(int argc, char **argv)
}
// these commands are already processed in handleCmdLinePreliminary, but repeat this
// just so that we don't get error messages about unknown commands
else if( !strcmp(argv[i], "--trackdir") && i+1<argc ) i++;
else if( !strcmp(argv[i], "--kartdir") && i+1<argc ) i++;
else if ( !strcmp(argv[i], "--fullscreen") || !strcmp(argv[i], "-f")) {}
else if ( !strcmp(argv[i], "--windowed") || !strcmp(argv[i], "-w")) {}
else if ( !strcmp(argv[i], "--screensize") || !strcmp(argv[i], "-s")) {
i++;
}
else if ( !strcmp(argv[i], "--version") || !strcmp(argv[i], "-v")) {}
else if( !strcmp(argv[i], "--trackdir") && i+1<argc ) { i++; }
else if( !strcmp(argv[i], "--kartdir") && i+1<argc ) { i++; }
else if( !strcmp(argv[i], "--renderer") && i+1<argc ) { i++; }
else if( !strcmp(argv[i], "--screensize") || !strcmp(argv[i], "-s")) {i++;}
else if( !strcmp(argv[i], "--fullscreen") || !strcmp(argv[i], "-f")) {}
else if( !strcmp(argv[i], "--windowed") || !strcmp(argv[i], "-w")) {}
else if( !strcmp(argv[i], "--version") || !strcmp(argv[i], "-v")) {}
else
{
fprintf ( stderr, "Invalid parameter: %s.\n\n", argv[i] );