bool GLES2Sprite::LoadSprite( VideoWeakPtr video, const str_type::string& fileName, Color mask, const unsigned int width, const unsigned int height) { m_video = video.lock().get(); if (width == 0 || height == 0) { m_texture = boost::dynamic_pointer_cast<GLES2Texture>(m_video->LoadTextureFromFile(fileName, 0, width, height, 1)); if (!m_texture) { m_logger.Log(fileName + " could not load sprite", Platform::FileLogger::ERROR); m_video->Message(fileName + " could not load sprite", GSMT_ERROR); return false; } else { const Texture::PROFILE profile = m_texture->GetProfile(); m_bitmapSize.x = static_cast<float>(profile.width); m_bitmapSize.y = static_cast<float>(profile.height); } } else { m_bitmapSize.x = static_cast<float>(width); m_bitmapSize.y = static_cast<float>(height); } m_type = T_BITMAP; SetupSpriteRects(1, 1); return true; }
bool GLES2Sprite::CreateRenderTarget( VideoWeakPtr video, const unsigned int width, const unsigned int height, const Texture::TARGET_FORMAT format) { m_video = video.lock().get(); m_texture = boost::dynamic_pointer_cast<GLES2Texture>(m_video->CreateRenderTargetTexture(width, height, format)); m_bitmapSize = Vector2(static_cast<float>(width), static_cast<float>(height)); m_type = T_TARGET; SetupSpriteRects(1, 1); return true; }
bool GLES2Sprite::LoadSprite( VideoWeakPtr video, GS_BYTE* pBuffer, const unsigned int bufferLength, Color mask, const unsigned int width, const unsigned int height) { m_video = video.lock().get(); // TODO // SetupSpriteRects(1, 1); return false; }
bool GLES2Texture::LoadTexture( VideoWeakPtr video, const void* pBuffer, Color mask, const unsigned int width, const unsigned int height, const unsigned int nMipMaps, const unsigned int bufferLength) { int iWidth, iHeight, channels; unsigned char *ht_map = SOIL_load_image_from_memory((unsigned char*)pBuffer, bufferLength, &iWidth, &iHeight, &channels, SOIL_LOAD_AUTO); if (ht_map) { ApplyPixelMask(ht_map, mask, channels, iWidth, iHeight); m_textureInfo.m_texture = SOIL_create_OGL_texture(ht_map, iWidth, iHeight, channels, m_textureID++, SOIL_FLAG_POWER_OF_TWO); } std::stringstream ss; ss << m_fileName << " file ID " << m_textureInfo.m_texture; m_logger.Log(ss.str(), Platform::FileLogger::INFO); if (!m_textureInfo.m_texture) { m_logger.Log(m_fileName + " couldn't load texture", Platform::FileLogger::ERROR); video.lock()->Message(m_fileName + " couldn't load texture", GSMT_ERROR); SOIL_free_image_data(ht_map); return false; } else { m_type = TT_STATIC; m_profile.width = static_cast<unsigned int>(iWidth); m_profile.height = static_cast<unsigned int>(iHeight); m_profile.originalWidth = m_profile.width; m_profile.originalHeight = m_profile.height; m_logger.Log(m_fileName + " texture loaded", Platform::FileLogger::INFO); SOIL_free_image_data(ht_map); } GLES2UniformParameter::m_boundTexture2D = 0; glBindTexture(GL_TEXTURE_2D, 0); return true; }
bool GLSprite::LoadSprite( VideoWeakPtr video, const str_type::string& fileName, Color mask, const unsigned int width, const unsigned int height) { m_video = boost::dynamic_pointer_cast<GLVideo>(video.lock()); TexturePtr tex = m_video.lock()->LoadTextureFromFile(fileName, mask, width, height, 0); m_texture = boost::dynamic_pointer_cast<GLTexture>(tex); if (!m_texture) return false; m_type = Sprite::T_BITMAP; Texture::PROFILE profile = m_texture->GetProfile(); m_bitmapSize = math::Vector2(static_cast<float>(profile.width), static_cast<float>(profile.height)); SetupSpriteRects(1, 1); return true; }
bool GLSprite::LoadSprite( VideoWeakPtr video, GS_BYTE* pBuffer, const unsigned int bufferLength, Color mask, const unsigned int width, const unsigned int height) { m_video = boost::dynamic_pointer_cast<GLVideo>(video.lock()); TexturePtr tex = m_video.lock()->CreateTextureFromFileInMemory(pBuffer, bufferLength, mask, width, height, 0); m_texture = boost::dynamic_pointer_cast<GLTexture>(tex); if (!m_texture) return false; m_type = Sprite::T_BITMAP; Texture::PROFILE profile = m_texture->GetProfile(); m_bitmapSize = math::Vector2(static_cast<float>(profile.width), static_cast<float>(profile.height)); SetupSpriteRects(1, 1); return true; }