void GFXPCD3D9WindowTarget::initPresentationParams()
{
   // Get some video mode related info.
   GFXVideoMode vm = mWindow->getVideoMode();

   // Do some validation...
   if(vm.fullScreen == true && mImplicit == false)
   {
      AssertISV(false, 
         "GFXPCD3D9WindowTarget::initPresentationParams - Cannot go fullscreen with secondary window!");
   }

   HWND hwnd = (HWND)mWindow->getSystemWindow( PlatformWindow::WindowSystem_Windows );
   AssertISV(hwnd, "GFXPCD3D9WindowTarget::initPresentationParams() - no HWND");

   // At some point, this will become GFXPCD3D9WindowTarget like trunk has,
   // so this cast isn't as bad as it looks. ;) BTR
   GFXPCD3D9Device* pcdevice = dynamic_cast<GFXPCD3D9Device*>(mDevice);
   mPresentationParams = pcdevice->setupPresentParams(vm, hwnd);

   if (mImplicit)
   {
      pcdevice->mMultisampleType = mPresentationParams.MultiSampleType;
      pcdevice->mMultisampleLevel = mPresentationParams.MultiSampleQuality;
   }
}
   static boolean	fillInputBuffer(j_decompress_ptr cinfo)
      // Read data into our input buffer.  Client calls this
      // when it needs more data from the file.
   {
      StreamedJPEGReader*	src = (StreamedJPEGReader*) cinfo->client_data;
      AssertISV(src, "StreamedJPEGReader::fillInputBuffer - 'this' is missing!");

      U32 bytesRead = src->mFile->read((char*)src->mBuffer, 8192);

      if (bytesRead <= 0) 
      {
         // Is the file completely empty?
         AssertISV(!src->mStartOfFile, "StreamedJPEGReader::fillInputBuffer - Empty source stream!");

         // Insert a fake EOI marker.
         src->mBuffer[0] = (JOCTET) 0xFF;
         src->mBuffer[1] = (JOCTET) JPEG_EOI;
         bytesRead = 2;
      }

      // Expose buffer state to clients.
      src->mSource.next_input_byte = src->mBuffer;
      src->mSource.bytes_in_buffer = bytesRead;
      src->mStartOfFile = false;

      return true;
   }
Beispiel #3
0
void AtlasOldMesher::optimize()
{
   AssertISV(false, "This is probably broken right now - BJG");
#if 0
   // Shove everything through nvTriStrip
   SetCacheSize(24);

   // first, stripify our geometry...
   PrimitiveGroup *pg;
   U16 pgCount;

   GenerateStrips(mIndices.address(), mIndices.size(), &pg, &pgCount, AtlasOldActivationHeightfield::smDoChecks);

   // We're lazy.
   AssertISV(pgCount == 1,
      "AtlasOldMesher::optimize - Got unexpectedly complex geometry from NVTriStrip! (a)");
   AssertISV(pg->type == PT_STRIP,
      "AtlasOldMesher::optimize - Got unexpectedly complex geometry from NVTriStrip! (b)");

   // Remap indices! BJGTODO - how am I supposed to interpet the results?
   /*   PrimitiveGroup *pgRemapped;
   RemapIndices(pg, pgCount, mVerts.size(), &pgRemapped); */

   // Ok, let's suck this stuff back in.
   mIndices.clear();
   mIndices.reserve(pg->numIndices);

   for(S32 i=0; i<pg->numIndices; i++)
      mIndices[i] = pg->indices[i];

   // And clean up the memory from the stripper.
   delete[] pg;

#endif
}
Beispiel #4
0
bool ResourceManager::remove( ResourceBase::Header* header )
{
   const Path &path = header->getPath();

#ifdef TORQUE_DEBUG_RES_MANAGER
   Con::printf( "ResourceManager::remove : [%s]", path.getFullPath().c_str() );
#endif

   ResourceHeaderMap::Iterator iter = mResourceHeaderMap.find( path.getFullPath() );
   if ( iter != mResourceHeaderMap.end() && iter->value == header )
   {
      AssertISV( header && (header->getRefCount() == 0), "ResourceManager error: trying to remove resource which is still in use." );
      mResourceHeaderMap.erase( iter );
   }
   else
   {
      iter = mPrevResourceHeaderMap.find( path.getFullPath() );
      if ( iter == mPrevResourceHeaderMap.end() || iter->value != header )
      {
         Con::errorf( "ResourceManager::remove : Trying to remove non-existent resource [%s]", path.getFullPath().c_str() );
         return false;
      }

      AssertISV( header && (header->getRefCount() == 0), "ResourceManager error: trying to remove resource which is still in use." );
      mPrevResourceHeaderMap.erase( iter );
   }

   FS::RemoveChangeNotification( path, this, &ResourceManager::notifiedFileChanged );

   return true;
}
Beispiel #5
0
bool Net::init()
{
#if defined(TORQUE_USE_WINSOCK)
   if(!initCount)
   {
#ifdef TORQUE_OS_XENON
      // Configure startup parameters
      XNetStartupParams xnsp;
      memset( &xnsp, 0, sizeof( xnsp ) );
      xnsp.cfgSizeOfStruct = sizeof( XNetStartupParams );

#ifndef TORQUE_DISABLE_PC_CONNECTIVITY
      xnsp.cfgFlags = XNET_STARTUP_BYPASS_SECURITY;
      Con::warnf("XNET_STARTUP_BYPASS_SECURITY enabled! This build can talk to PCs!");
#endif

      AssertISV( !XNetStartup( &xnsp ), "Net::init - failed to init XNet" );
#endif

      WSADATA stWSAData;
      AssertISV( !WSAStartup( 0x0101, &stWSAData ), "Net::init - failed to init WinSock!" );

      //logprintf("Winsock initialization %s", success ? "succeeded." : "failed!");
   }
#endif
   initCount++;

   Process::notify(&Net::process, PROCESS_NET_ORDER);

   return(true);
}
void GFXPCD3D9WindowTarget::initPresentationParams()
{
   // Get some video mode related info.
   GFXVideoMode vm = mWindow->getVideoMode();

   // Do some validation...
   if(vm.fullScreen == true && mImplicit == false)
   {
      AssertISV(false, 
         "GFXPCD3D9WindowTarget::initPresentationParams - Cannot go fullscreen with secondary window!");
   }

   Win32Window *win = dynamic_cast<Win32Window*>(mWindow);
   AssertISV(win, "GFXPCD3D9WindowTarget::initPresentationParams() - got a non Win32Window window passed in! Did DX go crossplatform?");

   HWND hwnd = win->getHWND();

   // At some point, this will become GFXPCD3D9WindowTarget like trunk has,
   // so this cast isn't as bad as it looks. ;) BTR
   GFXPCD3D9Device* pcdevice = dynamic_cast<GFXPCD3D9Device*>(mDevice);
   mPresentationParams = pcdevice->setupPresentParams(vm, hwnd);

   if (mImplicit)
   {
      pcdevice->mMultisampleType = mPresentationParams.MultiSampleType;
      pcdevice->mMultisampleLevel = mPresentationParams.MultiSampleQuality;
   }
}
Beispiel #7
0
bool AtlasChunk::readFromStream(AtlasChunk *ac, Stream *s)
{
   // First, read the size and allocate a buffer.
   
   // Let's do a sentinel check.
   U32 sent1;
   s->read(&sent1);
   AssertISV(sent1 == MakeFourCC('A', 'T', 'S', 'P'), "AtlasChunk::readFromStream - (sent1) invalid chunk master sentinel!");

   s->read(&ac->mChunkSize);

   // And now validate the chunk-type-sentinel.
   U32 sent2;
   s->read(&sent2);
   AssertISV(sent2 == ac->getHeadSentinel(), "AtlasChunk::readFromStream - (sent2) invalid chunk head sentinel!");

   // Get the chunk's data.  If it's already in memory, just reuse it.
   // Otherwise read it from the stream.

   bool isMemStream = false;
   U8 *data;
   U32 dataSize = ac->mChunkSize;
   
   if( dynamic_cast< MemStream* >( s ) )
   {
	   MemStream* memStream = ( MemStream* ) s;
	   U32 currentPos = memStream->getPosition();
	   isMemStream = true;
	   data = &( ( U8* ) memStream->getBuffer() )[ currentPos ];
	   memStream->setPosition( currentPos + dataSize );
   }
   else
   {
	   data = new U8[ dataSize ];

	   // Read next chunksize bytes into the buffer for later processing.
	   s->read( dataSize, data);
   }

   // Check end sentinel.
   U32 sent3;
   s->read(&sent3);
   AssertISV(sent3 == ac->getTailSentinel(), "AtlasChunk::readFromStream - (sent3) invalid chunk tail sentinel!");

   // And tell the chunk to read from that buffer...
   MemStream dataStream( dataSize, data );
   ac->read(&dataStream);

   // Clean up memory.
   if( !isMemStream )
	   delete[] data;

   // All done!
   return true;
}
   static void initSource(j_decompress_ptr cinfo)
   {
      StreamedJPEGReader*	src = (StreamedJPEGReader*) cinfo->client_data;
      AssertISV(src, "StreamedJPEGReader::initSource - 'this' is missing!");

      src->mStartOfFile = true;
   }
bool GFXD3D11OcclusionQuery::begin()
{
   if(GFXDevice::getDisableOcclusionQuery())
      return true;

   if (mQuery == NULL)
   {
      D3D11_QUERY_DESC queryDesc;
      queryDesc.Query = D3D11_QUERY_OCCLUSION;
      queryDesc.MiscFlags = 0;

      HRESULT hRes = D3D11DEVICE->CreateQuery(&queryDesc, &mQuery);

      if(FAILED(hRes))
      {
         AssertFatal(false, "GFXD3D11OcclusionQuery::begin - Hardware does not support D3D11 Occlusion-Queries, this should be caught before this type is created");
      }

      AssertISV(hRes != E_OUTOFMEMORY, "GFXD3D11OcclusionQuery::begin - Out of memory");
   }

   // Add a begin marker to the command buffer queue.
   D3D11DEVICECONTEXT->Begin(mQuery);

#ifdef TORQUE_GATHER_METRICS
   mBeginFrame = GuiTSCtrl::getFrameCount();
#endif

   return true;
}
Beispiel #10
0
U32 DDSFile::getSurfacePitch( U32 mipLevel ) const
{
   if(mFlags.test(CompressedData))
   {
      U32 sizeMultiple = 0;

      switch(mFormat)
      {
      case GFXFormatDXT1:
         sizeMultiple = 8;
         break;
      case GFXFormatDXT2:
      case GFXFormatDXT3:
      case GFXFormatDXT4:
      case GFXFormatDXT5:
         sizeMultiple = 16;
         break;
      default:
         AssertISV(false, "DDSFile::getPitch - invalid compressed texture format, we only support DXT1-5 right now.");
         break;
      }

      // Maybe need to be DWORD aligned?
      U32 align = getMax(U32(1), getWidth(mipLevel)/4) * sizeMultiple;
      align += 3; align >>=2; align <<=2;
      return align;

   }
Beispiel #11
0
bool GFXGLShader::initShader( const Torque::Path &file, 
                              bool isVertex, 
                              const Vector<GFXShaderMacro> &macros )
{
   PROFILE_SCOPE(GFXGLShader_CompileShader);
   GLuint activeShader = glCreateShader(isVertex ? GL_VERTEX_SHADER : GL_FRAGMENT_SHADER);
   if(isVertex)
      mVertexShader = activeShader;
   else
      mPixelShader = activeShader;
   glAttachShader(mProgram, activeShader);
   
   
   // Ok it's not in the shader gen manager, so ask Torque for it
   FileStream stream;
   if ( !stream.open( file, Torque::FS::File::Read ) )
   {
      AssertISV(false, avar("GFXGLShader::initShader - failed to open shader '%s'.", file.getFullPath().c_str()));

      if ( smLogErrors )
         Con::errorf( "GFXGLShader::initShader - Failed to open shader file '%s'.", 
            file.getFullPath().c_str() );

      return false;
   }
   
   if ( !_loadShaderFromStream( activeShader, file, &stream, macros ) )
      return false;
   
   GLint compile;
   glGetShaderiv(activeShader, GL_COMPILE_STATUS, &compile);

   // Dump the info log to the console
   U32 logLength = 0;
   glGetShaderiv(activeShader, GL_INFO_LOG_LENGTH, (GLint*)&logLength);
   
   GLint compileStatus = GL_TRUE;
   if ( logLength )
   {
      FrameAllocatorMarker fam;
      char* log = (char*)fam.alloc(logLength);
      glGetShaderInfoLog(activeShader, logLength, NULL, log);

      // Always print errors
      glGetShaderiv( activeShader, GL_COMPILE_STATUS, &compileStatus );

      if ( compileStatus == GL_FALSE )
      {
         if ( smLogErrors )
         {
            Con::errorf( "GFXGLShader::initShader - Error compiling shader!" );
            Con::errorf( "Program %s: %s", file.getFullPath().c_str(), log );
         }
      }
      else if ( smLogWarnings )
         Con::warnf( "Program %s: %s", file.getFullPath().c_str(), log );
   }

   return compileStatus != GL_FALSE;
}
Beispiel #12
0
void ConsoleConstructor::setup()
{
   for(ConsoleConstructor *walk = first; walk; walk = walk->next)
   {
#ifdef TORQUE_DEBUG
      walk->validate();
#endif

      if( walk->sc )
         Con::addCommand( walk->className, walk->funcName, walk->sc, walk->usage, walk->mina, walk->maxa, walk->toolOnly, walk->header );
      else if( walk->ic )
         Con::addCommand( walk->className, walk->funcName, walk->ic, walk->usage, walk->mina, walk->maxa, walk->toolOnly, walk->header );
      else if( walk->fc )
         Con::addCommand( walk->className, walk->funcName, walk->fc, walk->usage, walk->mina, walk->maxa, walk->toolOnly, walk->header );
      else if( walk->vc )
         Con::addCommand( walk->className, walk->funcName, walk->vc, walk->usage, walk->mina, walk->maxa, walk->toolOnly, walk->header );
      else if( walk->bc )
         Con::addCommand( walk->className, walk->funcName, walk->bc, walk->usage, walk->mina, walk->maxa, walk->toolOnly, walk->header );
      else if( walk->group )
         Con::markCommandGroup( walk->className, walk->funcName, walk->usage );
      else if( walk->callback )
         Con::noteScriptCallback( walk->className, walk->funcName, walk->usage, walk->header );
      else if( walk->ns )
      {
         Namespace* ns = Namespace::find( StringTable->insert( walk->className ) );
         if( ns )
            ns->mUsage = walk->usage;
      }
      else
      {
         AssertISV( false, "Found a ConsoleConstructor with an indeterminate type!" );
      }
   }
}
HRESULT _gfxD3DXInclude::Open(THIS_ D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName, 
                              LPCVOID pParentData, LPCVOID *ppData, UINT *pBytes, 
                              LPSTR pFullPath, DWORD cbFullPath)
{
   // First try making the path relative to the parent.
   Torque::Path path = Torque::Path::Join( mLastPath.last(), '/', pFileName );
   path = Torque::Path::CompressPath( path );

   if ( !Torque::FS::ReadFile( path, (void *&)*ppData, *pBytes, true ) )
   {
      // Ok... now try using the path as is.
      path = String( pFileName );
      path = Torque::Path::CompressPath( path );

      if ( !Torque::FS::ReadFile( path, (void *&)*ppData, *pBytes, true ) )
      {
         AssertISV(false, avar( "Failed to open include '%s'.", pFileName));
         return E_FAIL;
      }
   }

   // If the data was of zero size then we cannot recurse
   // into this file and DX won't call Close() below.
   //
   // So in this case don't push on the path.
   if ( *pBytes > 0 )
      mLastPath.push_back( path.getRootAndPath() );

   return S_OK;
}
bool GFXD3D9OcclusionQuery::begin()
{
   if ( GFXDevice::getDisableOcclusionQuery() )
      return true;

   if ( mQuery == NULL )
   {
#ifdef TORQUE_OS_XENON
      HRESULT hRes = static_cast<GFXD3D9Device*>( mDevice )->getDevice()->CreateQueryTiled( D3DQUERYTYPE_OCCLUSION, 2, &mQuery );
#else
      HRESULT hRes = static_cast<GFXD3D9Device*>( mDevice )->getDevice()->CreateQuery( D3DQUERYTYPE_OCCLUSION, &mQuery );
#endif

      AssertFatal( hRes != D3DERR_NOTAVAILABLE, "GFXD3D9OcclusionQuery::begin - Hardware does not support D3D9 Occlusion-Queries, this should be caught before this type is created" );
      AssertISV( hRes != E_OUTOFMEMORY, "GFXD3D9OcclusionQuery::begin - Out of memory" );
   }

   // Add a begin marker to the command buffer queue.
   mQuery->Issue( D3DISSUE_BEGIN );

#ifdef TORQUE_GATHER_METRICS
   mBeginFrame = GuiTSCtrl::getFrameCount();
#endif

   return true;
}
Beispiel #15
0
static mng_bool mngFatalErrorFn(mng_handle mng, mng_int32 code, mng_int8 severity, mng_chunkid chunktype, mng_uint32 chunkseq, mng_int32 extra1, mng_int32 extra2, mng_pchar text)
{
   mng_cleanup(&mng);
   
   AssertISV(false, avar("Error reading MNG file:\n %s", (const char*)text));
   return MNG_FALSE;
}
void GFXD3D9CardProfiler::init()
{
   mD3DDevice = dynamic_cast<GFXD3D9Device *>(GFX)->getDevice();
   AssertISV( mD3DDevice, "GFXD3D9CardProfiler::init() - No D3D9 Device found!");

   // Grab the caps so we can get our adapter ordinal and look up our name.
   D3DCAPS9 caps;
   D3D9Assert(mD3DDevice->GetDeviceCaps(&caps), "GFXD3D9CardProfiler::init - failed to get device caps!");

#ifdef TORQUE_OS_XENON
   mCardDescription = "Xbox360 GPU";
   mChipSet = "ATI";
   mVersionString = String::ToString(_XDK_VER);
   mVideoMemory = 512 * 1024 * 1024;
#else
   WMIVideoInfo wmiVidInfo;
   if( wmiVidInfo.profileAdapters() )
   {
      const PlatformVideoInfo::PVIAdapter &adapter = wmiVidInfo.getAdapterInformation( caps.AdapterOrdinal );

      mCardDescription = adapter.description;
      mChipSet = adapter.chipSet;
      mVersionString = adapter.driverVersion;
      mVideoMemory = adapter.vram;
   }
#endif

   Parent::init();
}
Beispiel #17
0
Bool FileRWStream::open(const char* in_filename, bool readOnly)
{
   if(!readOnly && assertIsv)
   {
      AssertISV(ResourceManager::sm_pManager == NULL ||
               ResourceManager::sm_pManager->isValidWriteFileName(in_filename) == true,
               avar("Attempted write to file: %s.\n"
                     "File is not in a writable directory.", in_filename));
   }
	close();

	// Try to open the file for binary writing.
	// if the file exists truncate it.
   // if the file does not exist, then instruct open
	// to create a file with RW attributes

   if(!readOnly)
      hFile = CreateFile(in_filename, GENERIC_WRITE|GENERIC_READ, 0, NULL,
                      OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
   else
      hFile = CreateFile( in_filename, GENERIC_READ, FILE_SHARE_READ, NULL, 
                       OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
   if ( hFile == INVALID_HANDLE_VALUE)
	{
      setStatus();
		return FALSE;
	}

	clrStatus();
	isMine = YES;
	return TRUE;
}
Beispiel #18
0
void AtlasDiscreteMesh::remap(const Vector<U16> &remapTable)
{
   AssertISV(remapTable.size() == mVertexCount, "AtlasDiscreteMesh::remap - remap table not the right size!");

   // Take each index, run it through the remap table, and store the result.
   for(U32 i=0; i<mIndexCount; i++)
      mIndex[i] = remapTable[mIndex[i]];
}
Beispiel #19
0
static mng_bool mngProcessHeaderFn(mng_handle mng, mng_uint32 width, mng_uint32 height)
{
   mngstuff *mymng = (mngstuff *)mng_get_userdata(mng);

   GFXFormat format;
   mng_uint8 colorType = mng_get_colortype(mng);
   mng_uint8 alphaDepth = mng_get_alphadepth(mng);
   switch(colorType)
   {
      case MNG_COLORTYPE_GRAY:
      case MNG_COLORTYPE_JPEGGRAY:
         format = GFXFormatR8G8B8;
         mng_set_canvasstyle(mng, MNG_CANVAS_RGB8);
         break;

      case MNG_COLORTYPE_INDEXED:
         if(alphaDepth >= 1)
         {
            format = GFXFormatR8G8B8A8;
            mng_set_canvasstyle(mng, MNG_CANVAS_RGBA8);
         }
         else
         {
            format = GFXFormatR8G8B8;
            mng_set_canvasstyle(mng, MNG_CANVAS_RGB8);
         }

      case MNG_COLORTYPE_RGB:
      case MNG_COLORTYPE_JPEGCOLOR:
         if(alphaDepth >= 1)
         {
            format = GFXFormatR8G8B8A8;
            mng_set_canvasstyle(mng, MNG_CANVAS_RGBA8);
         }
         else
         {
            format = GFXFormatR8G8B8;
            mng_set_canvasstyle(mng, MNG_CANVAS_RGB8);
         }
         break;

      case MNG_COLORTYPE_RGBA:
      case MNG_COLORTYPE_JPEGCOLORA:
         format = GFXFormatR8G8B8A8;
         mng_set_canvasstyle(mng, MNG_CANVAS_RGBA8);
         break;

      default:
         // This case should never get hit, however it resolves a compiler
         // warning
         format = GFXFormat_FIRST;
         AssertISV( false, "Unknown color format in bitmap MNG Loading" );
   }

   mymng->image->allocateBitmap(width, height, false, format);
   return MNG_TRUE;
}
void SimDataBlockEvent::unpack(NetConnection *cptr, BitStream *bstream)
{
   if(bstream->readFlag())
   {
      mProcess = true;
      id = bstream->readInt(DataBlockObjectIdBitSize) + DataBlockObjectIdFirst;
      S32 classId = bstream->readClassId(NetClassTypeDataBlock, cptr->getNetClassGroup());
      mIndex = bstream->readInt(DataBlockObjectIdBitSize);
      mTotal = bstream->readInt(DataBlockObjectIdBitSize + 1);
      
      SimObject* ptr;
      if( Sim::findObject( id, ptr ) )
      {
         // An object with the given ID already exists.  Make sure it has the right class.
         
         AbstractClassRep* classRep = AbstractClassRep::findClassRep( cptr->getNetClassGroup(), NetClassTypeDataBlock, classId );
         if( classRep && dStrcmp( classRep->getClassName(), ptr->getClassName() ) != 0 )
         {
            Con::warnf( "A '%s' datablock with id: %d already existed. "
                        "Clobbering it with new '%s' datablock from server.",
                        ptr->getClassName(), id, classRep->getClassName() );
            ptr->deleteObject();
            ptr = NULL;
         }
      }
      
      if( !ptr )
         ptr = ( SimObject* ) ConsoleObject::create( cptr->getNetClassGroup(), NetClassTypeDataBlock, classId );
         
      mObj = dynamic_cast< SimDataBlock* >( ptr );
      if( mObj != NULL )
      {
         #ifdef DEBUG_SPEW
         Con::printf(" - SimDataBlockEvent: unpacking event of type: %s", mObj->getClassName());
         #endif
         
         mObj->unpackData( bstream );
      }
      else
      {
         #ifdef DEBUG_SPEW
         Con::printf(" - SimDataBlockEvent: INVALID PACKET!  Could not create class with classID: %d", classId);
         #endif
         
         delete ptr;
         cptr->setLastError("Invalid packet in SimDataBlockEvent::unpack()");
      }

#ifdef TORQUE_DEBUG_NET
      U32 checksum = bstream->readInt(32);
      AssertISV( (checksum ^ DebugChecksum) == (U32)classId,
         avar("unpack did not match pack for event of class %s.",
            mObj->getClassName()) );
#endif

   }
}
Beispiel #21
0
void Platform::setWindowSize(U32 newWidth, U32 newHeight, bool fullScreen )
{
   AssertISV(gWindow, "Platform::setWindowSize - no window present!");

   // Grab the curent video settings and diddle them with the new values.
   GFXVideoMode vm = gWindow->getVideoMode();
   vm.resolution.set(newWidth, newHeight);
   vm.fullScreen = fullScreen;
   gWindow->setVideoMode(vm);
}
RenderPassManager* SceneManager::getDefaultRenderPass() const
{
   if( !mDefaultRenderPass )
   {
      Sim::findObject( "DiffuseRenderPassManager", mDefaultRenderPass );
      AssertISV( mDefaultRenderPass, "SceneManager::_setDefaultRenderPass - No DiffuseRenderPassManager defined!  Must be set up in script!" );
   }

   return mDefaultRenderPass;
}
Beispiel #23
0
int
main(int argc, char* argv[])
{
   if (argc != 3) {
      usage();
      return EXIT_FAILURE;
   }

   VolumeRStream  inputVol;
   VolumeRWStream outputVol;

   bool test = inputVol.openVolume(argv[2]);
   AssertISV(test != false, avar("Could not open input volume: %s", argv[2]));
   
   test = outputVol.openVolume(argv[1]);
   AssertISV(test != false, avar("Could not open output volume: %s", argv[1]));

   FindMatch fileMatches("*", 1024);
   inputVol.findMatches(&fileMatches);
   AssertWarn(fileMatches.isFull() == false,
              "Exceeded max merge size (1024) files have been left out");

   for (int i = 0; i < fileMatches.numMatches(); i++) {
      const char* pFileName = fileMatches.matchList[i];
      
      // Open the stream from the input volume
      //
      bool testOpen = inputVol.open(pFileName);
      AssertFatal(testOpen == true, "Something is horribly wrong...");
      
      outputVol.open(pFileName, STRM_COMPRESS_NONE, inputVol.getSize());
      
      copyStreams(outputVol, inputVol);
      outputVol.close();
      inputVol.close();
   }

   outputVol.closeVolume();
   inputVol.closeVolume();

   return EXIT_SUCCESS;
}
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);
}
void GFXD3D9QueryFence::resurrect()
{
   // Recreate the query
   if( mQuery == NULL )
   {
      HRESULT hRes = static_cast<GFXD3D9Device *>( mDevice )->getDevice()->CreateQuery( D3DQUERYTYPE_EVENT, &mQuery );

      AssertFatal( hRes != D3DERR_NOTAVAILABLE, "GFXD3D9QueryFence::resurrect - Hardware does not support D3D9 Queries, this should be caught before this fence type is created" );
      AssertISV( hRes != E_OUTOFMEMORY, "GFXD3D9QueryFence::resurrect - Out of memory" );
   }
}
Beispiel #26
0
void ConsoleConstructor::validate()
{
#ifdef TORQUE_DEBUG
   // Don't do the following check if we're not a method/func.
   if(this->group)
      return;

   // In debug, walk the list and make sure this isn't a duplicate.
   for(ConsoleConstructor *walk = first; walk; walk = walk->next)
   {
      // Skip mismatching func/method names.
      if(dStricmp(walk->funcName, this->funcName))
         continue;

      // Don't compare functions with methods or vice versa.
      if(bool(this->className) != bool(walk->className))
         continue;

      // Skip mismatching classnames, if they're present.
      if(this->className && walk->className && dStricmp(walk->className, this->className))
         continue;

      // If we encounter ourselves, stop searching; this prevents duplicate
      // firing of the assert, instead only firing for the latter encountered
      // entry.
      if(this == walk)
         break;

      // Match!
      if(this->className)
      {
         AssertISV(false, avar("ConsoleConstructor::setup - ConsoleMethod '%s::%s' collides with another of the same name.", this->className, this->funcName));
      }
      else
      {
         AssertISV(false, avar("ConsoleConstructor::setup - ConsoleFunction '%s' collides with another of the same name.", this->funcName));
      }
   }
#endif
}
void GFXD3D11OcclusionQuery::resurrect()
{
	// Recreate the query 
	if( mQuery == NULL ) 
	{ 
      D3D11_QUERY_DESC queryDesc;
      queryDesc.Query = D3D11_QUERY_OCCLUSION;
      queryDesc.MiscFlags = 0;

      HRESULT hRes = D3D11DEVICE->CreateQuery(&queryDesc, &mQuery); 
	
      AssertISV( hRes != E_OUTOFMEMORY, "GFXD3D9QueryFence::resurrect - Out of memory" ); 
   } 
}
   static void termSource(j_decompress_ptr cinfo)
      // Terminate the source.  Make sure we get deleted.
   {
      StreamedJPEGReader*	src = (StreamedJPEGReader*) cinfo->client_data;
      AssertISV(src, "StreamedJPEGReader::termSource - 'this' is missing!");

      // @@ it's kind of bogus to be deleting here
      // -- term_source happens at the end of
      // reading an image, but we're probably going
      // to want to init a source and use it to read
      // many images, without reallocating our
      // buffer.
      //delete src;
      //cinfo->src = NULL;
   }
void GFXD3D9QueryFence::issue()
{
   PROFILE_START( GFXD3D9QueryFence_issue );

   // Create the query if we need to
   if( mQuery == NULL )
   {
      HRESULT hRes = static_cast<GFXD3D9Device *>( mDevice )->getDevice()->CreateQuery( D3DQUERYTYPE_EVENT, &mQuery );

      AssertFatal( hRes != D3DERR_NOTAVAILABLE, "Hardware does not support D3D9 Queries, this should be caught before this fence type is created" );
      AssertISV( hRes != E_OUTOFMEMORY, "Out of memory" );
   }

   // Issue the query
   mQuery->Issue( D3DISSUE_END );

   PROFILE_END();
}
void SimDataBlockEvent::unpack(NetConnection *cptr, BitStream *bstream)
{
#ifdef AFX_CAP_DATABLOCK_CACHE // AFX CODE BLOCK (db-cache) <<
	// stash the stream position prior to unpacking
	S32 start_pos = bstream->getCurPos();
	((GameConnection *)cptr)->tempDisableStringBuffering(bstream);
#endif // AFX CODE BLOCK (db-cache) >>
   if(bstream->readFlag())
   {
      mProcess = true;
      id = bstream->readInt(DataBlockObjectIdBitSize) + DataBlockObjectIdFirst;
      S32 classId = bstream->readClassId(NetClassTypeDataBlock, cptr->getNetClassGroup());
      mIndex = bstream->readInt(DataBlockObjectIdBitSize);
      mTotal = bstream->readInt(DataBlockObjectIdBitSize + 1);

      SimObject* ptr = (SimObject *) ConsoleObject::create(cptr->getNetClassGroup(), NetClassTypeDataBlock, classId);
      if ((mObj = dynamic_cast<SimDataBlock*>(ptr)) != 0) 
      {
         //Con::printf(" - SimDataBlockEvent: unpacking event of type: %s", mObj->getClassName());
         mObj->unpackData(bstream);
      }
      else
      {
         //Con::printf(" - SimDataBlockEvent: INVALID PACKET!  Could not create class with classID: %d", classId);
         delete ptr;
         cptr->setLastError("Invalid packet in SimDataBlockEvent::unpack()");
      }

#ifdef TORQUE_DEBUG_NET
      U32 checksum = bstream->readInt(32);
      AssertISV( (checksum ^ DebugChecksum) == (U32)classId,
         avar("unpack did not match pack for event of class %s.",
            mObj->getClassName()) );
#endif

   }
#ifdef AFX_CAP_DATABLOCK_CACHE // AFX CODE BLOCK (db-cache) <<
   // rewind to stream position and then process raw bytes for caching
   ((GameConnection *)cptr)->repackClientDatablock(bstream, start_pos);
   ((GameConnection *)cptr)->restoreStringBuffering(bstream);
#endif // AFX CODE BLOCK (db-cache) >>
}