Skip to content

Commit c693122

Browse files
Added TVOS platform
1 parent e6f6a03 commit c693122

8 files changed

Lines changed: 140 additions & 5 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 3.6)
22

33
file(RELATIVE_PATH DILIGENT_TOOLS_DIR "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
44

5-
if(PLATFORM_WIN32 OR PLATFORM_UNIVERSAL_WINDOWS OR PLATFORM_LINUX OR PLATFORM_MACOS OR PLATFORM_IOS)
5+
if(PLATFORM_WIN32 OR PLATFORM_UNIVERSAL_WINDOWS OR PLATFORM_LINUX OR PLATFORM_MACOS OR PLATFORM_IOS OR PLATFORM_TVOS)
66
option(DILIGENT_INSTALL_TOOLS "Install DiligentTool module headers and libraries" ON)
77
else()
88
set(DILIGENT_INSTALL_TOOLS OFF)

Imgui/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ elseif(PLATFORM_MACOS)
7171
elseif(PLATFORM_IOS)
7272
list(APPEND SOURCE src/ImGuiImplIOS.mm)
7373
list(APPEND INTERFACE interface/ImGuiImplIOS.hpp)
74+
elseif(PLATFORM_TVOS)
75+
list(APPEND SOURCE src/ImGuiImplTVOS.mm)
76+
list(APPEND INTERFACE interface/ImGuiImplTVOS.hpp)
7477
endif()
7578

7679
add_library(Diligent-Imgui STATIC

Imgui/interface/ImGuiImplTVOS.hpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright 2019-2021 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+
#pragma once
28+
29+
#include <mutex>
30+
#include "ImGuiImplDiligent.hpp"
31+
32+
namespace Diligent
33+
{
34+
35+
class ImGuiImplTVOS final : public ImGuiImplDiligent
36+
{
37+
public:
38+
ImGuiImplTVOS(IRenderDevice* pDevice,
39+
TEXTURE_FORMAT BackBufferFmt,
40+
TEXTURE_FORMAT DepthBufferFmt,
41+
Uint32 InitialVertexBufferSize = ImGuiImplDiligent::DefaultInitialVBSize,
42+
Uint32 InitialIndexBufferSize = ImGuiImplDiligent::DefaultInitialIBSize);
43+
~ImGuiImplTVOS();
44+
45+
// clang-format off
46+
ImGuiImplTVOS (const ImGuiImplTVOS&) = delete;
47+
ImGuiImplTVOS ( ImGuiImplTVOS&&) = delete;
48+
ImGuiImplTVOS& operator = (const ImGuiImplTVOS&) = delete;
49+
ImGuiImplTVOS& operator = ( ImGuiImplTVOS&&) = delete;
50+
// clang-format on
51+
52+
virtual void NewFrame(Uint32 RenderSurfaceWidth,
53+
Uint32 RenderSurfaceHeight,
54+
SURFACE_TRANSFORM SurfacePreTransform) override final;
55+
virtual void Render(IDeviceContext* pCtx) override final;
56+
57+
private:
58+
std::mutex m_Mtx;
59+
double m_Time = 0.0;
60+
};
61+
62+
} // namespace Diligent

Imgui/src/ImGuiImplTVOS.mm

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/* Copyright 2019 Diligent Graphics LLC
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
12+
*
13+
* In no event and under no legal theory, whether in tort (including negligence),
14+
* contract, or otherwise, unless required by applicable law (such as deliberate
15+
* and grossly negligent acts) or agreed to in writing, shall any Contributor be
16+
* liable for any damages, including any direct, indirect, special, incidental,
17+
* or consequential damages of any character arising as a result of this License or
18+
* out of the use or inability to use the software (including but not limited to damages
19+
* for loss of goodwill, work stoppage, computer failure or malfunction, or any and
20+
* all other commercial damages or losses), even if such Contributor has been advised
21+
* of the possibility of such damages.
22+
*/
23+
24+
#include "imgui.h"
25+
#include "ImGuiImplTVOS.hpp"
26+
#import <CoreFoundation/CoreFoundation.h>
27+
28+
namespace Diligent
29+
{
30+
31+
ImGuiImplTVOS::ImGuiImplTVOS(IRenderDevice* pDevice,
32+
TEXTURE_FORMAT BackBufferFmt,
33+
TEXTURE_FORMAT DepthBufferFmt,
34+
Uint32 InitialVertexBufferSize,
35+
Uint32 InitialIndexBufferSize) :
36+
ImGuiImplDiligent(pDevice, BackBufferFmt, DepthBufferFmt, InitialVertexBufferSize, InitialIndexBufferSize)
37+
{
38+
ImGuiIO& io = ImGui::GetIO();
39+
//io.FontGlobalScale = 2;
40+
io.BackendPlatformName = "Diligent-ImGuiImplTVOS";
41+
}
42+
43+
ImGuiImplTVOS::~ImGuiImplTVOS()
44+
{
45+
}
46+
47+
void ImGuiImplTVOS::NewFrame(Uint32 RenderSurfaceWidth,
48+
Uint32 RenderSurfaceHeight,
49+
SURFACE_TRANSFORM SurfacePreTransform)
50+
{
51+
std::lock_guard<std::mutex> Lock{m_Mtx};
52+
if (m_Time == 0.0)
53+
m_Time = CFAbsoluteTimeGetCurrent();
54+
CFAbsoluteTime current_time = CFAbsoluteTimeGetCurrent();
55+
ImGuiIO& io = ImGui::GetIO();
56+
io.DeltaTime = current_time - m_Time;
57+
m_Time = current_time;
58+
59+
io.DisplaySize = ImVec2(RenderSurfaceWidth, RenderSurfaceHeight);
60+
61+
ImGuiImplDiligent::NewFrame(RenderSurfaceWidth, RenderSurfaceHeight, SurfacePreTransform);
62+
}
63+
64+
void ImGuiImplTVOS::Render(IDeviceContext* pCtx)
65+
{
66+
std::lock_guard<std::mutex> Lock{m_Mtx};
67+
ImGuiImplDiligent::Render(pCtx);
68+
}
69+
70+
}

ThirdParty/libtiff/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ set(SOURCE
4747

4848
if(PLATFORM_WIN32)
4949
list(APPEND SOURCE tif_win32.c)
50-
elseif(PLATFORM_ANDROID OR PLATFORM_UNIVERSAL_WINDOWS OR PLATFORM_LINUX OR PLATFORM_MACOS OR PLATFORM_IOS)
50+
elseif(PLATFORM_ANDROID OR PLATFORM_UNIVERSAL_WINDOWS OR PLATFORM_LINUX OR PLATFORM_MACOS OR PLATFORM_IOS OR PLATFORM_TVOS)
5151
list(APPEND SOURCE tif_unix.c)
5252
else()
5353
message(FATAL_ERROR "Unknown platform")

ThirdParty/libtiff/tif_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
# include "tif_config.android.h"
1212

13-
#elif PLATFORM_LINUX || PLATFORM_MACOS || PLATFORM_IOS
13+
#elif PLATFORM_LINUX || PLATFORM_MACOS || PLATFORM_IOS || PLATFORM_TVOS
1414

1515
# include "tif_config.linux.h"
1616

ThirdParty/libtiff/tiffconf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# include "tiffconf.linux.h"
77
# endif
88

9-
#elif PLATFORM_ANDROID || PLATFORM_LINUX || PLATFORM_MACOS || PLATFORM_IOS
9+
#elif PLATFORM_ANDROID || PLATFORM_LINUX || PLATFORM_MACOS || PLATFORM_IOS || PLATFORM_TVOS
1010

1111
# include "tiffconf.linux.h"
1212

ThirdParty/zlib-1.2.8/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ if(MSVC)
4444
target_compile_options(ZLib PRIVATE /W3 /wd4131 /wd4127 /wd4244 /wd4996)
4545
endif()
4646

47-
if(PLATFORM_LINUX OR PLATFORM_ANDROID OR PLATFORM_MACOS OR PLATFORM_IOS)
47+
if(PLATFORM_LINUX OR PLATFORM_ANDROID OR PLATFORM_MACOS OR PLATFORM_IOS OR PLATFORM_TVOS)
4848
target_compile_definitions(ZLib PRIVATE HAVE_UNISTD_H)
4949
endif()
5050

0 commit comments

Comments
 (0)