Browse Source

fix compiling on windows w/ msvc

modified:   .gitignore
	new file:   msvc/hexgame.sln
	new file:   msvc/hexgame.vcxproj
	new file:   msvc/hexgame.vcxproj.filters
	new file:   msvc/hexgame.vcxproj.user
	new file:   msvc/imgui.ini
	modified:   src/gooey.h
	modified:   src/hexgame.cpp
	modified:   src/hexgame.h
	modified:   src/renderer.h
master
cinnaboot 8 years ago
parent
commit
1678100bff
  1. 2
      .gitignore
  2. 31
      msvc/hexgame.sln
  3. 135
      msvc/hexgame.vcxproj
  4. 48
      msvc/hexgame.vcxproj.filters
  5. 4
      msvc/hexgame.vcxproj.user
  6. 5
      msvc/imgui.ini
  7. 2
      src/gooey.h
  8. 4
      src/hexgame.cpp
  9. 2
      src/hexgame.h
  10. 30
      src/renderer.h

2
.gitignore vendored

@ -2,4 +2,6 @@ bin/
build/
src/tags
*.swp
msvc/.vs/
msvc/x64/

31
msvc/hexgame.sln

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2011
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hexgame", "hexgame.vcxproj", "{A20061AD-7985-4275-96C6-A25215941A26}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A20061AD-7985-4275-96C6-A25215941A26}.Debug|x64.ActiveCfg = Debug|x64
{A20061AD-7985-4275-96C6-A25215941A26}.Debug|x64.Build.0 = Debug|x64
{A20061AD-7985-4275-96C6-A25215941A26}.Debug|x86.ActiveCfg = Debug|x64
{A20061AD-7985-4275-96C6-A25215941A26}.Debug|x86.Build.0 = Debug|x64
{A20061AD-7985-4275-96C6-A25215941A26}.Release|x64.ActiveCfg = Release|x64
{A20061AD-7985-4275-96C6-A25215941A26}.Release|x64.Build.0 = Release|x64
{A20061AD-7985-4275-96C6-A25215941A26}.Release|x86.ActiveCfg = Release|Win32
{A20061AD-7985-4275-96C6-A25215941A26}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AD869B47-2A3C-42CD-9CD1-70B5B8106A66}
EndGlobalSection
EndGlobal

135
msvc/hexgame.vcxproj

@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{A20061AD-7985-4275-96C6-A25215941A26}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<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>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>D:\dev\lib\SDL2-2.0.8\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>SDL2.lib;Opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<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>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>D:\dev\lib\SDL2-2.0.8\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>SDL2.lib;Opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\ext\imgui\examples\libs\gl3w\GL\gl3w.c" />
<ClCompile Include="..\ext\imgui\examples\sdl_opengl3_example\imgui_impl_sdl_gl3.cpp" />
<ClCompile Include="..\ext\imgui\imgui.cpp" />
<ClCompile Include="..\ext\imgui\imgui_draw.cpp" />
<ClCompile Include="..\src\hexgame.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\gooey.h" />
<ClInclude Include="..\src\hexgame.h" />
<ClInclude Include="..\src\hexlib.h" />
<ClInclude Include="..\src\renderer.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

48
msvc/hexgame.vcxproj.filters

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\hexgame.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ext\imgui\examples\libs\gl3w\GL\gl3w.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ext\imgui\imgui.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ext\imgui\imgui_draw.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ext\imgui\examples\sdl_opengl3_example\imgui_impl_sdl_gl3.cpp">
<Filter>Source Files</Filter>
</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>
</Project>

4
msvc/hexgame.vcxproj.user

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

5
msvc/imgui.ini

@ -0,0 +1,5 @@
[Window][Debug##Default]
Pos=13,4
Size=370,374
Collapsed=0

2
src/gooey.h

@ -3,7 +3,7 @@
#define GOOEY_H
#include <SDL2/SDL.h>
#include <SDL.h>
#include "imgui.h"
#include "examples/sdl_opengl3_example/imgui_impl_sdl_gl3.h"

4
src/hexgame.cpp

@ -18,7 +18,7 @@
#include <Winuser.h>
#endif
#include <SDL2/SDL.h>
#include <SDL.h>
#include "hexgame.h"
#include "hexlib.h"
@ -168,7 +168,7 @@ updateHexLineDraw(int32 x, int32 y)
for (hex_info &h1 : *g_game_state->hex_array)
{
for (uint i = 0; i < hexLine.size(); i++)
for (uint32 i = 0; i < hexLine.size(); i++)
{
Hex h2 = hexLine[i];
if (hex_equal(h1.hex, h2))

2
src/hexgame.h

@ -5,7 +5,7 @@
#include <vector>
#include <cassert>
#include <SDL2/SDL.h>
#include <SDL.h>
#include "aixlog.hpp"
#include "hexlib.h"

30
src/renderer.h

@ -10,7 +10,7 @@
//#include <GL/glew.h>
#include <GL/gl3w.h>
#include <SDL2/SDL.h>
#include <SDL.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
@ -235,16 +235,28 @@ createScene(std::vector<hex_info>* hexes)
int hex_count = (int) hexes->size();
// 6 triangles * 3 vertices per triangle * 3 floats per vertex = 54
int vbuf_len = hex_count * 6 * 3 * 3;
GLfloat vbuf[vbuf_len];
// TODO: surely there's a way to use indexed drawing for line vertices eg) line_loop
// and still use one buffer for multiple shapes/paths gldrawarraysintanced?, gldrawelements?
// https://gamedev.stackexchange.com/questions/104310/opengl-4-5-primitive-restart-vs-base-index
int line_vertices_per_hex = 6 * 2; // 12 vertices since we're using line segments atm
//gl_buffer *line_vertex_buffer = &g_hex_line_render_group.vertex_buffer;
int line_buf_len = hexes->size() * line_vertices_per_hex * 3; // 3 floats per vertex
// temporary buffers
GLfloat* vbuf = (GLfloat*) std::calloc(vbuf_len, sizeof(GLfloat));
GLfloat* cbuf = (GLfloat*) std::calloc(vbuf_len, sizeof(GLfloat));
GLfloat* line_buf = (GLfloat*) std::calloc(vbuf_len, sizeof(GLfloat));
for (int i = 0; i < hex_count; i++)
fillTriangleBufferFromHex(vbuf, 54 * i, (*hexes)[i]);
if (!initGLBufferObject(&g_filled_hex_render_group.vertex_buffer, vbuf_len, GL_DYNAMIC_DRAW, vbuf))
return false;
// color data for hex vertices
GLfloat cbuf[vbuf_len];
fillColorBuffer(cbuf, vbuf_len, hexes);
if (!initGLBufferObject(&g_filled_hex_render_group.color_buffer, vbuf_len, GL_DYNAMIC_DRAW, cbuf))
@ -252,17 +264,15 @@ createScene(std::vector<hex_info>* hexes)
// hex line vertex data
// TODO: surely there's a way to use indexed drawing for line vertices eg) line_loop
// and still use one buffer for multiple shapes/paths gldrawarraysintanced?, gldrawelements?
// https://gamedev.stackexchange.com/questions/104310/opengl-4-5-primitive-restart-vs-base-index
int line_vertices_per_hex = 6 * 2; // 12 vertices since we're using line segments atm
//gl_buffer *line_vertex_buffer = &g_hex_line_render_group.vertex_buffer;
int line_buf_len = hexes->size() * line_vertices_per_hex * 3; // 3 floats per vertex
GLfloat line_buf[line_buf_len];
fillHexLineBuffer(line_buf, line_buf_len, hexes);
if (!initGLBufferObject(&g_hex_line_render_group.vertex_buffer, line_buf_len, GL_STATIC_DRAW, line_buf))
return false;
// free temporary buffers
std::free(vbuf);
std::free(cbuf);
std::free(line_buf);
// debug draw vertexes
// 4 vertices, 3 floats per vertex

Loading…
Cancel
Save