2D_Game_Engine
Loading...
Searching...
No Matches
src
utilities.cpp
Go to the documentation of this file.
1
#include <pch.hpp>
2
#include <
utilities.hpp
>
3
#include <
window.hpp
>
4
5
float
GetWidthPercentageInPx
(
float
percentage){
6
return
percentage/100.0f*
Window::Width
;
7
}
8
9
float
GetHeightPercentageInPx
(
float
percentage){
10
return
percentage/100.0f*
Window::Height
;
11
}
12
13
bool
StartNode
(
const
std::string &name,
enum
ImGuiTreeNodeFlags_ flags){
14
return
ImGui::TreeNodeEx(name.c_str(),ImGuiTreeNodeFlags_SpanAvailWidth | flags);
15
}
16
17
std::string
ExecuteCommand
(
const
std::string &command){
18
std::cout<<
"Executing "
<<command<<std::endl;
19
20
char
buffer[128];
21
std::string result;
22
23
std::unique_ptr<FILE,
decltype
(&pclose)>pipe(popen(command.c_str(),
"r"
),pclose);
24
if
(!pipe){
25
perror(
"popen failed"
);
26
}
27
while
(fgets(buffer,128,pipe.get())!=
nullptr
) {
28
result+=buffer;
29
}
30
return
result;
31
}
Window::Height
float Height
Definition
window.hpp:43
Window::Width
float Width
Definition
window.cpp:227
GetHeightPercentageInPx
float GetHeightPercentageInPx(float percentage)
Definition
utilities.cpp:9
StartNode
bool StartNode(const std::string &name, enum ImGuiTreeNodeFlags_ flags)
Definition
utilities.cpp:13
GetWidthPercentageInPx
float GetWidthPercentageInPx(float percentage)
Definition
utilities.cpp:5
ExecuteCommand
std::string ExecuteCommand(const std::string &command)
Definition
utilities.cpp:17
utilities.hpp
window.hpp
Generated by
1.10.0