2 * Copyright (c) 2022 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-scene3d/public-api/loader/cube-data.h"
22 #include "dali/public-api/rendering/texture.h"
30 Texture CubeData::CreateTexture() const
32 Texture texture = Texture::New(TextureType::TEXTURE_CUBE, data[0][0].GetPixelFormat(), data[0][0].GetWidth(), data[0][0].GetHeight());
33 for(size_t iSide = 0u, iEndSize = data.size(); iSide < iEndSize; ++iSide)
35 auto& side = data[iSide];
36 for(size_t iMipLevel = 0u, iEndMipLevel = data[0].size(); iMipLevel < iEndMipLevel; ++iMipLevel)
38 texture.Upload(side[iMipLevel], CubeMapLayer::POSITIVE_X + iSide, iMipLevel, 0u, 0u, side[iMipLevel].GetWidth(), side[iMipLevel].GetHeight());
42 // If mipmap is not defined explicitly, use GenerateMipmaps.
43 // TODO: Maybe we can use better way to know it already has mipmap or not.
44 if(data.size() > 0u && data[0].size() == 1u)
46 texture.GenerateMipmaps();
53 } // namespace Scene3D