diff --git a/lib/camera.hpp b/lib/camera.hpp index 89f4d1a..8985fcf 100644 --- a/lib/camera.hpp +++ b/lib/camera.hpp @@ -299,8 +299,13 @@ class CameraController } }; +#if _WIN32 +__declspec(selectany) double CameraController::sxoffset = 0; +__declspec(selectany) double CameraController::syoffset = 0; +#else double CameraController::sxoffset = 0; double CameraController::syoffset = 0; +#endif } // namespace mylib diff --git a/lib/mylib.hpp b/lib/mylib.hpp index 6f48f54..a17748d 100644 --- a/lib/mylib.hpp +++ b/lib/mylib.hpp @@ -32,12 +32,17 @@ #include "./shader.hpp" +#define ML_BUFFER_OFFSET(idx) \ + static_cast(static_cast(0) + (idx)) namespace mylib { -#define ML_BUFFER_OFFSET(idx) \ - static_cast(static_cast(0) + (idx)) +inline const GLvoid* BUFFER_OFFSET(const std::size_t& idx) +{ + return + static_cast(static_cast(0) + (idx)); +} class Window { @@ -180,70 +185,6 @@ class App }; -GLuint compileShader(const char *filepath, const GLenum &SHADER_TYPE) -{ - GLuint shader = glCreateShader(SHADER_TYPE); - std::ifstream fs(filepath); - std::stringstream srcs; - std::string src; - - if (fs.is_open()) { - std::string tmp; - while (fs) { - std::getline(fs, tmp); - src += tmp + "\n"; - tmp.clear(); - } - } - else { - throw std::runtime_error("mylib::compileShader(): can't open shaderSrc file"); - } -#ifndef _NDEBUG - std::clog << "mylib::compileShader(): src: \n" << src << std::endl; -#endif - const GLchar* srcptr = src.c_str(); - glShaderSource(shader, 1, &srcptr, NULL); - glCompileShader(shader); - - GLint success; - GLchar infoLog[512]; - glGetShaderiv(shader, GL_COMPILE_STATUS, &success); - if (!success) { - glGetShaderInfoLog(shader, 512, NULL, infoLog); - std::cerr << "ERROR Compiling shader src: \n" << infoLog << std::endl; - throw std::runtime_error( - "mylib::compileShader(): glCompileShader error" - ); - } - - return shader; -} - -GLuint linkShaderProgram(std::vector shaders) -{ - GLuint program = glCreateProgram(); - for (const GLuint& shader: shaders) { - glAttachShader(program, shader); - } - glLinkProgram(program); - - GLint success; - GLchar infoLog[512]; - glGetShaderiv(program, GL_COMPILE_STATUS, &success); - if (!success) { - glGetShaderInfoLog(program, 512, NULL, infoLog); - std::cerr << "ERROR Compiling shader src: \n" << infoLog << std::endl; - throw std::runtime_error( - "mylib::compileShader(): glCompileShader error" - ); - } - - for (const auto& shader: shaders) { - glDeleteShader(shader); - } - return program; -} - }; #endif \ No newline at end of file diff --git a/super/main.cpp b/super/main.cpp new file mode 100644 index 0000000..e381473 --- /dev/null +++ b/super/main.cpp @@ -0,0 +1,64 @@ +#ifdef _DEBUG +#undef _NDEBUG +#undef NDEBUG +#else +#define _NDEBUG +#define NDEBUG +#endif + +#include "stdafx.h" + +#include "../lib/mylib.hpp" +#include "../lib/camera.hpp" + +#include +#ifdef _WIN32 +#include +#else +#include +#endif + +#include + +#define GLM_ENABLE_EXPERIMENTAL +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + try + { + mylib::Window window; + + start: + std::cout << "(1) MultiLightApp \n" + << std::endl; + unsigned int option{ 0 }; + std::cin >> option; + + switch (option) + { + default: + std::cout << "select any one of the option please." << std::endl; + goto start; + break; + } + } + catch (const std::exception& e) + { + throw e; + } + + std::cin.clear(); + std::cin.ignore(std::numeric_limits::max(), '\n'); + std::cin.get(); + std::exit(EXIT_SUCCESS); +}