Projektdateien hinzufügen.

This commit is contained in:
Robert Altner 2018-03-20 18:17:17 +01:00
parent d031c74fd7
commit 5a0672dea7
144 changed files with 24216 additions and 0 deletions

Binary file not shown.

View file

@ -0,0 +1,174 @@
<?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>{9F36592B-4AB2-44A2-B3E6-DD06ADF6D6B5}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>ConwaysGameOfLife</RootNamespace>
<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>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</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>
<IncludePath>$(SolutionDir)deps\include;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)deps\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(SolutionDir)deps\include;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)deps\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>sfml-graphics-d.lib;sfml-system-d.lib;sfml-window-d.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Framework.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="TestRender.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="ConwaysGameOfLife.cpp" />
<ClCompile Include="Framework.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="TestRender.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Quelldateien">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Headerdateien">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Ressourcendateien">
<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;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="Framework.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="TestRender.h">
<Filter>Headerdateien</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="ConwaysGameOfLife.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="Framework.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="TestRender.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
</ItemGroup>
</Project>

View file

@ -0,0 +1,112 @@
#include "stdafx.h"
#include "Framework.h"
// Initilaize static variables
sf::RenderWindow* Framework::m_window = nullptr;
sf::Event Framework::m_event = sf::Event();
TestRender Framework::m_test = TestRender();
bool Framework::init(unsigned width, unsigned height, const char* title, sf::Uint8 flags)
{
// If Window does not exist, create it
if (m_window == nullptr)
{
m_window = new sf::RenderWindow(sf::VideoMode(width, height), title, flags);
}
// If window is still nullptr, throw error
if (m_window == nullptr)
{
std::cout << "Window could not be created." << std::endl;
system("PAUSE");
return false;
}
return true;
}
// Program loop
bool Framework::run()
{
// If no window, break
if (m_window == nullptr)
{
std::cout << "Cannot run program loop if no window was initialized. Call Framework::init first." << std::endl;
system("PAUSE");
return false;
}
// The loop
while (m_window->isOpen())
{
// Run update(). If an error occures, break
if (update() == false)
{
std::cout << "An Error occured in Framework::update()" << std::endl;
system("PAUSE");
release();
return false;
}
// Run handleEvents(). If an error occures, break
if (handleEvents() == false)
{
std::cout << "An Error occured in Framework::handleEvents()" << std::endl;
system("PAUSE");
release();
return false;
}
// Run render(). If an error occures, break
if (render() == false)
{
std::cout << "An Error occured in Framework::render()" << std::endl;
system("PAUSE");
release();
return false;
}
}
// release window
release();
}
// Updates screen elements
bool Framework::update()
{
if (!m_test.update()) return false;
return true;
}
// Handles window events
bool Framework::handleEvents()
{
while (m_window->pollEvent(m_event))
{
// On Close Event
if (m_event.type == sf::Event::Closed) m_window->close();
}
return true;
}
// Renders objects
bool Framework::render()
{
m_window->clear();
if (!m_test.render(*m_window)) return false;
m_window->display();
return true;
}
// Releases pointers
void Framework::release()
{
m_window = nullptr;
delete m_window;
std::cout << "Released window" << std::endl;
}

View file

@ -0,0 +1,66 @@
/**
* Framework.h
* Handles Events, Updates and Renders the Window
* It is static, since only one window should be created
*
* @author Robert Altner
* @version 1.0
*/
#pragma once
#include "stdafx.h"
class Framework
{
public:
/**
Initializes a window
@param width Width of the window
@param height Height of the window
@param title Title of the window
@param flags A uint with SFML flags
@return True if success, False if fail
*/
static bool init(unsigned width, unsigned height, const char* title, sf::Uint8 flags);
/**
The program loop
@return False if an error occured
*/
static bool run();
private:
static sf::RenderWindow* m_window; // A reference to a window object
static sf::Event m_event; // The event handling variable of SFML
static TestRender m_test;
/**
Updates the elements on screen
@return False if an error occured
*/
static bool update();
/**
Handles events in the program
@return False if an error occured
*/
static bool handleEvents();
/**
Renders elements to screen
@return False if an error occured
*/
static bool render();
/**
Deletes pointers
*/
static void release();
};

View file

@ -0,0 +1,27 @@
#include "stdafx.h"
#include "TestRender.h"
TestRender::TestRender()
{
startPos = sf::Vector2f(200, 200);
circle = sf::CircleShape(200);
circle.setFillColor(sf::Color::Green);
circle.setPosition(startPos);
counter = 0;
}
bool TestRender::render(sf::RenderWindow& window)
{
window.draw(circle);
return true;
}
bool TestRender::update()
{
circle.setPosition(startPos + sf::Vector2f(sin(counter) * 100, cos(counter) * 100));
counter += 0.001;
return true;
}

View file

@ -0,0 +1,26 @@
/**
* TestRender.h
* A class used by me to test rendering/update functionality of Framework.h
*
* @author Robert Altner
* @version 1.0
*/
#pragma once
#include "stdafx.h"
class TestRender
{
public:
TestRender();
bool render(sf::RenderWindow& window);
bool update();
private:
sf::CircleShape circle;
sf::Vector2f startPos;
float counter;
};

Binary file not shown.

BIN
ConwaysGameOfLife/stdafx.h Normal file

Binary file not shown.

Binary file not shown.