cpp_launchpad/compile/main.cpp

108 lines
3.0 KiB
C++

#include "act/controller.h"
#include "act/root.h"
#include "code/provider.h"
#include "code/macros.h"
#include <vector>
#include <stdio.h>
#include <string>
#include <fstream>
#include <iostream>
int main(int argc, char *argv[]) {
// Parse configuration files.
std::string obj_list_filepath_l = ROOT_DIRECTORY_MV "/pack/obj_files.txt";
FILE* obj_list_file_l = fopen(obj_list_filepath_l.data(), "r");
char char_l = fgetc(obj_list_file_l);
std::string obj_file_l = "";
std::vector<std::string> obj_files_l;
while (char_l != EOF) {
if (char_l == '\n') {
std::string copy_l(obj_file_l);
obj_files_l.push_back(copy_l);
obj_file_l.clear();
} else {
obj_file_l += char_l;
}
char_l = fgetc(obj_list_file_l);
}
// Read OBJ files.
for (int i = 0; i < obj_files_l.size(); i++) {
obj_file_l = obj_files_l[i];
std::string line_l;
std::ifstream file_l;
file_l.open(obj_file_l);
while (getline(file_l, line_l)) {
char first_l = line_l[0];
char second_l = line_l[1];
printf("%c\n", first_l);
if (first_l == 'v' && second_l != ' ') {
// Create vertex
} else if (first_l == 'v' && second_l == 'n') {
// Create vertex normal vector
} else if (first_l == 'v' && second_l == 't') {
// Create texture coordinate
} else if (first_l == 'f') {
// Create face
} else {
continue;
}
}
}
// Create text service.
text_service_factory_t text_service_factory_l;
text_service_t::configuration_t text_service_configuration_l;
text_service_configuration_l.language_m = text_service_t::language_t::english;
text_service_t* text_service_l = text_service_factory_l.create(
&text_service_configuration_l
).value_m;
// Create window service.
window_service_factory_t window_service_factory_l;
window_service_t::configuration_t window_service_configuration_l;
window_service_t* window_service_l = window_service_factory_l.create(
&window_service_configuration_l
).value_m;
// Create provider.
provider_factory_t provider_factory_l;
provider_t::configuration_t provider_configuration_l;
provider_configuration_l.text_service_m = text_service_l;
provider_configuration_l.window_service_m = window_service_l;
provider_t* provider_l = provider_factory_l.create(
&provider_configuration_l
).value_m;
// Create root controller.
root_controller_factory_t root_controller_factory_l;
root_controller_t::configuration_t root_controller_configuration_l;
root_controller_configuration_l.provider_m = provider_l;
root_controller_t* root_controller_l = root_controller_factory_l.create(
&root_controller_configuration_l
).value_m;
// Start root controller.
controller_t::error_t root_controller_event_l = root_controller_l->on_event(
controller_t::event_t::start
).error_m;
// Clean up
root_controller_factory_l.dispose(
root_controller_l
);
provider_factory_l.dispose(
provider_l
);
window_service_factory_l.dispose(
window_service_l
);
text_service_factory_l.dispose(
text_service_l
);
if (root_controller_event_l == controller_t::error_t::none) {
return 0;
}
return 1;
}