diff --git a/ext/aixlog b/ext/aixlog index 2e5ee01..abca753 160000 --- a/ext/aixlog +++ b/ext/aixlog @@ -1 +1 @@ -Subproject commit 2e5ee0188650a254f76f7e735ef986f117dee71f +Subproject commit abca7539315c902e10c06bb363c19a0e1111bc78 diff --git a/ext/imgui b/ext/imgui index 948009a..062b1f0 160000 --- a/ext/imgui +++ b/ext/imgui @@ -1 +1 @@ -Subproject commit 948009a8b2e98ef35fb8ddfe19299535a16c0834 +Subproject commit 062b1f0463f6689f55e1599f5ea0f16a5edd99a9 diff --git a/msvc/hexgame.vcxproj b/msvc/hexgame.vcxproj index 23e1857..48da8a3 100644 --- a/msvc/hexgame.vcxproj +++ b/msvc/hexgame.vcxproj @@ -100,34 +100,37 @@ - D:\dev\lib\glm;D:\dev\projects\hexgame\ext\imgui\examples\libs\gl3w;D:\dev\projects\hexgame\ext\imgui;D:\dev\projects\hexgame\ext\aixlog\include;D:\dev\lib\SDL2-2.0.8\include;%(AdditionalIncludeDirectories) + D:\dev\lib\glm;D:\dev\lib\gl3w\include;D:\dev\projects\hexgame\ext\imgui;D:\dev\projects\hexgame\ext\aixlog\include;D:\dev\lib\SDL2-2.0.8\include;D:\dev\lib\SDL2_image-2.0.3\include;D:\dev\lib\Assimp\include;%(AdditionalIncludeDirectories) - D:\dev\lib\SDL2-2.0.8\lib\x64;%(AdditionalLibraryDirectories) - SDL2.lib;Opengl32.lib;%(AdditionalDependencies) + D:\dev\lib\Assimp\lib\x64;D:\dev\lib\SDL2_image-2.0.3\lib\x64;D:\dev\lib\SDL2-2.0.8\lib\x64;%(AdditionalLibraryDirectories) + SDL2.lib;SDL2_image.lib;Opengl32.lib;assimp-vc140-mt.lib;%(AdditionalDependencies) - D:\dev\lib\glm;D:\dev\projects\hexgame\ext\imgui\examples\libs\gl3w;D:\dev\projects\hexgame\ext\imgui;D:\dev\projects\hexgame\ext\aixlog\include;D:\dev\lib\SDL2-2.0.8\include;%(AdditionalIncludeDirectories) + D:\dev\lib\glm;D:\dev\lib\gl3w\include;D:\dev\projects\hexgame\ext\imgui;D:\dev\projects\hexgame\ext\aixlog\include;D:\dev\lib\SDL2-2.0.8\include;D:\dev\lib\SDL2_image-2.0.3\include;D:\dev\lib\Assimp\include;%(AdditionalIncludeDirectories) - D:\dev\lib\SDL2-2.0.8\lib\x64;%(AdditionalLibraryDirectories) - SDL2.lib;Opengl32.lib;%(AdditionalDependencies) + D:\dev\lib\Assimp\lib\x64;D:\dev\lib\SDL2_image-2.0.3\lib\x64;D:\dev\lib\SDL2-2.0.8\lib\x64;%(AdditionalLibraryDirectories) + SDL2.lib;SDL2_image.lib;Opengl32.lib;assimp-vc140-mt.lib;%(AdditionalDependencies) - - + + + + + + - - - - - - + + + + + diff --git a/msvc/hexgame.vcxproj.filters b/msvc/hexgame.vcxproj.filters index 4c78506..0420bc9 100644 --- a/msvc/hexgame.vcxproj.filters +++ b/msvc/hexgame.vcxproj.filters @@ -18,31 +18,44 @@ Source Files - - Source Files - Source Files Source Files - + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + Source Files - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - \ No newline at end of file diff --git a/msvc/hexgame.vcxproj.user b/msvc/hexgame.vcxproj.user index be25078..f539350 100644 --- a/msvc/hexgame.vcxproj.user +++ b/msvc/hexgame.vcxproj.user @@ -1,4 +1,11 @@  - + + . + WindowsLocalDebugger + + + . + WindowsLocalDebugger + \ No newline at end of file diff --git a/src/build.bat b/src/build.bat deleted file mode 100644 index fd4f28d..0000000 --- a/src/build.bat +++ /dev/null @@ -1,24 +0,0 @@ -@echo off - -cls - -IF "%VisualStudioVersion%" == "" call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 - -SETLOCAL -SET CFLAGS=%CFLAGS% -MT -nologo -Gm- -Oi -WX -W4 -wd4100 -wd4189 -Zi /EHsc -SET INCLUDES=%INCLUDES% /I ..\SDL2\include -SET INCLUDES=%INCLUDES% /I ..\glew\include -SET INCLUDES=%INCLUDES% /I ..\freetype\include -SET _LIBPATH=%_LIBPATH% /LIBPATH:..\SDL2\lib -SET _LIBPATH=%_LIBPATH% /LIBPATH:..\glew\lib -REM SET _LIBPATH=%_LIBPATH% /LIBPATH:..\freetype\lib -REM SET LIBS=%LIBS% SDL2.lib glew32sd.lib opengl32.lib User32.lib libfreetype.dll.a -SET LIBS=%LIBS% SDL2.lib glew32sd.lib opengl32.lib User32.lib - -IF NOT EXIST ..\build mkdir ..\build -pushd ..\build -cl %CFLAGS% %INCLUDES% ..\src\hexgame.cpp %LIBS% /link %_LIBPATH% -popd - -ENDLOCAL - diff --git a/src/gooey.cpp b/src/gooey.cpp index debe46c..3fb719d 100644 --- a/src/gooey.cpp +++ b/src/gooey.cpp @@ -6,7 +6,8 @@ #endif #include "imgui.h" -#include "examples/sdl_opengl3_example/imgui_impl_sdl_gl3.h" +#include "examples/imgui_impl_sdl.h" +#include "examples/imgui_impl_opengl3.h" #include "util.h" #include "gooey.h" @@ -18,7 +19,10 @@ initGooey(SDL_Handles &handles, v2i vp_dims /*TODO: pass in game state*/) ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); io.IniFilename = NULL; // don't save window state to imgui.ini - ImGui_ImplSdlGL3_Init(handles.window); + + ImGui_ImplSDL2_InitForOpenGL(handles.window, handles.glContext); + ImGui_ImplOpenGL3_Init("#version 330 core"); + io.DisplaySize.x = vp_dims.x; io.DisplaySize.y = vp_dims.y; ImGui::StyleColorsDark(); @@ -29,14 +33,15 @@ initGooey(SDL_Handles &handles, v2i vp_dims /*TODO: pass in game state*/) void shutdownGooey() { - ImGui_ImplSdlGL3_Shutdown(); + ImGui_ImplOpenGL3_Shutdown(); + ImGui_ImplSDL2_Shutdown(); ImGui::DestroyContext(); } bool gooeyProcessEvent(SDL_Event &event) { - ImGui_ImplSdlGL3_ProcessEvent(&event); + ImGui_ImplSDL2_ProcessEvent(&event); return ImGui::GetIO().WantCaptureMouse; } @@ -44,7 +49,9 @@ void renderGooey(SDL_Handles &handles, HexDrawMode &mode, bool &is_debug, hex_info* start_hex, hex_info* current_hex, bool &is_selecting, v3f camera_pos) { - ImGui_ImplSdlGL3_NewFrame(handles.window); + ImGui_ImplOpenGL3_NewFrame(); + ImGui_ImplSDL2_NewFrame(handles.window); + ImGui::NewFrame(); ImGuiWindowFlags window_flags = 0; window_flags |= ImGuiWindowFlags_NoTitleBar; @@ -103,7 +110,7 @@ renderGooey(SDL_Handles &handles, HexDrawMode &mode, bool &is_debug, ImGui::End(); ImGui::Render(); - ImGui_ImplSdlGL3_RenderDrawData(ImGui::GetDrawData()); + ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); } diff --git a/src/hexgame.cpp b/src/hexgame.cpp index 6cb546f..2366c93 100644 --- a/src/hexgame.cpp +++ b/src/hexgame.cpp @@ -477,7 +477,11 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, int main(int argc, char* argv[]) #endif { +#if defined(_WIN32) + AixLog::Log::init(AixLog::Severity::trace, AixLog::Type::normal); +#else AixLog::Log::init(AixLog::Severity::trace, AixLog::Type::normal); +#endif LOG(INFO) << "Application started\n"; // init global game state diff --git a/src/hexlib.cpp b/src/hexlib.cpp index a2be6b8..1ae59e2 100644 --- a/src/hexlib.cpp +++ b/src/hexlib.cpp @@ -3,9 +3,7 @@ // Generated code -- http://www.redblobgames.com/grids/hexagons/ -#include #include -#include #include #include using std::abs; diff --git a/src/hexlib.h b/src/hexlib.h index 343bb58..4df7fe3 100644 --- a/src/hexlib.h +++ b/src/hexlib.h @@ -3,6 +3,7 @@ // Generated code -- http://www.redblobgames.com/grids/hexagons/ +#define _USE_MATH_DEFINES #include #include using std::vector; diff --git a/src/mesh.h b/src/mesh.h index ab0a629..d572412 100644 --- a/src/mesh.h +++ b/src/mesh.h @@ -7,6 +7,8 @@ #include +#include "util.h" + struct meMeshInfo { glm::mat4 model_transform; diff --git a/src/render_group.cpp b/src/render_group.cpp index a456be6..3904369 100644 --- a/src/render_group.cpp +++ b/src/render_group.cpp @@ -14,6 +14,8 @@ #include "render_group.h" #include "mesh.h" +#define INFO_LOG_MAX_LENGTH 312; + bool rgInitShaderProgram(gl_render_group* rg, const char * vertex_code, const char * frag_code) { @@ -42,18 +44,26 @@ rgInitShaderProgram(gl_render_group* rg, const char * vertex_code, const char * glDeleteShader(vertex_shader_id); glDeleteShader(fragment_shader_id); + // TODO: quick hack to allow 'dynamic' stack allocation for msvc + // also remove INFO_LOG_MAX_LENGTH define +#if 1 GLint isLinked = 0; glGetProgramiv(rg->program_id, GL_LINK_STATUS, &isLinked); if (isLinked == GL_FALSE) { - GLint maxLength = 0; + GLint maxLength = INFO_LOG_MAX_LENGTH; glGetProgramiv(rg->program_id, GL_INFO_LOG_LENGTH, &maxLength); - GLchar infoLog[maxLength]; +#ifdef _WIN32 + GLchar infoLog[312] = { 0 }; +#else + GLchar infoLog[maxLength] = { 0 }; +#endif glGetProgramInfoLog(rg->program_id, maxLength, &maxLength, &infoLog[0]); LOG(ERROR) << infoLog << "\n"; glDeleteProgram(rg->program_id); return false; } +#endif return true; } diff --git a/src/renderer.cpp b/src/renderer.cpp index 0519119..6a0a892 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -236,7 +236,11 @@ initRenderer(SDL_Handles &handles, v2i vpDims) } handles.glContext = SDL_GL_CreateContext(handles.window); - gl3wInit(); // TODO: decide on extension library + + if (gl3wInit()) { // TODO: decide on extension library + LOG(ERROR) << "failed to initialize OpenGL\n"; + return false; + } LOG(INFO) << "opengl vendor: " << glGetString(GL_VENDOR) << "\n"; LOG(INFO)<< "opengl renderer: " << glGetString(GL_RENDERER) << "\n"; diff --git a/src/util.cpp b/src/util.cpp index 272c4e2..eebd4cd 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -2,7 +2,7 @@ #include #include -//#include "aixlog.hpp" +#include "aixlog.hpp" #include "util.h" @@ -11,9 +11,8 @@ const uint MAX_FILESIZE = 2 * 1024 * 1024; // 2MB char * utilDumpTextFile(const char* filename) { - // log('info: loading filename, blablabla); - // TODO: log errors - std::FILE* fp = std::fopen(filename, "rb"); + LOG(INFO) << "loading filename, " << filename << "\n"; + std::FILE* fp = std::fopen(filename, "rt"); assert(fp); std::fseek(fp, 0, SEEK_END);