Compare commits
1 commit
613a917d36
...
2c736089be
Author | SHA1 | Date | |
---|---|---|---|
2c736089be |
5 changed files with 10 additions and 27 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,4 +5,3 @@ CMakeDoxygenDefaults.cmake
|
|||
Makefile
|
||||
cmake_install.cmake
|
||||
bin/loader/loader
|
||||
lib/glfw
|
||||
|
|
|
@ -30,7 +30,7 @@ source_group("sources" FILES ${PROJECT_SOURCES})
|
|||
source_group("vendors" FILES ${VENDORS_SOURCES})
|
||||
|
||||
find_package(Boost 1.56 REQUIRED COMPONENTS
|
||||
program_options log)
|
||||
program_options)
|
||||
|
||||
set(EXE_1_NAME loader)
|
||||
file(
|
||||
|
@ -41,7 +41,7 @@ set(CMAKE_BINARY_DIR "bin")
|
|||
|
||||
add_executable(${EXE_1_NAME} ${EXE_1_SOURCES} ${PROJECT_HEADERS}
|
||||
${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)
|
||||
set_target_properties(${EXE_1_NAME} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${EXE_1_NAME})
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
#include <glad/glad.c>
|
||||
// glad must be loaded before GLFW
|
||||
#include "graphics.hpp"
|
||||
#include "main.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* class ShaderProgram Implementations */
|
||||
string ShaderProgram::baseName() {
|
||||
switch (this->base) {
|
||||
case Empty:
|
||||
|
@ -26,7 +24,6 @@ void framebuffer_size_callback(GLFWwindow *window, int width, int height) {
|
|||
glViewport(0, 0, width, height);
|
||||
}
|
||||
|
||||
/* extended main function */
|
||||
int mainWindow(ShaderProgram* shaderProgram) {
|
||||
/* graphics stuff */
|
||||
glfwInit();
|
||||
|
|
24
src/main.cpp
24
src/main.cpp
|
@ -1,3 +1,4 @@
|
|||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
|
@ -32,16 +33,16 @@ int main(int argc, char **argv) {
|
|||
return 1;
|
||||
}
|
||||
} catch (po::error &e) {
|
||||
BOOST_LOG_TRIVIAL(fatal) << e.what() << endl << endl;
|
||||
cout << e.what() << endl << endl;
|
||||
help(argv[0], desc);
|
||||
return EXIT_USAGE;
|
||||
}
|
||||
|
||||
/* setup the shader program */
|
||||
if (vm.count("verbose")) {
|
||||
// TODO: make verbose flag somehow global?
|
||||
printf("Reading shader files\n");
|
||||
printf("verbose!");
|
||||
}
|
||||
|
||||
/* setup the shader program */
|
||||
ifstream vertexFileStream(vm["vert"].as<string>());
|
||||
ifstream fragFileStream(vm["frag"].as<string>());
|
||||
std::stringstream vertexSource;
|
||||
|
@ -50,28 +51,20 @@ int main(int argc, char **argv) {
|
|||
fragSource << fragFileStream.rdbuf();
|
||||
|
||||
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;
|
||||
}
|
||||
if (!fragFileStream.fail()) {
|
||||
BOOST_LOG_TRIVIAL(fatal) << "Error while reading the frag shader file." << endl;
|
||||
if (fragFileStream.fail()) {
|
||||
cout << "Error while reading the frag shader file." << endl;
|
||||
return EXIT_IO;
|
||||
}
|
||||
vertexFileStream.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(),
|
||||
fragSource.str());
|
||||
|
||||
/* Run our main program */
|
||||
if (vm.count("verbose")) {
|
||||
printf("Starting mainWindow\n");
|
||||
}
|
||||
int result = mainWindow(&shaderProgram);
|
||||
|
||||
return result;
|
||||
|
@ -88,7 +81,6 @@ void help(char *prog, po::options_description desc) {
|
|||
<< "1\tGeneric Failure"
|
||||
<< "2\tBad arguments"
|
||||
<< "3\tI/O Error" << endl
|
||||
<< "3\tOpenGL Error" << endl
|
||||
<< endl
|
||||
<< desc << endl;
|
||||
// NOTE: constants for the error codes are defined in main.hpp
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
#ifndef MAIN_HPP
|
||||
#define MAIN_HPP
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/program_options/parsers.hpp>
|
||||
#include <boost/program_options/positional_options.hpp>
|
||||
#include <boost/program_options/variables_map.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
#include "graphics.hpp"
|
||||
|
||||
// EXIT_FAILURE and EXIT_SUCCESS are defined in cstdlib
|
||||
const int EXIT_USAGE = 2;
|
||||
const int EXIT_IO = 3;
|
||||
const int EXIT_GL = 4;
|
||||
|
||||
namespace po = boost::program_options;
|
||||
using namespace std;
|
||||
|
@ -19,4 +15,3 @@ using namespace std;
|
|||
int main(int argc, char **argv);
|
||||
|
||||
void help(char *prog, po::options_description desc);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue