Browse Source

updating for msvc project, also updated imgui to v1.65

master
cinnaboot 8 years ago
parent
commit
fc3d7ce3ec
  1. 2
      ext/aixlog
  2. 2
      ext/imgui
  3. 31
      msvc/hexgame.vcxproj
  4. 49
      msvc/hexgame.vcxproj.filters
  5. 9
      msvc/hexgame.vcxproj.user
  6. 24
      src/build.bat
  7. 19
      src/gooey.cpp
  8. 4
      src/hexgame.cpp
  9. 2
      src/hexlib.cpp
  10. 1
      src/hexlib.h
  11. 2
      src/mesh.h
  12. 14
      src/render_group.cpp
  13. 6
      src/renderer.cpp
  14. 7
      src/util.cpp

2
ext/aixlog

@ -1 +1 @@
Subproject commit 2e5ee0188650a254f76f7e735ef986f117dee71f Subproject commit abca7539315c902e10c06bb363c19a0e1111bc78

2
ext/imgui

@ -1 +1 @@
Subproject commit 948009a8b2e98ef35fb8ddfe19299535a16c0834 Subproject commit 062b1f0463f6689f55e1599f5ea0f16a5edd99a9

31
msvc/hexgame.vcxproj

@ -100,34 +100,37 @@
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile> <ClCompile>
<AdditionalIncludeDirectories>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)</AdditionalIncludeDirectories> <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)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalLibraryDirectories>D:\dev\lib\SDL2-2.0.8\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>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)</AdditionalLibraryDirectories>
<AdditionalDependencies>SDL2.lib;Opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>SDL2.lib;SDL2_image.lib;Opengl32.lib;assimp-vc140-mt.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile> <ClCompile>
<AdditionalIncludeDirectories>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)</AdditionalIncludeDirectories> <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)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalLibraryDirectories>D:\dev\lib\SDL2-2.0.8\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>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)</AdditionalLibraryDirectories>
<AdditionalDependencies>SDL2.lib;Opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>SDL2.lib;SDL2_image.lib;Opengl32.lib;assimp-vc140-mt.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\ext\imgui\examples\libs\gl3w\GL\gl3w.c" /> <ClCompile Include="..\..\..\lib\gl3w\src\gl3w.c" />
<ClCompile Include="..\ext\imgui\examples\sdl_opengl3_example\imgui_impl_sdl_gl3.cpp" /> <ClCompile Include="..\ext\imgui\examples\imgui_impl_opengl3.cpp" />
<ClCompile Include="..\ext\imgui\examples\imgui_impl_sdl.cpp" />
<ClCompile Include="..\ext\imgui\imgui.cpp" /> <ClCompile Include="..\ext\imgui\imgui.cpp" />
<ClCompile Include="..\ext\imgui\imgui_demo.cpp" />
<ClCompile Include="..\ext\imgui\imgui_draw.cpp" /> <ClCompile Include="..\ext\imgui\imgui_draw.cpp" />
<ClCompile Include="..\ext\imgui\imgui_widgets.cpp" />
<ClCompile Include="..\src\gooey.cpp" />
<ClCompile Include="..\src\hexgame.cpp" /> <ClCompile Include="..\src\hexgame.cpp" />
</ItemGroup> <ClCompile Include="..\src\hexlib.cpp" />
<ItemGroup> <ClCompile Include="..\src\mesh.cpp" />
<ClInclude Include="..\src\gooey.h" /> <ClCompile Include="..\src\renderer.cpp" />
<ClInclude Include="..\src\hexgame.h" /> <ClCompile Include="..\src\render_group.cpp" />
<ClInclude Include="..\src\hexlib.h" /> <ClCompile Include="..\src\util.cpp" />
<ClInclude Include="..\src\renderer.h" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

49
msvc/hexgame.vcxproj.filters

@ -18,31 +18,44 @@
<ClCompile Include="..\src\hexgame.cpp"> <ClCompile Include="..\src\hexgame.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\ext\imgui\examples\libs\gl3w\GL\gl3w.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ext\imgui\imgui.cpp"> <ClCompile Include="..\ext\imgui\imgui.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\ext\imgui\imgui_draw.cpp"> <ClCompile Include="..\ext\imgui\imgui_draw.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\ext\imgui\examples\sdl_opengl3_example\imgui_impl_sdl_gl3.cpp"> <ClCompile Include="..\src\gooey.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\hexlib.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\mesh.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\render_group.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\renderer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\util.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ext\imgui\examples\imgui_impl_opengl3.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ext\imgui\examples\imgui_impl_sdl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ext\imgui\imgui_demo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ext\imgui\imgui_widgets.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\lib\gl3w\src\gl3w.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\gooey.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\hexgame.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\hexlib.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\renderer.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>

9
msvc/hexgame.vcxproj.user

@ -1,4 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerWorkingDirectory>.</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerWorkingDirectory>.</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project> </Project>

24
src/build.bat

@ -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

19
src/gooey.cpp

@ -6,7 +6,8 @@
#endif #endif
#include "imgui.h" #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 "util.h"
#include "gooey.h" #include "gooey.h"
@ -18,7 +19,10 @@ initGooey(SDL_Handles &handles, v2i vp_dims /*TODO: pass in game state*/)
ImGui::CreateContext(); ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
io.IniFilename = NULL; // don't save window state to imgui.ini 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.x = vp_dims.x;
io.DisplaySize.y = vp_dims.y; io.DisplaySize.y = vp_dims.y;
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
@ -29,14 +33,15 @@ initGooey(SDL_Handles &handles, v2i vp_dims /*TODO: pass in game state*/)
void void
shutdownGooey() shutdownGooey()
{ {
ImGui_ImplSdlGL3_Shutdown(); ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplSDL2_Shutdown();
ImGui::DestroyContext(); ImGui::DestroyContext();
} }
bool bool
gooeyProcessEvent(SDL_Event &event) gooeyProcessEvent(SDL_Event &event)
{ {
ImGui_ImplSdlGL3_ProcessEvent(&event); ImGui_ImplSDL2_ProcessEvent(&event);
return ImGui::GetIO().WantCaptureMouse; return ImGui::GetIO().WantCaptureMouse;
} }
@ -44,7 +49,9 @@ void
renderGooey(SDL_Handles &handles, HexDrawMode &mode, bool &is_debug, renderGooey(SDL_Handles &handles, HexDrawMode &mode, bool &is_debug,
hex_info* start_hex, hex_info* current_hex, bool &is_selecting, v3f camera_pos) 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; ImGuiWindowFlags window_flags = 0;
window_flags |= ImGuiWindowFlags_NoTitleBar; window_flags |= ImGuiWindowFlags_NoTitleBar;
@ -103,7 +110,7 @@ renderGooey(SDL_Handles &handles, HexDrawMode &mode, bool &is_debug,
ImGui::End(); ImGui::End();
ImGui::Render(); ImGui::Render();
ImGui_ImplSdlGL3_RenderDrawData(ImGui::GetDrawData()); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
} }

4
src/hexgame.cpp

@ -477,7 +477,11 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
int main(int argc, char* argv[]) int main(int argc, char* argv[])
#endif #endif
{ {
#if defined(_WIN32)
AixLog::Log::init<AixLog::SinkOutputDebugString>(AixLog::Severity::trace, AixLog::Type::normal);
#else
AixLog::Log::init<AixLog::SinkCout>(AixLog::Severity::trace, AixLog::Type::normal); AixLog::Log::init<AixLog::SinkCout>(AixLog::Severity::trace, AixLog::Type::normal);
#endif
LOG(INFO) << "Application started\n"; LOG(INFO) << "Application started\n";
// init global game state // init global game state

2
src/hexlib.cpp

@ -3,9 +3,7 @@
// Generated code -- http://www.redblobgames.com/grids/hexagons/ // Generated code -- http://www.redblobgames.com/grids/hexagons/
#include <cmath>
#include <cstdlib> #include <cstdlib>
#include <vector>
#include <algorithm> #include <algorithm>
#include <iterator> #include <iterator>
using std::abs; using std::abs;

1
src/hexlib.h

@ -3,6 +3,7 @@
// Generated code -- http://www.redblobgames.com/grids/hexagons/ // Generated code -- http://www.redblobgames.com/grids/hexagons/
#define _USE_MATH_DEFINES
#include <cmath> #include <cmath>
#include <vector> #include <vector>
using std::vector; using std::vector;

2
src/mesh.h

@ -7,6 +7,8 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include "util.h"
struct meMeshInfo struct meMeshInfo
{ {
glm::mat4 model_transform; glm::mat4 model_transform;

14
src/render_group.cpp

@ -14,6 +14,8 @@
#include "render_group.h" #include "render_group.h"
#include "mesh.h" #include "mesh.h"
#define INFO_LOG_MAX_LENGTH 312;
bool bool
rgInitShaderProgram(gl_render_group* rg, const char * vertex_code, const char * frag_code) 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(vertex_shader_id);
glDeleteShader(fragment_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; GLint isLinked = 0;
glGetProgramiv(rg->program_id, GL_LINK_STATUS, &isLinked); glGetProgramiv(rg->program_id, GL_LINK_STATUS, &isLinked);
if (isLinked == GL_FALSE) { if (isLinked == GL_FALSE) {
GLint maxLength = 0; GLint maxLength = INFO_LOG_MAX_LENGTH;
glGetProgramiv(rg->program_id, GL_INFO_LOG_LENGTH, &maxLength); 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]); glGetProgramInfoLog(rg->program_id, maxLength, &maxLength, &infoLog[0]);
LOG(ERROR) << infoLog << "\n"; LOG(ERROR) << infoLog << "\n";
glDeleteProgram(rg->program_id); glDeleteProgram(rg->program_id);
return false; return false;
} }
#endif
return true; return true;
} }

6
src/renderer.cpp

@ -236,7 +236,11 @@ initRenderer(SDL_Handles &handles, v2i vpDims)
} }
handles.glContext = SDL_GL_CreateContext(handles.window); 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 vendor: " << glGetString(GL_VENDOR) << "\n";
LOG(INFO)<< "opengl renderer: " << glGetString(GL_RENDERER) << "\n"; LOG(INFO)<< "opengl renderer: " << glGetString(GL_RENDERER) << "\n";

7
src/util.cpp

@ -2,7 +2,7 @@
#include <cstdlib> #include <cstdlib>
#include <cstdio> #include <cstdio>
//#include "aixlog.hpp" #include "aixlog.hpp"
#include "util.h" #include "util.h"
@ -11,9 +11,8 @@ const uint MAX_FILESIZE = 2 * 1024 * 1024; // 2MB
char * char *
utilDumpTextFile(const char* filename) utilDumpTextFile(const char* filename)
{ {
// log('info: loading filename, blablabla); LOG(INFO) << "loading filename, " << filename << "\n";
// TODO: log errors std::FILE* fp = std::fopen(filename, "rt");
std::FILE* fp = std::fopen(filename, "rb");
assert(fp); assert(fp);
std::fseek(fp, 0, SEEK_END); std::fseek(fp, 0, SEEK_END);

Loading…
Cancel
Save