Skip to content

Commit 6a60f19

Browse files
All build issues are resolve3d
1 parent eaf582f commit 6a60f19

File tree

4 files changed

+102
-92
lines changed

4 files changed

+102
-92
lines changed

examples_tests/61.UI/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ if(NOT RES)
33
message(FATAL_ERROR "common.cmake not found. Should be in {repo_root}/cmake directory")
44
endif()
55

6-
list(
7-
APPEND
8-
EXTRA_SOURCES
6+
set(EXTRA_SOURCES "")
7+
list(APPEND EXTRA_SOURCES
98
"UI_System.cpp"
109
"UI_System.hpp"
1110
)
1211

13-
nbl_create_executable_project("${EXTRA_SOURCES}" "" "" "")
12+
nbl_create_executable_project("${EXTRA_SOURCES}" "" "" "imgui")

examples_tests/61.UI/UI_System.cpp

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ using namespace nbl::core;
1010
using namespace nbl::asset;
1111
using namespace nbl::ui;
1212

13-
namespace MFA::UI_System
13+
namespace UI_System
1414
{
1515

1616
//-----------------------------------------------------------------------------
@@ -508,11 +508,11 @@ namespace MFA::UI_System
508508
//-------------------------------------------------------------------------------------------------
509509

510510
void Init(
511-
smart_refctd_ptr<ILogicalDevice> const& device,
511+
nbl::core::smart_refctd_ptr<nbl::video::ILogicalDevice> const& device,
512512
float screenWidth, float screenHeight,
513-
smart_refctd_ptr<IGPURenderpass>& renderPass,
514-
IGPUPipelineCache* pipelineCache,
515-
IGPUObjectFromAssetConverter::SParams& cpu2GpuParams
513+
nbl::core::smart_refctd_ptr<nbl::video::IGPURenderpass>& renderPass,
514+
nbl::video::IGPUPipelineCache* pipelineCache,
515+
nbl::video::IGPUObjectFromAssetConverter::SParams& cpu2GpuParams
516516
)
517517
{
518518
state = new State();
@@ -607,7 +607,7 @@ namespace MFA::UI_System
607607

608608
//-------------------------------------------------------------------------------------------------
609609

610-
bool Render(float const deltaTimeInSec, IGPUCommandBuffer& commandBuffer)
610+
bool Render(float deltaTimeInSec, nbl::video::IGPUCommandBuffer& commandBuffer)
611611
{
612612
ImGuiIO& io = ImGui::GetIO();
613613
assert(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer backend. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame().");
@@ -628,7 +628,12 @@ namespace MFA::UI_System
628628
//);
629629

630630
auto const* drawData = ImGui::GetDrawData();
631-
assert(drawData != nullptr);
631+
632+
if (drawData == nullptr)
633+
{
634+
return false;
635+
}
636+
//assert(drawData != nullptr);
632637

633638
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
634639
float const frameBufferWidth = drawData->DisplaySize.x * drawData->FramebufferScale.x;
@@ -822,11 +827,11 @@ namespace MFA::UI_System
822827

823828
//-------------------------------------------------------------------------------------------------
824829

825-
void PostRender(float deltaTimeInSec)
830+
void Update(float deltaTimeInSec)
826831
{
827832
ImGui::NewFrame();
828833
state->hasFocus = false;
829-
for (auto const & subscriber : state->subscribers)
834+
for (auto const& subscriber : state->subscribers)
830835
{
831836
subscriber.listener();
832837
}
@@ -1090,12 +1095,12 @@ namespace MFA::UI_System
10901095

10911096
//-------------------------------------------------------------------------------------------------
10921097

1093-
#ifdef __ANDROID__
1094-
void SetAndroidApp(android_app* pApp)
1095-
{
1096-
androidApp = pApp;
1097-
}
1098-
#endif
1098+
//#ifdef __ANDROID__
1099+
// void SetAndroidApp(android_app* pApp)
1100+
// {
1101+
// androidApp = pApp;
1102+
// }
1103+
//#endif
10991104

11001105
//-------------------------------------------------------------------------------------------------
11011106

examples_tests/61.UI/UI_System.hpp

Lines changed: 70 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,107 @@
11
#pragma once
22

3+
#include <nabla.h>
4+
35
#include <glm/vec3.hpp>
46

57
namespace UI_System
68
{
79

8-
// TODO Support for custom font
9-
void Init(
10-
nbl::core::smart_refctd_ptr<nbl::video::ILogicalDevice> const & device,
11-
float screenWidth, float screenHeight,
12-
nbl::core::smart_refctd_ptr<nbl::video::IGPURenderpass> & renderPass,
13-
nbl::video::IGPUPipelineCache * pipelineCache,
14-
nbl::video::IGPUObjectFromAssetConverter::SParams & cpu2GpuParams
15-
);
10+
// TODO Support for custom font
11+
void Init(
12+
nbl::core::smart_refctd_ptr<nbl::video::ILogicalDevice> const& device,
13+
float screenWidth, float screenHeight,
14+
nbl::core::smart_refctd_ptr<nbl::video::IGPURenderpass>& renderPass,
15+
nbl::video::IGPUPipelineCache* pipelineCache,
16+
nbl::video::IGPUObjectFromAssetConverter::SParams& cpu2GpuParams
17+
);
1618

17-
bool Render(float const deltaTimeInSec, nbl::video::IGPUCommandBuffer & commandBuffer);
19+
bool Render(float deltaTimeInSec, nbl::video::IGPUCommandBuffer& commandBuffer);
1820

19-
void PostRender(float deltaTimeInSec);
21+
void Update(float deltaTimeInSec);
2022

21-
void BeginWindow(char const * windowName);
23+
void BeginWindow(char const* windowName);
2224

23-
void EndWindow();
25+
void EndWindow();
2426

25-
int Register(std::function<void()> const & listener);
27+
int Register(std::function<void()> const& listener);
2628

27-
bool UnRegister(int listenerId);
29+
bool UnRegister(int listenerId);
2830

29-
void SetNextItemWidth(float nextItemWidth);
31+
void SetNextItemWidth(float nextItemWidth);
3032

31-
void Text(char const * label, ...);
33+
void Text(char const* label, ...);
3234

33-
void InputFloat(char const * label, float * value);
35+
void InputFloat(char const* label, float* value);
3436

35-
void InputFloat2(char const * label, float * value);
37+
void InputFloat2(char const* label, float* value);
3638

37-
void InputFloat3(char const * label, float * value);
39+
void InputFloat3(char const* label, float* value);
3840

39-
void InputFloat4(char const * label, float * value);
41+
void InputFloat4(char const* label, float* value);
4042

41-
void InputFloat3(char const * label, glm::vec3 & value);
43+
void InputFloat3(char const* label, glm::vec3& value);
4244

43-
bool Combo(
44-
char const * label,
45-
int32_t * selectedItemIndex,
46-
char const ** items,
47-
int32_t itemsCount
48-
);
45+
bool Combo(
46+
char const* label,
47+
int32_t* selectedItemIndex,
48+
char const** items,
49+
int32_t itemsCount
50+
);
4951

50-
bool Combo(
51-
const char * label,
52-
int * selectedItemIndex,
53-
std::vector<std::string> & values
54-
);
52+
bool Combo(
53+
const char* label,
54+
int* selectedItemIndex,
55+
std::vector<std::string>& values
56+
);
5557

56-
void SliderInt(
57-
char const * label,
58-
int * value,
59-
int minValue,
60-
int maxValue
61-
);
58+
void SliderInt(
59+
char const* label,
60+
int* value,
61+
int minValue,
62+
int maxValue
63+
);
6264

63-
void SliderFloat(
64-
char const * label,
65-
float * value,
66-
float minValue,
67-
float maxValue
68-
);
65+
void SliderFloat(
66+
char const* label,
67+
float* value,
68+
float minValue,
69+
float maxValue
70+
);
6971

70-
void Checkbox(
71-
char const * label,
72-
bool * value
73-
);
72+
void Checkbox(
73+
char const* label,
74+
bool* value
75+
);
7476

75-
void Spacing();
77+
void Spacing();
7678

77-
void Button(
78-
char const * label,
79-
std::function<void()> const & onPress
80-
);
79+
void Button(
80+
char const* label,
81+
std::function<void()> const& onPress
82+
);
8183

82-
void InputText(
83-
char const * label,
84-
std::string & outValue
85-
);
84+
void InputText(
85+
char const* label,
86+
std::string& outValue
87+
);
8688

87-
[[nodiscard]]
88-
bool HasFocus();
89+
[[nodiscard]]
90+
bool HasFocus();
8991

90-
void Shutdown();
92+
void Shutdown();
9193

92-
[[nodiscard]]
93-
bool IsItemActive();
94+
[[nodiscard]]
95+
bool IsItemActive();
9496

95-
[[nodiscard]]
96-
bool TreeNode(char const * name);
97+
[[nodiscard]]
98+
bool TreeNode(char const* name);
9799

98-
void TreePop();
100+
void TreePop();
99101

100-
#ifdef __ANDROID__
101-
void SetAndroidApp(android_app * pApp);
102-
#endif
102+
//#ifdef __ANDROID__
103+
// void SetAndroidApp(android_app * pApp);
104+
//#endif
103105

104106
}
105107

examples_tests/61.UI/main.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
// For conditions of distribution and use, see copyright notice in nabla.h
44

55
#define _NBL_STATIC_LIB_
6+
#include <nabla.h>
67

7-
#include <iostream>
8-
#include <cstdio>
9-
#include <random>
108

11-
#include "../common/Camera.hpp"
9+
//#include <iostream>
10+
//#include <cstdio>
11+
//#include <random>
12+
//
13+
//#include <nabla.h>
14+
//
15+
//#include "../common/Camera.hpp"
1216
#include "../common/CommonAPI.h"
13-
#include "nbl/ext/ScreenShot/ScreenShot.h"
17+
//#include "nbl/ext/ScreenShot/ScreenShot.h"
1418

1519
#include "UI_System.hpp"
1620

0 commit comments

Comments
 (0)