本文整理汇总了C++中idDynamicBlockAlloc类的典型用法代码示例。如果您正苦于以下问题:C++ idDynamicBlockAlloc类的具体用法?C++ idDynamicBlockAlloc怎么用?C++ idDynamicBlockAlloc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了idDynamicBlockAlloc类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1:
===========================================================================
*/
#include "sys/platform.h"
#include "idlib/math/Vector.h"
#include "idlib/Heap.h"
#include "framework/Common.h"
#include "idlib/Str.h"
#if !defined( ID_REDIRECT_NEWDELETE ) && !defined( MACOS_X )
#define USE_STRING_DATA_ALLOCATOR
#endif
#ifdef USE_STRING_DATA_ALLOCATOR
static idDynamicBlockAlloc<char, 1<<18, 128> stringDataAllocator;
#endif
idVec4 g_color_table[16] =
{
idVec4(0.0f, 0.0f, 0.0f, 1.0f),
idVec4(1.0f, 0.0f, 0.0f, 1.0f), // S_COLOR_RED
idVec4(0.0f, 1.0f, 0.0f, 1.0f), // S_COLOR_GREEN
idVec4(1.0f, 1.0f, 0.0f, 1.0f), // S_COLOR_YELLOW
idVec4(0.0f, 0.0f, 1.0f, 1.0f), // S_COLOR_BLUE
idVec4(0.0f, 1.0f, 1.0f, 1.0f), // S_COLOR_CYAN
idVec4(1.0f, 0.0f, 1.0f, 1.0f), // S_COLOR_MAGENTA
idVec4(1.0f, 1.0f, 1.0f, 1.0f), // S_COLOR_WHITE
idVec4(0.5f, 0.5f, 0.5f, 1.0f), // S_COLOR_GRAY
idVec4(0.0f, 0.0f, 0.0f, 1.0f), // S_COLOR_BLACK
idVec4(0.0f, 0.0f, 0.0f, 1.0f),
开发者ID:BielBdeLuna,项目名称:dhewm3,代码行数:31,代码来源:Str.cpp
示例2: GetNumUsedBlocks
/*
====================
idSampleDecoder::GetNumUsedBlocks
====================
*/
int idSampleDecoder::GetNumUsedBlocks( void ) {
return decoderMemoryAllocator.GetNumUsedBlocks();
}
开发者ID:Salamek,项目名称:Shadow-of-Dust,代码行数:8,代码来源:snd_decoder.cpp
示例3: GetUsedBlockMemory
/*
====================
idSampleDecoder::GetUsedBlockMemory
====================
*/
int idSampleDecoder::GetUsedBlockMemory( void ) {
return decoderMemoryAllocator.GetUsedBlockMemory();
}
开发者ID:Salamek,项目名称:Shadow-of-Dust,代码行数:8,代码来源:snd_decoder.cpp
示例4: Init
/*
====================
idSampleDecoder::Init
====================
*/
void idSampleDecoder::Init( void ) {
decoderMemoryAllocator.Init();
decoderMemoryAllocator.SetLockMemory( true );
decoderMemoryAllocator.SetFixedBlocks( idSoundSystemLocal::s_realTimeDecoding.GetBool() ? 10 : 1 );
}
开发者ID:Salamek,项目名称:Shadow-of-Dust,代码行数:10,代码来源:snd_decoder.cpp
示例5: Shutdown
/*
====================
idSampleDecoder::Shutdown
====================
*/
void idSampleDecoder::Shutdown( void ) {
decoderMemoryAllocator.Shutdown();
sampleDecoderAllocator.Shutdown();
}
开发者ID:Salamek,项目名称:Shadow-of-Dust,代码行数:9,代码来源:snd_decoder.cpp
示例6:
void *_decoder_realloc( void *memblock, size_t size ) {
void *ptr = decoderMemoryAllocator.Resize( (byte *)memblock, size );
assert( size == 0 || ptr != NULL );
return ptr;
}
开发者ID:tankorsmash,项目名称:quadcow,代码行数:5,代码来源:snd_decoder.cpp
示例7: _decoder_free
void _decoder_free( void *memblock ) {
decoderMemoryAllocator.Free( (byte *)memblock );
}
开发者ID:tankorsmash,项目名称:quadcow,代码行数:3,代码来源:snd_decoder.cpp
示例8: PurgeMemory
/*
================
idStr::PurgeMemory
================
*/
void idStr::PurgeMemory( void ) {
#ifdef USE_STRING_DATA_ALLOCATOR
stringDataAllocator.FreeEmptyBaseBlocks();
#endif
}
开发者ID:BielBdeLuna,项目名称:dhewm3,代码行数:10,代码来源:Str.cpp
示例9: DecodeOGG
/*
====================
idSampleDecoderLocal::DecodeOGG
====================
*/
int idSampleDecoderLocal::DecodeOGG( idSoundSample *sample, int sampleOffset44k, int sampleCount44k, float *dest ) {
int readSamples, totalSamples;
int shift = 22050 / sample->objectInfo.nSamplesPerSec;
int sampleOffset = sampleOffset44k >> shift;
int sampleCount = sampleCount44k >> shift;
// open OGG file if not yet opened
if ( lastSample == NULL ) {
// make sure there is enough space for another decoder
if ( decoderMemoryAllocator.GetFreeBlockMemory() < MIN_OGGVORBIS_MEMORY ) {
return 0;
}
if ( sample->nonCacheData == NULL ) {
assert( false ); // this should never happen
failed = true;
return 0;
}
file.SetData( (const char *)sample->nonCacheData, sample->objectMemSize );
if ( ov_openFile( &file, &ogg ) < 0 ) {
failed = true;
return 0;
}
lastFormat = WAVE_FORMAT_TAG_OGG;
lastSample = sample;
}
// seek to the right offset if necessary
if ( sampleOffset != lastSampleOffset ) {
if ( ov_pcm_seek( &ogg, sampleOffset / sample->objectInfo.nChannels ) != 0 ) {
failed = true;
return 0;
}
}
lastSampleOffset = sampleOffset;
// decode OGG samples
totalSamples = sampleCount;
readSamples = 0;
do {
float **samples;
int ret = ov_read_float( &ogg, &samples, totalSamples / sample->objectInfo.nChannels, NULL );
if ( ret == 0 ) {
failed = true;
break;
}
if ( ret < 0 ) {
failed = true;
return 0;
}
ret *= sample->objectInfo.nChannels;
SIMDProcessor->UpSampleOGGTo44kHz( dest + ( readSamples << shift ), samples, ret, sample->objectInfo.nSamplesPerSec, sample->objectInfo.nChannels );
readSamples += ret;
totalSamples -= ret;
} while( totalSamples > 0 );
lastSampleOffset += readSamples;
return ( readSamples << shift );
}
开发者ID:tankorsmash,项目名称:quadcow,代码行数:68,代码来源:snd_decoder.cpp
示例10: ShutdownMemory
/*
================
idStr::ShutdownMemory
================
*/
void idStr::ShutdownMemory( void ) {
#ifdef USE_STRING_DATA_ALLOCATOR
stringDataAllocator.Shutdown();
#endif
}
开发者ID:BielBdeLuna,项目名称:dhewm3,代码行数:10,代码来源:Str.cpp
示例11: InitMemory
/*
================
idStr::InitMemory
================
*/
void idStr::InitMemory( void ) {
#ifdef USE_STRING_DATA_ALLOCATOR
stringDataAllocator.Init();
#endif
}
开发者ID:BielBdeLuna,项目名称:dhewm3,代码行数:10,代码来源:Str.cpp
示例12:
/*
===================
idSoundCache::~idSoundCache ()
===================
*/
idSoundCache::~idSoundCache()
{
listCache.DeleteContents( true );
soundCacheAllocator.Shutdown();
}
开发者ID:revelator,项目名称:MHDoom,代码行数:10,代码来源:snd_cache.cpp
示例13: Load
/*
===================
idSoundSample::Load
Loads based on name, possibly doing a MakeDefault if necessary
===================
*/
void idSoundSample::Load( void )
{
defaultSound = false;
purged = false;
hardwareBuffer = false;
timestamp = GetNewTimeStamp();
if( timestamp == FILE_NOT_FOUND_TIMESTAMP )
{
common->DWarning( "Couldn't load sound '%s' using default", name.c_str() );
MakeDefault();
return;
}
// load it
idWaveFile fh;
waveformatex_t info;
if( fh.Open( name, &info ) == -1 )
{
common->DWarning( "Couldn't load sound '%s' using default", name.c_str() );
MakeDefault();
return;
}
if( info.nChannels != 1 && info.nChannels != 2 )
{
common->DWarning( "idSoundSample: %s has %i channels, using default", name.c_str(), info.nChannels );
fh.Close();
MakeDefault();
return;
}
if( info.wBitsPerSample != 16 )
{
common->DWarning( "idSoundSample: %s is %dbits, expected 16bits using default", name.c_str(), info.wBitsPerSample );
fh.Close();
MakeDefault();
return;
}
if( info.nSamplesPerSec != 44100 && info.nSamplesPerSec != 22050 && info.nSamplesPerSec != 11025 )
{
common->DWarning( "idSoundCache: %s is %dHz, expected 11025, 22050 or 44100 Hz. Using default", name.c_str(), info.nSamplesPerSec );
fh.Close();
MakeDefault();
return;
}
objectInfo = info;
objectSize = fh.GetOutputSize();
objectMemSize = fh.GetMemorySize();
nonCacheData = ( byte * ) soundCacheAllocator.Alloc( objectMemSize );
fh.Read( nonCacheData, objectMemSize, NULL );
// optionally convert it to 22kHz to save memory
CheckForDownSample();
// create hardware audio buffers
if( idSoundSystemLocal::useOpenAL )
{
// PCM loads directly
if( objectInfo.wFormatTag == WAVE_FORMAT_TAG_PCM )
{
alGetError();
alGenBuffers( 1, &openalBuffer );
if( alGetError() != AL_NO_ERROR )
{
common->Error( "idSoundCache: error generating OpenAL hardware buffer" );
}
if( alIsBuffer( openalBuffer ) )
{
alGetError();
alBufferData( openalBuffer, objectInfo.nChannels == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, nonCacheData, objectMemSize, objectInfo.nSamplesPerSec );
if( alGetError() != AL_NO_ERROR )
{
common->Error( "idSoundCache: error loading data into OpenAL hardware buffer" );
}
else
{
// removed the code here as it causes
// micro stutter in the camera.
hardwareBuffer = true;
}
}
}
// OGG decompressed at load time (when smaller than s_decompressionLimit seconds, 6 seconds by default)
if( objectInfo.wFormatTag == WAVE_FORMAT_TAG_OGG )
//.........这里部分代码省略.........
开发者ID:revelator,项目名称:MHDoom,代码行数:101,代码来源:snd_cache.cpp
注:本文中的idDynamicBlockAlloc类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论