Esempio n. 1
0
void VertexParamsDefHLSL::print( Stream &stream, bool isVerterShader )
{
   assignConstantNumbers();

   const char *opener = "ConnectData main( VertData IN";
   stream.write( dStrlen(opener), opener );

   // find all the uniform variables and print them out
   for( U32 i=0; i<LangElement::elementList.size(); i++)
   {
      Var *var = dynamic_cast<Var*>(LangElement::elementList[i]);
      if( var )
      {
         if( var->uniform )
         {
            const char* nextVar = ",\r\n                  ";
            stream.write( dStrlen(nextVar), nextVar );            

            U8 varNum[64];
            dSprintf( (char*)varNum, sizeof(varNum), "register(C%d)", var->constNum );

            U8 output[256];
            if (var->arraySize <= 1)
               dSprintf( (char*)output, sizeof(output), "uniform %-8s %-15s : %s", var->type, var->name, varNum );
            else
               dSprintf( (char*)output, sizeof(output), "uniform %-8s %s[%d] : %s", var->type, var->name, var->arraySize, varNum );

            stream.write( dStrlen((char*)output), output );
         }
      }
   }

   const char *closer = "\r\n)\r\n{\r\n   ConnectData OUT;\r\n\r\n";
   stream.write( dStrlen(closer), closer );
}
Esempio n. 2
0
void PostEffectVis::_setDefaultCaption( VisWindow &vis, U32 texIndex )
{
   PostEffect *pfx = vis.pfx;
   GuiWindowCtrl *winCtrl = vis.window[texIndex];
   
   if ( texIndex == Target )
   {
      char caption[256];           
      char name[256];

      if ( pfx->getName() == NULL || dStrlen( pfx->getName() ) == 0 )
         dSprintf( name, 256, "(none)" );
      else
         dSprintf( name, 256, "%s", pfx->getName() );

      dSprintf( caption, 256, "%s[%i] target [NOT ENABLED]", name, pfx->getId() );

      winCtrl->setDataField( StringTable->insert("text"), NULL, caption );
   }
   else
   {
      char caption[256];            
      char name[256];

      if ( pfx->getName() == NULL || dStrlen( pfx->getName() ) == 0 )
         dSprintf( name, 256, "(none)" );
      else
         dSprintf( name, 256, "%s", pfx->getName() );

      dSprintf( caption, 256, "%s[%i] input%i - %s [NOT ENABLED]", name, pfx->getId(), texIndex-1, pfx->mTexFilename[texIndex-1].c_str() );

      winCtrl->setDataField( StringTable->insert("text"), NULL, caption );
   }
}
//-----------------------------------------------------------------------------
bool Platform::setClipboard(const char *text)
{
    ScrapRef       clip;
    U32            textSize;
    OSStatus       err = noErr;

    // make sure we have something to copy
    textSize = dStrlen(text);
    if(textSize == 0)
        return false;

    // get a local ref to the system clipboard
    GetScrapByName( kScrapClipboardScrap, kScrapClearNamedScrap, &clip );

    // put the data on the clipboard as text
    err = PutScrapFlavor( clip, kScrapFlavorTypeText, kScrapFlavorMaskNone, textSize, text);

    // put the data on the clipboard as unicode
    const UTF16 *utf16Data = convertUTF8toUTF16(text);
    err |= PutScrapFlavor( clip, kScrapFlavorTypeUnicode, kScrapFlavorMaskNone,
                           dStrlen(utf16Data) * sizeof(UTF16), utf16Data);
    delete [] utf16Data;

    // and see if we were successful.
    if( err == noErr )
        return true;
    else
        return false;
}
Esempio n. 4
0
void ShaderConnectorHLSL::print( Stream &stream, bool isVertexShader )
{
   const char * header = "struct ";
   const char * header2 = "\r\n{\r\n";
   const char * footer = "};\r\n\r\n\r\n";

   stream.write( dStrlen(header), header );
   stream.write( dStrlen((char*)mName), mName );
   stream.write( dStrlen(header2), header2 );


   // print out elements
   for( U32 i=0; i<mElementList.size(); i++ )
   {
      U8 output[256];

      Var *var = mElementList[i];
      if (var->arraySize <= 1)
         dSprintf( (char*)output, sizeof(output), "   %s %-15s : %s;\r\n", var->type, var->name, var->connectName );
      else
         dSprintf( (char*)output, sizeof(output), "   %s %s[%d] : %s;\r\n", var->type, var->name, var->arraySize, var->connectName );

      stream.write( dStrlen((char*)output), output );
   }

   stream.write( dStrlen(footer), footer );
}
Esempio n. 5
0
//------------------------------------------------------------------------------
static void log(const char *string)
{
   // Bail if we ain't logging.
   if (!consoleLogMode) 
   {
      return;
   }

   // In mode 1, we open, append, close on each log write.
   if ((consoleLogMode & 0x3) == 1) 
   {
      consoleLogFile.open(defLogFileName, Torque::FS::File::ReadWrite);
   }

   // Write to the log if its status is hunky-dory.
   if ((consoleLogFile.getStatus() == Stream::Ok) || (consoleLogFile.getStatus() == Stream::EOS)) 
   {
      consoleLogFile.setPosition(consoleLogFile.getStreamSize());
      // If this is the first write...
      if (newLogFile) 
      {
         // Make a header.
         Platform::LocalTime lt;
         Platform::getLocalTime(lt);
         char buffer[128];
         dSprintf(buffer, sizeof(buffer), "//-------------------------- %d/%d/%d -- %02d:%02d:%02d -----\r\n",
               lt.month + 1,
               lt.monthday,
               lt.year + 1900,
               lt.hour,
               lt.min,
               lt.sec);
         consoleLogFile.write(dStrlen(buffer), buffer);
         newLogFile = false;
         if (consoleLogMode & 0x4) 
         {
            // Dump anything that has been printed to the console so far.
            consoleLogMode -= 0x4;
            U32 size, line;
            ConsoleLogEntry *log;
            getLockLog(log, size);
            for (line = 0; line < size; line++) 
            {
               consoleLogFile.write(dStrlen(log[line].mString), log[line].mString);
               consoleLogFile.write(2, "\r\n");
            }
            unlockLog();
         }
      }
      // Now write what we came here to write.
      consoleLogFile.write(dStrlen(string), string);
      consoleLogFile.write(2, "\r\n");
   }

   if ((consoleLogMode & 0x3) == 1) 
   {
      consoleLogFile.close();
   }
}
Esempio n. 6
0
void ShaderGenPrinterHLSL::printMainComment(Stream& stream)
{
   const char * header5 = "// Main\r\n";
   const char * line    = "//-----------------------------------------------------------------------------\r\n";

   stream.write( dStrlen(line), line );
   stream.write( dStrlen(header5), header5 );
   stream.write( dStrlen(line), line );
}
void ShaderGenPrinterGLSL::printMainComment( Stream& stream )
{
   // Print out main function definition
   const char * header5 = "// Main                                                                        \r\n";
   const char * line    = "//-----------------------------------------------------------------------------\r\n";

   stream.write( dStrlen(line), line );
   stream.write( dStrlen(header5), header5 );
   stream.write( dStrlen(line), line );
}
Esempio n. 8
0
static bool isMainDotCsPresent(char *dir)
{ 
   char maincsbuf[MAX_MAC_PATH_LONG];
   const char *maincsname = "/main.cs";
   const U32 len = dStrlen(dir) + dStrlen(maincsname)+1;
   AssertISV(len < MAX_MAC_PATH_LONG, "Sorry, path is too long, I can't run from this folder.");
   
   dSprintf(maincsbuf,MAX_MAC_PATH_LONG,"%s%s", dir, maincsname);
   
   return Platform::isFile(maincsbuf);
}
//--------------------------------------------------------------------------
// On add - verify data settings
//--------------------------------------------------------------------------
bool CustomMaterial::onAdd()
{
   if (Parent::onAdd() == false)
      return false;

   mShaderData = dynamic_cast<ShaderData*>(Sim::findObject( mShaderDataName ) );
   if(mShaderDataName.isNotEmpty() && mShaderData == NULL)
   {
      logError("Failed to find ShaderData %s", mShaderDataName.c_str());
      return false;
   }
   
   const char* samplerDecl = "sampler";
   S32 i = 0;
   for (SimFieldDictionaryIterator itr(getFieldDictionary()); *itr; ++itr)
   {
   	SimFieldDictionary::Entry* entry = *itr;
      if (dStrStartsWith(entry->slotName, samplerDecl))
      {
      	if (i >= MAX_TEX_PER_PASS)
         {
            logError("Too many sampler declarations, you may only have %i", MAX_TEX_PER_PASS);
            return false;
         }
         
         if (dStrlen(entry->slotName) == dStrlen(samplerDecl))
         {
         	logError("sampler declarations must have a sampler name, e.g. sampler[\"diffuseMap\"]");
            return false;
         }
         
         // Assert sampler names are defined on ShaderData
         S32 pos = -1;
         String samplerName = entry->slotName + dStrlen(samplerDecl);
         samplerName.insert(0, '$');
         mShaderData->hasSamplerDef(samplerName, pos);
         
         if(pos == -1)
         {
            const char *error = (avar("CustomMaterial(%s) bind sampler[%s] and is not present on ShaderData(%s)", 
               getName(), samplerName.c_str(), mShaderDataName.c_str() ));
            Con::errorf(error);
            GFXAssertFatal(0, error);
            continue;
         }
         mSamplerNames[pos] = samplerName;
         mTexFilename[pos] = entry->value;
         ++i;
      }
   }

   return true;
}
Esempio n. 10
0
void ShaderGenPrinterHLSL::printShaderHeader(Stream& stream)
{
   const char *header1 = "//*****************************************************************************\r\n";
   const char *header2 = "// Torque -- HLSL procedural shader\r\n";

   stream.write( dStrlen(header1), header1 );
   stream.write( dStrlen(header2), header2 );
   stream.write( dStrlen(header1), header1 );

   const char* header3 = "\r\n";      
   stream.write( dStrlen(header3), header3 );
}
Esempio n. 11
0
//--------------------------------------------------------------------------
// print
//--------------------------------------------------------------------------
void Var::print( Stream &stream )
{
   if( structName[0] != '\0' )
   {
      stream.write( dStrlen((char*)structName), structName );
      if(GFX->getAdapterType() == OpenGL)
         stream.write( 1, "_" );
      else
      stream.write( 1, "." );
   }

   stream.write( dStrlen((char*)name), name );
}
Esempio n. 12
0
//--------------------------------------
bool Platform::isSubDirectory(const char *pParent, const char *pDir)
{
   if (!pParent || !*pDir)
      return false;

   const char* fileName = avar("%s/*", pParent);

   TempAlloc< TCHAR > file( dStrlen( fileName ) + 1 );
   TempAlloc< TCHAR > dir( dStrlen( pDir ) + 1 );

#ifdef UNICODE
   convertUTF8toUTF16( fileName, file, file.size );
   convertUTF8toUTF16( pDir, dir, dir.size );
#else
   dStrcpy( file, fileName );
   dStrcpy( dir, pDir );
#endif

   backslash( file );
   backslash( dir );

   // this is somewhat of a brute force method but we need to be 100% sure
   // that the user cannot enter things like ../dir or /dir etc,...
   WIN32_FIND_DATA findData;
   HANDLE handle = FindFirstFile(file, &findData);
   if (handle == INVALID_HANDLE_VALUE)
      return false;
   do
   {
      // if it is a directory...
      if (findData.dwFileAttributes &
          (FILE_ATTRIBUTE_DIRECTORY|
           FILE_ATTRIBUTE_OFFLINE|
           FILE_ATTRIBUTE_SYSTEM|
           FILE_ATTRIBUTE_TEMPORARY) )
      {
         //FIXME: this has to be dStrcasecmp but there's no implementation for Unicode

         // and the names match
         if (dStrcmp(dir, findData.cFileName ) == 0)
         {
            // then we have a real sub directory
            FindClose(handle);
            return true;
         }
      }
   }while(FindNextFile(handle, &findData));

   FindClose(handle);
   return false;
}
Esempio n. 13
0
// [tom, 7/12/2005] Rather then converting this to unicode, just using the ANSI
// versions of the Win32 API as its quicker for testing.
bool Platform::cdFileExists(const char *filePath, const char *volumeName, S32 serialNum)
{
   if (!filePath || !filePath[0])
      return true;

   //first find the CD device...
   char fileBuf[1024];
   char drivesBuf[256];
   S32 length = GetLogicalDriveStringsA(256, drivesBuf);
   char *drivePtr = drivesBuf;
   while (S32(drivePtr - drivesBuf) < length)
   {
      char driveVolume[256], driveFileSystem[256];
      U32 driveSerial, driveFNLength, driveFlags;
      if ((dStricmp(drivePtr, "A:\\") != 0 && dStricmp(drivePtr, "B:\\") != 0) &&
          GetVolumeInformationA((const char*)drivePtr, &driveVolume[0], (unsigned long)255,
                               (unsigned long*)&driveSerial, (unsigned long*)&driveFNLength,
                               (unsigned long*)&driveFlags, &driveFileSystem[0], (unsigned long)255))
      {
#if defined (TORQUE_DEBUG) || !defined (TORQUE_SHIPPING)
         Con::printf("Found Drive: %s, vol: %s, serial: %d", drivePtr, driveVolume, driveSerial);
#endif
         //see if the volume and serial number match
         if (!dStricmp(volumeName, driveVolume) && (!serialNum || (serialNum == driveSerial)))
         {
            //see if the file exists on this volume
            if(dStrlen(drivePtr) == 3 && drivePtr[2] == '\\' && filePath[0] == '\\')
               dSprintf(fileBuf, sizeof(fileBuf), "%s%s", drivePtr, filePath + 1);
            else
               dSprintf(fileBuf, sizeof(fileBuf), "%s%s", drivePtr, filePath);
#if defined (TORQUE_DEBUG) || !defined (TORQUE_SHIPPING)
            Con::printf("Looking for file: %s on %s", fileBuf, driveVolume);
#endif
            WIN32_FIND_DATAA findData;
            HANDLE h = FindFirstFileA(fileBuf, &findData);
            if(h != INVALID_HANDLE_VALUE)
            {
               FindClose(h);
               return true;
            }
            FindClose(h);
         }
      }

      //check the next drive
      drivePtr += dStrlen(drivePtr) + 1;
   }

   return false;
}
Esempio n. 14
0
S32 GuiTabBookCtrl::calculatePageTabWidth( GuiTabPageCtrl *page )
{
   if( !page )
      return mMinTabWidth;

   const char* text = page->getText();

   if( !text || dStrlen(text) == 0 || mProfile == NULL || mProfile->mFont == NULL )
      return mMinTabWidth;

   GFont *font = mProfile->mFont;

   return font->getStrNWidth( text, dStrlen(text) );

}
Esempio n. 15
0
ColladaAppNode::ColladaAppNode(const domNode* node, ColladaAppNode* parent)
      : p_domNode(node), appParent(parent), nodeExt(new ColladaExtension_node(node)),
      lastTransformTime(TSShapeLoader::DefaultTime-1), defaultTransformValid(false),
      invertMeshes(false)
{
   mName = dStrdup(_GetNameOrId(node));
   mParentName = dStrdup(parent ? parent->getName() : "ROOT");

   // Extract user properties from the <node> extension as whitespace separated
   // "name=value" pairs
   char* properties = dStrdup(nodeExt->user_properties);
   char* pos = properties;
   char* end = properties + dStrlen( properties );
   while ( pos < end )
   {
      // Find the '=' character to separate the name and value pair
      char* split = dStrchr( pos, '=' );
      if ( !split )
         break;

      // Get the name (whitespace trimmed string up to the '=')
      // and value (whitespace trimmed string after the '=')
      *split = '\0';
      char* name = TrimFirstWord( pos );
      char* value = TrimFirstWord( split + 1 );

      mProps.insert(StringTable->insert(name), dAtof(value));

      pos = value + dStrlen( value ) + 1;
   }

   dFree( properties );

   // Create vector of transform elements
   for (S32 iChild = 0; iChild < node->getContents().getCount(); iChild++) {
      switch (node->getContents()[iChild]->getElementType()) {
         case COLLADA_TYPE::TRANSLATE:
         case COLLADA_TYPE::ROTATE:
         case COLLADA_TYPE::SCALE:
         case COLLADA_TYPE::SKEW:
         case COLLADA_TYPE::MATRIX:
         case COLLADA_TYPE::LOOKAT:
            nodeTransforms.increment();
            nodeTransforms.last().element = node->getContents()[iChild];
            break;
      }
   }
}
Esempio n. 16
0
ExecuteThread::ExecuteThread(const char *executable, const char *args /* = NULL */, const char *directory /* = NULL */) : Thread(0, NULL, false)
{
   SHELLEXECUTEINFO shl;
   dMemset(&shl, 0, sizeof(shl));

   shl.cbSize = sizeof(shl);
   shl.fMask = SEE_MASK_NOCLOSEPROCESS;
   
   char exeBuf[1024];
   Platform::makeFullPathName(executable, exeBuf, sizeof(exeBuf));
   
   TempAlloc< TCHAR > dirBuf( ( directory ? dStrlen( directory ) : 0 ) + 1 );
   dirBuf[ dirBuf.size - 1 ] = 0;

#ifdef UNICODE
   WCHAR exe[ 1024 ];
   convertUTF8toUTF16( exeBuf, exe, sizeof( exe ) / sizeof( exe[ 0 ] ) );

   TempAlloc< WCHAR > argsBuf( ( args ? dStrlen( args ) : 0 ) + 1 );
   argsBuf[ argsBuf.size - 1 ] = 0;

   if( args )
      convertUTF8toUTF16( args, argsBuf, argsBuf.size );
   if( directory )
      convertUTF8toUTF16( directory, dirBuf, dirBuf.size );
#else
   char* exe = exeBuf;
   char* argsBuf = args;
   if( directory )
      dStrpcy( dirBuf, directory );
#endif

   backslash( exe );
   backslash( dirBuf );
   
   shl.lpVerb = TEXT( "open" );
   shl.lpFile = exe;
   shl.lpParameters = argsBuf;
   shl.lpDirectory = dirBuf;

   shl.nShow = SW_SHOWNORMAL;

   if(ShellExecuteEx(&shl) && shl.hProcess)
   {
      mProcess = shl.hProcess;
      start();
   }
}
Esempio n. 17
0
   /// Open the file and emit a row with the names of all enabled keys.
   virtual bool init( const char* fileName )
   {
      if( !mStream.open( fileName, Torque::FS::File::Write ) )
      {
         Con::errorf( "CSVSamplerBackend::init -- could not open '%s' for writing", fileName );
         return false;
      }

      Con::printf( "CSVSamplerBackend::init -- writing samples to '%s'", fileName );

      bool first = true;
      for( U32 i = 0; i < gSampleKeys.size(); ++ i )
      {
         SampleKey& key = gSampleKeys[ i ];
         if( key.mEnabled )
         {
            if( !first )
               mStream.write( 1, "," );

            mRecords.push_back( SampleRecord( i + 1 ) );
            mStream.write( dStrlen( key.mName ), key.mName );
            first = false;
         }
      }

      newline();
      return true;
   }
Esempio n. 18
0
void SimComponent::write(Stream &stream, U32 tabStop, U32 flags /* = 0 */)
{
   MutexHandle handle;
   handle.lock(mMutex); // When this goes out of scope, it will unlock it

   // export selected only?
   if((flags & SelectedOnly) && !isSelected())
   {
      for(U32 i = 0; i < mComponentList.size(); i++)
         mComponentList[i]->write(stream, tabStop, flags);

      return;
   }

   stream.writeTabs(tabStop);
   char buffer[1024];
   dSprintf(buffer, sizeof(buffer), "new %s(%s) {\r\n", getClassName(), getName() ? getName() : "");
   stream.write(dStrlen(buffer), buffer);
   writeFields(stream, tabStop + 1);

   if(mComponentList.size())
   {
      stream.write(2, "\r\n");

      stream.writeTabs(tabStop+1);
      stream.writeLine((U8 *)"// Note: This is a list of behaviors, not arbitrary SimObjects as in a SimGroup or SimSet.\r\n");

      for(U32 i = 0; i < mComponentList.size(); i++)
         mComponentList[i]->write(stream, tabStop + 1, flags);
   }

   stream.writeTabs(tabStop);
   stream.write(4, "};\r\n");
}
Esempio n. 19
0
//--------------------------------------
S32 Platform::getFileSize(const char *pFilePath)
{
   if (!pFilePath || !*pFilePath)
      return -1;

   TempAlloc< TCHAR > buf( dStrlen( pFilePath ) + 1 );

#ifdef UNICODE
   convertUTF8toUTF16( pFilePath, buf, buf.size );
#else
   dStrcpy( buf, pFilePath );
#endif
   backslash( buf );

   // Get file info
   WIN32_FIND_DATA findData;
   HANDLE handle = FindFirstFile(buf, &findData);

   if(handle == INVALID_HANDLE_VALUE)
      return -1;

   FindClose(handle);

   // if the file is a Directory, Offline, System or Temporary then FALSE
   if (findData.dwFileAttributes &
       (FILE_ATTRIBUTE_DIRECTORY|
        FILE_ATTRIBUTE_OFFLINE|
        FILE_ATTRIBUTE_SYSTEM|
        FILE_ATTRIBUTE_TEMPORARY) )
      return -1;

   // must be a real file then
   return findData.nFileSizeLow;
}
Esempio n. 20
0
//--------------------------------------
bool Platform::createPath(const char *file)
{
   TempAlloc< TCHAR > pathbuf( dStrlen( file ) + 1 );

#ifdef UNICODE
   TempAlloc< WCHAR > fileBuf( pathbuf.size );
   convertUTF8toUTF16( file, fileBuf, fileBuf.size );
   const WCHAR* fileName = fileBuf;
   const WCHAR* dir;
#else
   const char* fileName = file;
   const char* dir;
#endif

   pathbuf[ 0 ] = 0;
   U32 pathLen = 0;

   while((dir = dStrchr(fileName, '/')) != NULL)
   {
      TCHAR* pathptr = pathbuf;
      dMemcpy( pathptr + pathLen, fileName, ( dir - fileName ) * sizeof( TCHAR ) );
      pathbuf[pathLen + dir-fileName] = 0;
 
      // ignore return value because we are fine with already existing directory
      CreateDirectory(pathbuf, NULL);

      pathLen += dir - fileName;
      pathbuf[pathLen++] = '\\';
      fileName = dir + 1;
   }
   return true;
}
Esempio n. 21
0
bool Platform::getFileTimes(const char *filePath, FileTime *createTime, FileTime *modifyTime)
{
   WIN32_FIND_DATA findData;

   TempAlloc< TCHAR > fp( dStrlen( filePath ) + 1 );

#ifdef UNICODE
   convertUTF8toUTF16( filePath, fp, fp.size );
#else
   dStrcpy( fp, filePath );
#endif

   backslash( fp );

   HANDLE h = FindFirstFile(fp, &findData);
   if(h == INVALID_HANDLE_VALUE)
      return false;

   if(createTime)
   {
      createTime->v1 = findData.ftCreationTime.dwLowDateTime;
      createTime->v2 = findData.ftCreationTime.dwHighDateTime;
   }
   if(modifyTime)
   {
      modifyTime->v1 = findData.ftLastWriteTime.dwLowDateTime;
      modifyTime->v2 = findData.ftLastWriteTime.dwHighDateTime;
   }
   FindClose(h);
   return true;
}
Esempio n. 22
0
//--------------------------------------
bool MaterialList::readText(Stream &stream, U8 firstByte)
{
   free();

   if (!firstByte)
      return (stream.getStatus() == Stream::Ok || stream.getStatus() == Stream::EOS);

   char buf[1024];
   buf[0] = firstByte;
   U32 offset = 1;

   for(;;)
   {
      stream.readLine((U8*)(buf+offset), sizeof(buf)-offset);
      if(!buf[0])
         break;
      offset = 0;

      // Material paths are a legacy of Tribes tools,
      // strip them off...
      char *name = &buf[dStrlen(buf)];
      while (name != buf && name[-1] != '/' && name[-1] != '\\')
         name--;

      // Add it to the list
      mMaterialNames.push_back(name);
      mMatInstList.push_back(NULL);
   }

   return (stream.getStatus() == Stream::Ok || stream.getStatus() == Stream::EOS);
}
Esempio n. 23
0
//-----------------------------------------------------------------------------
bool Platform::dumpDirectories(const char *path, Vector<StringTableEntry> &directoryVector, S32 depth, bool noBasePath)
{
	if (isCachePath(path))
	{
	   PROFILE_START(dumpDirectories);

	   ResourceManager->initExcludedDirectories();

	   const S32 len = dStrlen(path)+1;
	   char newpath[len];
	   dSprintf(newpath, len, "%s", path);
	   if(newpath[len - 1] == '/')
		  newpath[len - 1] = '\0'; // cut off the trailing slash, if there is one

		// Insert base path to follow what Windows does.
		if ( !noBasePath )
			directoryVector.push_back(StringTable->insert(newpath));

		bool ret = recurseDumpDirectoriesCache(newpath, "", directoryVector, depth, noBasePath);
	   PROFILE_END();

	   return ret;
	}

   PROFILE_START(dumpDirectories);
   ResourceManager->initExcludedDirectories();
   bool ret = android_DumpDirectories(path, "", directoryVector, depth, noBasePath);
   PROFILE_END();
   
   return ret;
}
Esempio n. 24
0
void RedBook::setLastError(const char * error)
{
   if(!error || dStrlen(error) >= sizeof(smLastError))
      setLastError("Invalid error string passed");
   else
      dStrcpy(smLastError, error);
}
Esempio n. 25
0
 U32 getNumChars() const
 {
    if( mNumChars == U32_MAX )
       mNumChars = dStrlen( utf16() );
    
    return mNumChars;
 }
void ShaderGenPrinterGLSL::printVertexShaderCloser( Stream& stream )
{
   // We are render OpenGL upside down for use DX9 texture coords.
   // Must be the last vertex feature.
   const char *closer = "   gl_Position.y *= -1;\r\n}\r\n";
   stream.write( dStrlen(closer), closer );
}
Esempio n. 27
0
//-----------------------------------------------------------------------------
bool Platform::dumpPath(const char *path, Vector<Platform::FileInfo>& fileVector, S32 depth)
{
	if (isCachePath(path))
	{
		PROFILE_START(dumpPath);
		const S32 len = dStrlen(path) + 1;
	    char newpath[255];

		strcpy(newpath, path);

	   if(newpath[len - 2] == '/')
		  newpath[len - 2] = '\0'; // cut off the trailing slash, if there is one

	   bool ret = recurseDumpPathCache( newpath, fileVector, depth);
	   PROFILE_END();

	   return ret;
	}

   PROFILE_START(dumpPath);
   bool ret = android_DumpPath( path, fileVector, depth);
   PROFILE_END();
   
   return ret;
}
Esempio n. 28
0
void Settings::buildGroupString(String &name, const UTF8 *settingName)
{
   // here we want to loop through the stack and build a "/" seperated string
   // representing the entire current group stack that gets pre-pended to the
   // setting name passed in
   if(mGroupStack.size() > 0)
   {
      for(S32 i=0; i < mGroupStack.size(); i++)
	  {
		 S32 pos = 0;
		 if(name.size() > 0)
			pos = name.size()-1;

         // tack on the "/" in front if this isn't the first
		 if(i == 0)
		 {
	        name.insert(pos, mGroupStack[i]);
		 } else
		 {
			name.insert(pos, "/");
            name.insert(pos+1, mGroupStack[i]);
		 }
	  }

	  // tack on a final "/"
	  name.insert(name.size()-1, "/");
	  if(dStrlen(settingName) > 0)
	     name.insert(name.size()-1, settingName);
   } else
	  name = settingName;
}
Esempio n. 29
0
//--------------------------------------
StringTableEntry _StringTable::insert(const char* _val, const bool caseSens)
{
   // Added 3/29/2007 -- If this is undesirable behavior, let me know -patw
   const char *val = _val;
   if( val == NULL )
      val = "";
   //-

   Node **walk, *temp;
   U32 key = hashString(val);
   walk = &buckets[key % numBuckets];
   while((temp = *walk) != NULL)   {
      if(caseSens && !dStrcmp(temp->val, val))
         return temp->val;
      else if(!caseSens && !dStricmp(temp->val, val))
         return temp->val;
      walk = &(temp->next);
   }
   char *ret = 0;
   if(!*walk) {
      *walk = (Node *) mempool.alloc(sizeof(Node));
      (*walk)->next = 0;
      (*walk)->val = (char *) mempool.alloc(dStrlen(val) + 1);
      dStrcpy((*walk)->val, val);
      ret = (*walk)->val;
      itemCount ++;
   }
   if(itemCount > 2 * numBuckets) {
      resize(4 * numBuckets - 1);
   }
   return ret;
}
void ShaderGenPrinterGLSL::printShaderHeader( Stream& stream )
{
   const char *header1 = "//*****************************************************************************\r\n";
   const char *header2 = "// Torque -- GLSL procedural shader\r\n";

   stream.write( dStrlen(header1), header1 );
   stream.write( dStrlen(header2), header2 );
   stream.write( dStrlen(header1), header1 );

   // Cheap HLSL compatibility.
   const char* header3 = "#include \"shaders/common/gl/hlslCompat.glsl\"\r\n";      
   stream.write( dStrlen(header3), header3 );

   const char* header4 = "\r\n";      
   stream.write( dStrlen(header4), header4 );
}