10 std::string &window_name,
unsigned int width,
unsigned int height,
unsigned int fullscreen_width,
11 unsigned int fullscreen_height,std::string &scene_path,
TonemapType tonemap,
float gamma,
float exposure,
bool resizable=
false){
12 FILE *fdest=fopen(
"temp/data.cpp",
"w");
14 perror(
"Failed to open file temp/data.cpp");
18 fprintf(fdest,
"#include <pch.hpp>\n");
19 fprintf(fdest,
"#include <scene.hpp>\n\n");
20 fprintf(fdest,
"const char *WINDOW_NAME=\"%s\";\n",window_name.c_str());
21 fprintf(fdest,
"unsigned int WINDOW_WIDTH=%u;\n",width);
22 fprintf(fdest,
"unsigned int WINDOW_HEIGHT=%u;\n",height);
23 fprintf(fdest,
"unsigned int FULLSCREEN_WIDTH=%u;\n",fullscreen_width);
24 fprintf(fdest,
"unsigned int FULLSCREEN_HEIGHT=%u;\n",fullscreen_height);
25 fprintf(fdest,
"std::string SCENE_PATH=\"%s\";\n",scene_path.c_str());
26 fprintf(fdest,
"bool RESIZABLE=%s;\n",((resizable)?
"true":
"false"));
27 fprintf(fdest,
"TonemapType TONE_MAP_TYPE=TonemapType::%s;\n",
TonemapTypeToString(tonemap).c_str());
28 fprintf(fdest,
"float GAMMA=%f;\n",gamma);
29 fprintf(fdest,
"float EXPOSURE=%f;\n",exposure);
31 for(
auto &[fn_name,
id]:script_components){
33 fprintf(fdest,
"extern void %s(Scene *scene,NativeScriptComponent *nsc,float frame_time);\n",fn_name.c_str());
37 fprintf(fdest,
"\nvoid LoadScripts(Scene *scene){\n");
40 for(
auto &[fn_name,
id]:script_components){
42 fprintf(fdest,
"\tscene->AddComponent<NativeScriptComponent>((uint32_t)%u);\n",
id);
43 fprintf(fdest,
"\tauto nsc%d=scene->GetComponent<NativeScriptComponent>((uint32_t)%u)->OnUpdate=%s;\n",
i,
id,fn_name.c_str());
54 static std::thread applicationThread;
55 static std::atomic<bool> isApplicationRunning=
false;
57 if(isApplicationRunning.load()){
61 isApplicationRunning.store(
true);
62 applicationThread=std::thread([&isApplicationRunning,&script_components](){
63 std::string scene_path=
"test.scene";
67 printf(
"%s\n",
ExecuteCommand(
"cd application && premake5 gmake2 --file=application_premake.lua").c_str());
69 printf(
"%s\n",
ExecuteCommand(
"cd lib && make config=release").c_str());
70 printf(
"%s\n",
ExecuteCommand(
"cd temp && make config=release").c_str());
75 strcat(command,
"cp ");
77 strcat(command,
" bin/Release/");
81 system(
"cd bin/Release && ./Application");
83 printf(
"%s\n",
ExecuteCommand(
"cd lib && make config=debug").c_str());
84 printf(
"%s\n",
ExecuteCommand(
"cd temp && make config=debug").c_str());
89 strcat(command,
"cp ");
91 strcat(command,
" bin/Debug/");
95 system(
"cd bin/Debug && ./Application");
96 #elif defined(ENABLE_PROFILING)
97 printf(
"%s\n",
ExecuteCommand(
"cd lib && make config=profile").c_str());
98 printf(
"%s\n",
ExecuteCommand(
"cd temp && make config=profile").c_str());
103 strcat(command,
"cp ");
105 strcat(command,
" bin/Profile/");
109 system(
"cd bin/Profile && ./Application");
112 isApplicationRunning.store(
false);
114 applicationThread.detach();
unsigned int FULLSCREEN_WIDTH
unsigned int WINDOW_HEIGHT
unsigned int WINDOW_WIDTH
unsigned int FULLSCREEN_HEIGHT
TonemapType GetTonemapType()
std::string TonemapTypeToString(TonemapType type)
std::string ExecuteCommand(const std::string &command)
Renderer * RENDERER
The main renderer.