本文整理汇总了C++中clPtr类的典型用法代码示例。如果您正苦于以下问题:C++ clPtr类的具体用法?C++ clPtr怎么用?C++ clPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了clPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EmitParticles
void clParticleEmitter_Sphere::EmitParticles( const clPtr<clParticleSystem>& PS, float DeltaTime ) const
{
FAccumulatedTime += DeltaTime;
while (
FAccumulatedTime > 1.0f / FEmissionRate &&
PS->GetParticles().size() < FMaxParticles )
{
FAccumulatedTime -= 1.0f / FEmissionRate;
sParticle P;
float Theta = Math::RandomInRange( 0.0f, Math::TWOPI );
float Phi = Math::RandomInRange( 0.0f, Math::TWOPI );
float R = FRadius;
float SinTheta = sin( Theta );
float x = R * SinTheta * cos( Phi );
float y = R * SinTheta * sin( Phi );
float z = R * cos( Theta );
P.FPosition = FCenter + vec3( x, y, z );
P.FVelocity = vec3( x, y, z ).GetNormalized() * Math::RandomInRange( FRadialVelocityMin, FRadialVelocityMax );
P.FAcceleration = vec3( 0.0f );
P.FTTL = Math::RandomInRange( FLifetimeMin, FLifetimeMax );
P.FLifeTime = P.FTTL;
P.FRGBA = Math::RandomVector4InRange( FColorMin, FColorMax );
P.FRGBA.w = 1.0f;
P.FSize = Math::RandomInRange( FSizeMin, FSizeMax );
PS->AddParticle( P );
}
}
示例2: FS
FSTmp::FSTmp(clPtr<FS> _baseFS)
: FS(TMP)
{
// to prevent build FSTmp on top of another FSTmp
if (_baseFS->Type() == FS::TMP)
baseFS = ((FSTmp*)_baseFS.Ptr())->baseFS;
else
baseFS = _baseFS;
}
示例3: ShouldRemove
bool ShouldRemove( const clPtr<iTask> T, size_t ID )
{
if ( T->GetTaskID() == ID )
{
T->Exit();
return true;
}
return false;
}
示例4:
void clCanvas::Rect3D( const LMatrix4& Proj, const LMatrix4& MV,
const LVector3& V1,
const LVector3& V2,
const LVector3& V3,
const LVector3& V4,
const clPtr<clGLTexture>& Texture,
const clPtr<clGLSLShaderProgram>& SP )
{
LGL3->glDisable( GL_DEPTH_TEST );
Texture->Bind( 0 );
clPtr<clGLSLShaderProgram> S = SP ? SP : FRect3DSP;
S->Bind();
S->SetUniformNameMat4Array( "u_MVP", 1, MV * Proj );
FRect3D->Restart( 6 );
FRect3D->SetTexCoordV( LVector2( 0, 0 ) );
FRect3D->EmitVertexV( V1 );
FRect3D->SetTexCoordV( LVector2( 1, 0 ) );
FRect3D->EmitVertexV( V2 );
FRect3D->SetTexCoordV( LVector2( 0, 1 ) );
FRect3D->EmitVertexV( V4 );
FRect3D->SetTexCoordV( LVector2( 1, 0 ) );
FRect3D->EmitVertexV( V2 );
FRect3D->SetTexCoordV( LVector2( 1, 1 ) );
FRect3D->EmitVertexV( V3 );
FRect3D->SetTexCoordV( LVector2( 0, 1 ) );
FRect3D->EmitVertexV( V4 );
FRect3DVA->SetVertexAttribs( FRect3D );
FRect3DVA->Draw( false );
}
示例5: LoadFileAsBlob
clPtr<Blob> LoadFileAsBlob( const std::string& FName )
{
clPtr<iIStream> input = g_FS->CreateReader( FName );
clPtr<Blob> Res = new Blob();
Res->CopyMemoryBlock( input->MapStream(), input->GetSize() );
return Res;
}
示例6: FSArch
clPtr<FS> clArchPlugin::OpenFS( clPtr<FS> Fs, FSPath& Path ) const
{
FSString Uri = Fs->Uri( Path );
struct archive* Arch = ArchOpen( Uri.GetUtf8() );
if ( Arch == nullptr )
{
return nullptr;
}
FSArchNode RootDir;
RootDir.fsStat.mode = S_IFDIR;
FSPath NodePath;
struct archive_entry* entry = archive_entry_new2( Arch );
int Res;
while ( ( Res = archive_read_next_header2( Arch, entry ) ) == ARCHIVE_OK )
{
NodePath.Set( CS_UTF8, archive_entry_pathname( entry ) );
FSString* ItemName = NodePath.GetItem( NodePath.Count() - 1 );
if ( NodePath.Count() == 1 && ( ItemName->IsDot() || ItemName->IsEmpty() ) )
{
// skip root dir
continue;
}
const mode_t Mode = archive_entry_mode( entry );
const int64_t Size = archive_entry_size( entry );
RootDir.entryOffset += Size;
FSStat ItemStat;
ItemStat.mode = S_ISREG( Mode ) ? Mode : S_IFDIR;
ItemStat.size = Size;
ItemStat.m_CreationTime = archive_entry_ctime( entry );
ItemStat.m_LastAccessTime = archive_entry_atime( entry );
ItemStat.m_LastWriteTime = archive_entry_mtime( entry );
ItemStat.m_ChangeTime = ItemStat.m_LastWriteTime;
FSArchNode* Dir = ArchGetParentDir( &RootDir, NodePath, ItemStat );
FSArchNode* Item = Dir->Add( FSArchNode( ItemName->GetUtf8(), ItemStat ) );
if (Item) {
Item->entryOffset = archive_read_header_position( Arch );
}
}
if ( Res != ARCHIVE_EOF )
{
dbg_printf( "Couldn't read archive entry: %s\n", archive_error_string( Arch ) );
}
archive_entry_free( entry );
ArchClose( Arch );
return new FSArch( RootDir, Uri );
}
示例7: AttachToScene
void clExplosion::AttachToScene( const clPtr<clSceneNode>& Scene )
{
if ( !m_Node )
{
m_Node = make_intrusive<clParticleSystemNode>();
const vec4 Pal[] =
{
vec4( 0.2f, 0.30f, 0.8f, 1.0f ),
vec4( 0.7f, 0.25f, 0.3f, 1.0f ),
vec4( 0.1f, 0.80f, 0.2f, 1.0f )
};
vec4 Color = Pal[ Math::RandomInRange( 0, 3 ) ];
auto Emitter = make_intrusive<clParticleEmitter_Explosion>();
Emitter->FCenter = vec3( 0.0f );
Emitter->FSizeMin = 0.02f;
Emitter->FSizeMax = 0.05f;
Emitter->FLifetimeMin = 0.1f;
Emitter->FLifetimeMax = 1.0f;
Emitter->FMaxParticles = 10000;
Emitter->FEmissionRate = 300;
Emitter->FRadialVelocityMin = 1.0f;
Emitter->FRadialVelocityMax = 2.0f;
Emitter->FColorMin = Color;
Emitter->FColorMax = Color;
Emitter->FAcceleration = 10.0f * m_ParticleAccel; //vec3( 0.0f, 0.0f, -3.0f );
m_Node->AddEmitter( Emitter );
}
Scene->Add( m_Node );
}
示例8: Append
void FSList::Append( clPtr<FSNode> p )
{
p->next = 0;
if ( last )
{
last->next = p.ptr();
}
else
{
first = p.ptr();
}
last = p.ptr();
p.drop();
count++;
}
示例9: Traverse
void iSceneTraverser::Traverse( clPtr<clSceneNode> Node )
{
if ( !Node ) { return; }
Reset();
Node->AcceptTraverser( this );
}
示例10: Picasa_ParseXMLResponse
void clGallery::ListDownloaded( clPtr<clBlob> B )
{
if ( B )
{
/// Parse the blob
FURLs.clear();
void* Data = B->GetData();
size_t DataSize = B->GetSize();
Picasa_ParseXMLResponse( std::string( ( char* )Data, DataSize ), FURLs );
}
else
{
FNoImagesList = true;
return;
}
for ( size_t j = 0 ; j != FURLs.size() ; j++ )
{
printf( "URL[%d] = %s\n", ( int )j, FURLs[j].c_str() );
}
fflush( stdout );
// теперь что-то создать в FImages ?
FImages.clear(); // resize(FURLs.size());
for ( size_t j = 0 ; j != FURLs.size() ; j++ )
{
LPhotoSize Size = L_PHOTO_SIZE_128;
std::string ImgUrl = Picasa_GetDirectImageURL( FURLs[j], Size );
clPtr<sImageDescriptor> Desc = new sImageDescriptor();
Desc->FSize = Size;
Desc->FURL = ImgUrl;
Desc->FID = j;
FImages.push_back( Desc );
// и запустить загрузку
Desc->StartDownload( true );
}
FNoImagesList = false;
}
示例11: clGLTexture
void clCanvas::TextStr( float X1, float Y1, float X2, float Y2, const std::string& Str, int Size, const LVector4& Color, const clPtr<clTextRenderer>& TR, int FontID )
{
clPtr<clBitmap> B = TR->RenderTextWithFont( Str, FontID, Size, 0xFFFFFFFF, true );
clPtr<clGLTexture> Texture = new clGLTexture();
Texture->LoadFromBitmap( B );
this->TexturedRect2D( X1, Y1, X2, Y2, Color, Texture );
// make sure we draw everything before detroying the texture
LGL3->glFinish();
}
示例12: RenderDirect
void RenderDirect( clPtr<clFlowUI> Control )
{
int Num = Control->FNumImg;
int CurImg = Control->GetCurrentImage();
float Dist = ( float )( Num * OneImageSize );
if ( Num < 1 ) {
return;
}
// index = [curr - 2 .. curr + 2]
/// Left -> Right -> Selected rendering order
int ImgOrder[] = { CurImg - 3, CurImg - 2, CurImg - 1, CurImg + 3, CurImg + 2, CurImg + 1, CurImg };
for ( int in_i = 0 ; in_i < 7 ; in_i++ )
{
int i = ImgOrder[in_i];
if ( i < 0 ) {
i += ( 1 - ( ( int )( i / Num ) ) ) * Num;
}
if ( i >= Num ) {
i -= ( ( int )( i / Num ) ) * Num;
}
if ( i < Num && i > -1 )
{
vec3 Pt[4];
Control->QuadCoords( Pt, Control->FFlinger->FValue - ( float )( i ) * OneImageSize );
vec3 Q[4];
for ( int j = 0 ; j < 4 ; j++ )
{
Q[j] = Control->FProjection * Control->FView * Pt[j];
}
BoxR( Q, 0xFFFFFF );
}
}
}
示例13: Lock
void clWorkerThread::AddTask( const clPtr<iTask>& Task )
{
tthread::lock_guard<tthread::mutex> Lock( FTasksMutex );
// non-zero IDs should be unique
if ( size_t ID = Task->GetTaskID() )
{
for ( std::list< clPtr<iTask> >::iterator i = FPendingTasks.begin(); i != FPendingTasks.end(); ++i )
{
// LASSERT( (*i)->GetTaskID() != ID );
}
}
FPendingTasks.push_back( Task );
FCondition.notify_all();
}
示例14:
void clCanvas::TexturedRect2D( float X1, float Y1, float X2, float Y2, const LVector4& Color, const clPtr<clGLTexture>& Texture )
{
LGL3->glDisable( GL_DEPTH_TEST );
Texture->Bind( 0 );
FTexRectSP->Bind();
FTexRectSP->SetUniformNameVec4Array( "u_Color", 1, Color );
FTexRectSP->SetUniformNameVec4Array( "u_RectSize", 1, LVector4( X1, Y1, X2, Y2 ) );
LGL3->glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
LGL3->glEnable( GL_BLEND );
FRectVA->Draw( false );
LGL3->glDisable( GL_BLEND );
}
示例15: ExtractCurrentFile_ZIP
/// Internal routine to extract a single file from ZIP archive
int ExtractCurrentFile_ZIP( unzFile uf, const char* password, int* abort_flag, float* progress, const clPtr<iOStream>& fout )
{
char filename_inzip[256];
int err = UNZ_OK;
void* buf;
uInt size_buf;
unz_file_info64 file_info;
err = unzGetCurrentFileInfo64( uf, &file_info, filename_inzip, sizeof( filename_inzip ), NULL, 0, NULL, 0 );
if ( err != UNZ_OK ) { return err; }
uint64 file_size = ( uint64 )file_info.uncompressed_size;
uint64 total_bytes = 0;
unsigned char _buf[WRITEBUFFERSIZE];
size_buf = WRITEBUFFERSIZE;
buf = ( void* )_buf;
err = unzOpenCurrentFilePassword( uf, password );
if ( err != UNZ_OK ) { return err; }
do
{
err = unzReadCurrentFile( uf, buf, size_buf );
if ( err < 0 ) { break; }
if ( err > 0 ) { total_bytes += err; fout->Write( buf, err ); }
}
while ( err > 0 );
int close_err = unzCloseCurrentFile ( uf );
if ( close_err != UNZ_OK ) { return close_err; }
return err;
}