Compare commits

..

1 commit

Author SHA1 Message Date
2c736089be modules are good now 2023-10-18 19:48:48 +02:00
5 changed files with 10 additions and 27 deletions

1
.gitignore vendored
View file

@ -5,4 +5,3 @@ CMakeDoxygenDefaults.cmake
Makefile Makefile
cmake_install.cmake cmake_install.cmake
bin/loader/loader bin/loader/loader
lib/glfw

View file

@ -30,7 +30,7 @@ source_group("sources" FILES ${PROJECT_SOURCES})
source_group("vendors" FILES ${VENDORS_SOURCES}) source_group("vendors" FILES ${VENDORS_SOURCES})
find_package(Boost 1.56 REQUIRED COMPONENTS find_package(Boost 1.56 REQUIRED COMPONENTS
program_options log) program_options)
set(EXE_1_NAME loader) set(EXE_1_NAME loader)
file( file(
@ -41,7 +41,7 @@ set(CMAKE_BINARY_DIR "bin")
add_executable(${EXE_1_NAME} ${EXE_1_SOURCES} ${PROJECT_HEADERS} add_executable(${EXE_1_NAME} ${EXE_1_SOURCES} ${PROJECT_HEADERS}
${PROJECT_SHADERS} ${VENDORS_SOURCES}) ${PROJECT_SHADERS} ${VENDORS_SOURCES})
target_link_libraries(${EXE_1_NAME} glfw Boost::program_options Boost::log) target_link_libraries(${EXE_1_NAME} glfw Boost::program_options)
target_include_directories(${EXE_1_NAME} PRIVATE include) target_include_directories(${EXE_1_NAME} PRIVATE include)
set_target_properties(${EXE_1_NAME} PROPERTIES set_target_properties(${EXE_1_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${EXE_1_NAME}) RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${EXE_1_NAME})

View file

@ -1,13 +1,11 @@
#include <glad/glad.c> #include <glad/glad.c>
// glad must be loaded before GLFW // glad must be loaded before GLFW
#include "graphics.hpp" #include "graphics.hpp"
#include "main.hpp"
#include <iostream> #include <iostream>
using namespace std; using namespace std;
/* class ShaderProgram Implementations */
string ShaderProgram::baseName() { string ShaderProgram::baseName() {
switch (this->base) { switch (this->base) {
case Empty: case Empty:
@ -26,7 +24,6 @@ void framebuffer_size_callback(GLFWwindow *window, int width, int height) {
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
} }
/* extended main function */
int mainWindow(ShaderProgram* shaderProgram) { int mainWindow(ShaderProgram* shaderProgram) {
/* graphics stuff */ /* graphics stuff */
glfwInit(); glfwInit();

View file

@ -1,3 +1,4 @@
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
@ -32,16 +33,16 @@ int main(int argc, char **argv) {
return 1; return 1;
} }
} catch (po::error &e) { } catch (po::error &e) {
BOOST_LOG_TRIVIAL(fatal) << e.what() << endl << endl; cout << e.what() << endl << endl;
help(argv[0], desc); help(argv[0], desc);
return EXIT_USAGE; return EXIT_USAGE;
} }
/* setup the shader program */
if (vm.count("verbose")) { if (vm.count("verbose")) {
// TODO: make verbose flag somehow global? printf("verbose!");
printf("Reading shader files\n");
} }
/* setup the shader program */
ifstream vertexFileStream(vm["vert"].as<string>()); ifstream vertexFileStream(vm["vert"].as<string>());
ifstream fragFileStream(vm["frag"].as<string>()); ifstream fragFileStream(vm["frag"].as<string>());
std::stringstream vertexSource; std::stringstream vertexSource;
@ -50,28 +51,20 @@ int main(int argc, char **argv) {
fragSource << fragFileStream.rdbuf(); fragSource << fragFileStream.rdbuf();
if (vertexFileStream.fail()) { if (vertexFileStream.fail()) {
BOOST_LOG_TRIVIAL(fatal) << "Error while reading the vertex shader file." << endl; cout << "Error while reading the vertex shader file." << endl;
return EXIT_IO; return EXIT_IO;
} }
if (!fragFileStream.fail()) { if (fragFileStream.fail()) {
BOOST_LOG_TRIVIAL(fatal) << "Error while reading the frag shader file." << endl; cout << "Error while reading the frag shader file." << endl;
return EXIT_IO; return EXIT_IO;
} }
vertexFileStream.close(); vertexFileStream.close();
fragFileStream.close(); fragFileStream.close();
if (vm.count("verbose")) {
printf("Creating ShaderProgram\n");
}
// TODO: determinde ShaderProgram::Base with a CLI arg
ShaderProgram shaderProgram(ShaderProgram::Base::Empty, vertexSource.str(), ShaderProgram shaderProgram(ShaderProgram::Base::Empty, vertexSource.str(),
fragSource.str()); fragSource.str());
/* Run our main program */ /* Run our main program */
if (vm.count("verbose")) {
printf("Starting mainWindow\n");
}
int result = mainWindow(&shaderProgram); int result = mainWindow(&shaderProgram);
return result; return result;
@ -88,7 +81,6 @@ void help(char *prog, po::options_description desc) {
<< "1\tGeneric Failure" << "1\tGeneric Failure"
<< "2\tBad arguments" << "2\tBad arguments"
<< "3\tI/O Error" << endl << "3\tI/O Error" << endl
<< "3\tOpenGL Error" << endl
<< endl << endl
<< desc << endl; << desc << endl;
// NOTE: constants for the error codes are defined in main.hpp // NOTE: constants for the error codes are defined in main.hpp

View file

@ -1,17 +1,13 @@
#ifndef MAIN_HPP
#define MAIN_HPP
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
#include <boost/program_options/parsers.hpp> #include <boost/program_options/parsers.hpp>
#include <boost/program_options/positional_options.hpp> #include <boost/program_options/positional_options.hpp>
#include <boost/program_options/variables_map.hpp> #include <boost/program_options/variables_map.hpp>
#include <boost/log/trivial.hpp>
#include "graphics.hpp" #include "graphics.hpp"
// EXIT_FAILURE and EXIT_SUCCESS are defined in cstdlib // EXIT_FAILURE and EXIT_SUCCESS are defined in cstdlib
const int EXIT_USAGE = 2; const int EXIT_USAGE = 2;
const int EXIT_IO = 3; const int EXIT_IO = 3;
const int EXIT_GL = 4;
namespace po = boost::program_options; namespace po = boost::program_options;
using namespace std; using namespace std;
@ -19,4 +15,3 @@ using namespace std;
int main(int argc, char **argv); int main(int argc, char **argv);
void help(char *prog, po::options_description desc); void help(char *prog, po::options_description desc);
#endif