void Texture::LoadSkyboxFromFile ( const std::string& texturePath ) { REQUIRES( !IsLoaded() ); REQUIRES( !texturePath.empty() ); m_filePath = texturePath; m_texels = stbi_load( m_filePath.c_str(), &m_width, &m_height, &m_channels, 0 ); LoadSkyboxToOpenGL(); PROMISES( IsLoaded() ); PROMISES( GetFilePath() == texturePath ); }
void Texture::DestroyTexture( Texture*& pTexture ) { REQUIRES( pTexture ); sm_texturePool.erase( pTexture->GetFilePath() ); pTexture = nullptr; PROMISES( pTexture == nullptr ); }
void Texture::LoadFromFile( const std::string& texturePath ) { REQUIRES( !IsLoaded() ); REQUIRES( !texturePath.empty() ); m_filePath = texturePath; int bufferSize; const unsigned char* textureBuffer = reinterpret_cast< const unsigned char* >( getFileManager().readDataFromFile( texturePath, bufferSize ) ); if( textureBuffer != nullptr ) m_texels = stbi_load_from_memory( textureBuffer, bufferSize, &m_width, &m_height, &m_channels, 0 ); SAFE_DELETE( textureBuffer ); LoadToOpenGL(); PROMISES( IsLoaded() ); PROMISES( GetFilePath() == texturePath ); }
Texture* Texture::CreateOrGetTexture( const std::string& textureName, const std::string& texturePath ) { REQUIRES( !texturePath.empty() ); REQUIRES( strlen( texturePath.c_str() ) > 0 ); auto iter = sm_texturePool.find( textureName ); Texture* texture = nullptr;//sm_texturePool[ textureName ]; if( iter == sm_texturePool.end() ) { texture = new Texture( texturePath ); sm_texturePool.insert( std::pair< std::string, Texture* >( textureName, texture ) ); } else texture = iter->second; PROMISES( texture ); PROMISES( texture->IsLoaded() ); PROMISES( texture->GetFilePath() == texturePath ); return texture; }
void Texture::LoadFromMemory( Size width, Size height, Color* pRGBATexels, int channels ) { REQUIRES( !IsLoaded() ); REQUIRES( width > 0 ); REQUIRES( height > 0 ); REQUIRES( pRGBATexels ); m_width = width; m_height = height; m_channels = channels; m_texels = new Color[m_width*m_height*m_channels]; memcpy( m_texels, pRGBATexels, sizeof(Color)*(m_height*m_width*m_channels) ); LoadToOpenGL(); PROMISES( IsLoaded() ); }
bool PWVideoWriter::open( const std::string& filename, int FPS, cv::Size frameSize ){ REQUIRES( !filename.empty(), "File name must not be empty."); // TODO: assigned codex type, and replace 0 with it. // int ex = static_cast<int>(inputVideo.get(CV_CAP_PROP_FOURCC)); // Get Codec Type- Int form // char EXT[] = {(char)(ex & 0XFF) , (char)((ex & 0XFF00) >> 8),(char)((ex & 0XFF0000) >> 16),(char)((ex & 0XFF000000) >> 24), 0}; capture.open(filename, 0, // Codex FPS, // FPS frameSize, // Frame Size true); // isColor PROMISES(capture.isOpened(), "Video is not open, something has gone wrong."); return true; }