2D_Game_Engine
Loading...
Searching...
No Matches
utilities.cpp
Go to the documentation of this file.
1#include <pch.hpp>
2#include <utilities.hpp>
3#include <window.hpp>
4
5float GetWidthPercentageInPx(float percentage){
6 return percentage/100.0f*Window::Width;
7}
8
9float GetHeightPercentageInPx(float percentage){
10 return percentage/100.0f*Window::Height;
11}
12
13bool StartNode(const std::string &name,enum ImGuiTreeNodeFlags_ flags){
14 return ImGui::TreeNodeEx(name.c_str(),ImGuiTreeNodeFlags_SpanAvailWidth | flags);
15}
16
17std::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}
float Height
Definition window.hpp:43
float Width
Definition window.cpp:227
float GetHeightPercentageInPx(float percentage)
Definition utilities.cpp:9
bool StartNode(const std::string &name, enum ImGuiTreeNodeFlags_ flags)
Definition utilities.cpp:13
float GetWidthPercentageInPx(float percentage)
Definition utilities.cpp:5
std::string ExecuteCommand(const std::string &command)
Definition utilities.cpp:17