Compare commits
2 commits
2c736089be
...
613a917d36
Author | SHA1 | Date | |
---|---|---|---|
613a917d36 | |||
001d795b73 |
5 changed files with 28 additions and 11 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,3 +5,4 @@ CMakeDoxygenDefaults.cmake
|
||||||
Makefile
|
Makefile
|
||||||
cmake_install.cmake
|
cmake_install.cmake
|
||||||
bin/loader/loader
|
bin/loader/loader
|
||||||
|
lib/glfw
|
||||||
|
|
|
@ -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)
|
program_options log)
|
||||||
|
|
||||||
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)
|
target_link_libraries(${EXE_1_NAME} glfw Boost::program_options Boost::log)
|
||||||
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})
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
#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:
|
||||||
|
@ -24,6 +26,7 @@ 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();
|
||||||
|
|
26
src/main.cpp
26
src/main.cpp
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
@ -33,16 +32,16 @@ int main(int argc, char **argv) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} catch (po::error &e) {
|
} catch (po::error &e) {
|
||||||
cout << e.what() << endl << endl;
|
BOOST_LOG_TRIVIAL(fatal) << e.what() << endl << endl;
|
||||||
help(argv[0], desc);
|
help(argv[0], desc);
|
||||||
return EXIT_USAGE;
|
return EXIT_USAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm.count("verbose")) {
|
|
||||||
printf("verbose!");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* setup the shader program */
|
/* setup the shader program */
|
||||||
|
if (vm.count("verbose")) {
|
||||||
|
// TODO: make verbose flag somehow global?
|
||||||
|
printf("Reading shader files\n");
|
||||||
|
}
|
||||||
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;
|
||||||
|
@ -51,20 +50,28 @@ int main(int argc, char **argv) {
|
||||||
fragSource << fragFileStream.rdbuf();
|
fragSource << fragFileStream.rdbuf();
|
||||||
|
|
||||||
if (vertexFileStream.fail()) {
|
if (vertexFileStream.fail()) {
|
||||||
cout << "Error while reading the vertex shader file." << endl;
|
BOOST_LOG_TRIVIAL(fatal) << "Error while reading the vertex shader file." << endl;
|
||||||
return EXIT_IO;
|
return EXIT_IO;
|
||||||
}
|
}
|
||||||
if (fragFileStream.fail()) {
|
if (!fragFileStream.fail()) {
|
||||||
cout << "Error while reading the frag shader file." << endl;
|
BOOST_LOG_TRIVIAL(fatal) << "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;
|
||||||
|
@ -81,6 +88,7 @@ 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
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
|
#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;
|
||||||
|
@ -15,3 +19,4 @@ 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
|
||||||
|
|
Loading…
Add table
Reference in a new issue