2 * Copyright (c) 2020 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.
19 #include "dali-scene-loader/public-api/environment-definition.h"
20 #include "dali-scene-loader/public-api/utils.h"
27 EnvironmentDefinition::RawData
28 EnvironmentDefinition::LoadRaw(const std::string& environmentsPath) const
31 auto loadFn = [&environmentsPath](const std::string& path, CubeData& cd) {
35 for (auto& face : cd.data)
37 face.push_back(PixelData::New(new uint8_t[3]{ 0xff, 0xff, 0xff }, 3, 1, 1, Pixel::RGB888, PixelData::DELETE_ARRAY));
40 else if(!LoadCubeMapData(environmentsPath + path, cd))
42 ExceptionFlinger(ASSERT_LOCATION) << "Failed to load cubemap texture from '" <<
47 loadFn(mDiffuseMapPath, raw.mDiffuse);
48 loadFn(mSpecularMapPath, raw.mSpecular);
52 EnvironmentDefinition::Textures EnvironmentDefinition::Load(RawData&& raw) const
56 // This texture should have 6 faces and only one mipmap
57 if (!raw.mDiffuse.data.empty())
59 textures.mDiffuse = raw.mDiffuse.CreateTexture();
62 // This texture should have 6 faces and 6 mipmaps
63 if (!raw.mSpecular.data.empty())
65 textures.mSpecular = raw.mSpecular.CreateTexture();