2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include "game-texture.h"
21 #include "game-utils.h"
23 #include <dali-toolkit/public-api/image-loader/sync-image-loader.h>
25 GameTexture::GameTexture()
31 GameTexture::~GameTexture()
35 GameTexture::GameTexture( const char* filename )
42 bool GameTexture::Load( const char* filename )
44 Dali::PixelData pixelData = Dali::Toolkit::SyncImageLoader::Load( filename );
51 Dali::Texture texture = Dali::Texture::New( Dali::TextureType::TEXTURE_2D,
52 pixelData.GetPixelFormat(),
54 pixelData.GetHeight() );
55 texture.Upload( pixelData );
56 texture.GenerateMipmaps();
57 Dali::TextureSet textureSet = Dali::TextureSet::New();
58 textureSet.SetTexture( 0, texture );
59 Dali::Sampler sampler = Dali::Sampler::New();
60 sampler.SetWrapMode( Dali::WrapMode::REPEAT, Dali::WrapMode::REPEAT, Dali::WrapMode::REPEAT );
61 sampler.SetFilterMode( Dali::FilterMode::LINEAR_MIPMAP_LINEAR, Dali::FilterMode::LINEAR );
62 textureSet.SetSampler( 0, sampler );
66 mTextureSet = textureSet;
68 mUniqueId = GameUtils::HashString( filename );
75 Dali::TextureSet& GameTexture::GetTextureSet()
80 uint32_t GameTexture::GetUniqueId()
85 bool GameTexture::IsReady()