- try for fix bug on OsgGraph

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@5982 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 3b25a17852be3db1aa79d95376b09add821daa50
Former-commit-id: 8fa5e651d07b76f82562bc6b5ce0c02e403bdcca
This commit is contained in:
torcs-ng 2015-04-20 21:16:41 +00:00
parent c91fb90dcb
commit e27fb12622
5 changed files with 13 additions and 12 deletions

View file

@ -71,7 +71,7 @@ SDCar::~SDCar(void)
osg::ref_ptr<osg::Node> SDCar::loadCar(tCarElt *car, bool tracktype, bool subcat, unsigned carshader) osg::ref_ptr<osg::Node> SDCar::loadCar(tCarElt *car, bool tracktype, bool subcat, unsigned carshader)
{ {
this->car = car; this->car = car;
static const int nMaxTexPathSize = 1024; static const int nMaxTexPathSize = 512;
char buf[nMaxTexPathSize]; char buf[nMaxTexPathSize];
int index; int index;
void *handle; void *handle;

View file

@ -79,20 +79,21 @@ osg::ref_ptr<osg::MatrixTransform> SDWheels::initWheel(int wheelIndex, const cha
#if 1 #if 1
osgLoader loader; osgLoader loader;
char wheel_file_name[32]; char wheel_file_name[32];
char buf[4096]; int MaxPathSize = 512;
char buf[MaxPathSize];
std::string TmpPath = GetDataDir(); std::string TmpPath = GetDataDir();
std::string strTPath; std::string strTPath;
snprintf(buf, 4096, "drivers/%s/%d/", car->_modName, car->_driverIndex); snprintf(buf, MaxPathSize, "drivers/%s/%d/", car->_modName, car->_driverIndex);
strTPath = TmpPath+buf; strTPath = TmpPath+buf;
loader.AddSearchPath(strTPath); loader.AddSearchPath(strTPath);
snprintf(buf, 4096, "cars/models/%s/", car->_carName); snprintf(buf, MaxPathSize, "cars/models/%s/", car->_carName);
strTPath = TmpPath+buf; strTPath = TmpPath+buf;
loader.AddSearchPath(strTPath); loader.AddSearchPath(strTPath);
GfOut("Chemin Textures : %s\n", strTPath.c_str()); GfOut("Chemin Textures : %s\n", strTPath.c_str());
snprintf(buf, 4096, "data/textures/"); snprintf(buf, MaxPathSize, "data/textures/");
strTPath = TmpPath+buf; strTPath = TmpPath+buf;
loader.AddSearchPath(strTPath); loader.AddSearchPath(strTPath);
@ -116,7 +117,7 @@ osg::ref_ptr<osg::MatrixTransform> SDWheels::initWheel(int wheelIndex, const cha
} }
#else #else
char wheel_file_name[32]; char wheel_file_name[32];
char buf[4096]; char buf[MaxPathSize];
std::string LocalPath = GetDataDir(); std::string LocalPath = GetDataDir();
@ -124,10 +125,10 @@ osg::ref_ptr<osg::MatrixTransform> SDWheels::initWheel(int wheelIndex, const cha
options->CACHE_NONE; options->CACHE_NONE;
//options = new osgDB::ReaderWriter::Options; //options = new osgDB::ReaderWriter::Options;
snprintf(buf, 4096, "drivers/%s/%d/", car->_modName, car->_driverIndex); snprintf(buf, MaxPathSize, "drivers/%s/%d/", car->_modName, car->_driverIndex);
options->getDatabasePathList().push_back(LocalPath+buf); options->getDatabasePathList().push_back(LocalPath+buf);
snprintf(buf, 4096, "cars/models/%s/", car->_carName); snprintf(buf, MaxPathSize, "cars/models/%s/", car->_carName);
options->getDatabasePathList().push_back(LocalPath+buf); options->getDatabasePathList().push_back(LocalPath+buf);
options->getDatabasePathList().push_back(LocalPath+"data/textures/"); options->getDatabasePathList().push_back(LocalPath+"data/textures/");

View file

@ -93,7 +93,7 @@ Geodelist _geodelist;
ReaderWriterACC::ReaderWriterACC() ReaderWriterACC::ReaderWriterACC()
{ {
osgDB::ReaderWriter::supportsExtension("acc","SPEED DREAMS Database format"); osgDB::ReaderWriter::supportsExtension("acc", "SPEED DREAMS Database format");
m_bCar = false; m_bCar = false;
m_transparentGroup = NULL; m_transparentGroup = NULL;
m_opaqueGroup = NULL; m_opaqueGroup = NULL;

View file

@ -271,7 +271,7 @@ int initCars(tSituation *s)
if (!grHandle) if (!grHandle)
{ {
sprintf(buf, "%s%s", GfLocalDir(), GR_PARAM_FILE); snprintf(buf, 256, "%s%s", GfLocalDir(), GR_PARAM_FILE);
grHandle = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT); grHandle = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
} }

View file

@ -33,8 +33,8 @@ SDCarShader::SDCarShader(osg::Node *car, SDCar *c)
std::string TmpPath = GetDataDir(); std::string TmpPath = GetDataDir();
osg::ref_ptr<osg::Shader> vertShader = new osg::Shader( osg::Shader::VERTEX); osg::ref_ptr<osg::Shader> vertShader = new osg::Shader( osg::Shader::VERTEX);
osg::ref_ptr<osg::Shader> fragShader = new osg::Shader( osg::Shader::FRAGMENT); osg::ref_ptr<osg::Shader> fragShader = new osg::Shader( osg::Shader::FRAGMENT);
vertShader->loadShaderSourceFromFile(TmpPath+"/data/shaders/car.vert"); vertShader->loadShaderSourceFromFile(TmpPath+"data/shaders/car.vert");
fragShader->loadShaderSourceFromFile(TmpPath+"/data/shaders/car.frag"); fragShader->loadShaderSourceFromFile(TmpPath+"data/shaders/car.frag");
program = new osg::Program; program = new osg::Program;
program->addShader( vertShader.get() ); program->addShader( vertShader.get() );
program->addShader( fragShader.get() ); program->addShader( fragShader.get() );