|
| 1 | +/* |
| 2 | + * Copyright 2019-2026 Diligent Graphics LLC |
| 3 | + * |
| 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 |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 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. |
| 15 | + * |
| 16 | + * In no event and under no legal theory, whether in tort (including negligence), |
| 17 | + * contract, or otherwise, unless required by applicable law (such as deliberate |
| 18 | + * and grossly negligent acts) or agreed to in writing, shall any Contributor be |
| 19 | + * liable for any damages, including any direct, indirect, special, incidental, |
| 20 | + * or consequential damages of any character arising as a result of this License or |
| 21 | + * out of the use or inability to use the software (including but not limited to damages |
| 22 | + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and |
| 23 | + * all other commercial damages or losses), even if such Contributor has been advised |
| 24 | + * of the possibility of such damages. |
| 25 | + */ |
| 26 | + |
| 27 | +#include "GLTFUtilities.hpp" |
| 28 | + |
| 29 | +#include "DebugUtilities.hpp" |
| 30 | + |
| 31 | +namespace Diligent |
| 32 | +{ |
| 33 | + |
| 34 | +namespace GLTF |
| 35 | +{ |
| 36 | + |
| 37 | +std::pair<FILTER_TYPE, FILTER_TYPE> GltfFilterModeToFilterType(int32_t GltfFilterMode) |
| 38 | +{ |
| 39 | + switch (GltfFilterMode) |
| 40 | + { |
| 41 | + case 9728: // NEAREST |
| 42 | + return {FILTER_TYPE_POINT, FILTER_TYPE_POINT}; |
| 43 | + case 9729: // LINEAR |
| 44 | + return {FILTER_TYPE_LINEAR, FILTER_TYPE_LINEAR}; |
| 45 | + case 9984: // NEAREST_MIPMAP_NEAREST |
| 46 | + return {FILTER_TYPE_POINT, FILTER_TYPE_POINT}; |
| 47 | + case 9985: // LINEAR_MIPMAP_NEAREST |
| 48 | + return {FILTER_TYPE_LINEAR, FILTER_TYPE_POINT}; |
| 49 | + case 9986: // NEAREST_MIPMAP_LINEAR |
| 50 | + return {FILTER_TYPE_POINT, FILTER_TYPE_LINEAR}; |
| 51 | + case 9987: // LINEAR_MIPMAP_LINEAR |
| 52 | + return {FILTER_TYPE_LINEAR, FILTER_TYPE_LINEAR}; |
| 53 | + default: |
| 54 | + LOG_WARNING_MESSAGE("Unknown gltf filter mode: ", GltfFilterMode, ". Defaulting to linear."); |
| 55 | + return {FILTER_TYPE_LINEAR, FILTER_TYPE_LINEAR}; |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +TEXTURE_ADDRESS_MODE GltfWrapModeToAddressMode(int32_t GltfWrapMode) |
| 60 | +{ |
| 61 | + switch (GltfWrapMode) |
| 62 | + { |
| 63 | + case 10497: |
| 64 | + return TEXTURE_ADDRESS_WRAP; |
| 65 | + case 33071: |
| 66 | + return TEXTURE_ADDRESS_CLAMP; |
| 67 | + case 33648: |
| 68 | + return TEXTURE_ADDRESS_MIRROR; |
| 69 | + default: |
| 70 | + LOG_WARNING_MESSAGE("Unknown gltf address wrap mode: ", GltfWrapMode, ". Defaulting to WRAP."); |
| 71 | + return TEXTURE_ADDRESS_WRAP; |
| 72 | + } |
| 73 | +} |
| 74 | + |
| 75 | +} // namespace GLTF |
| 76 | + |
| 77 | +} // namespace Diligent |
0 commit comments