GL - added client objects

-  no memory leaks in client
This commit is contained in:
Linda Andersson 2013-12-09 11:05:47 +01:00
parent 5416df6d86
commit 4134836405
15 changed files with 265 additions and 35 deletions

View File

@ -106,12 +106,12 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)GameLogic;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;GameLogic_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
@ -123,12 +123,12 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)GameLogic;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;GameLogic_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
@ -142,14 +142,14 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)GameLogic;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;GameLogic_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>OysterGraphics_x86.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
@ -163,14 +163,14 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)GameLogic;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;GameLogic_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>OysterGraphics_x86.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
@ -187,22 +187,27 @@
<ProjectReference Include="..\..\OysterMath\OysterMath.vcxproj">
<Project>{f10cbc03-9809-4cba-95d8-327c287b18ee}</Project>
</ProjectReference>
<ProjectReference Include="..\GameLogic\GameLogic.vcxproj">
<Project>{b1195bb9-b3a5-47f0-906c-8dea384d1520}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="DanBiasGame_Impl.cpp" />
<ClCompile Include="DLLMain.cpp" />
<ClCompile Include="GameClientState\GameState\C_DynamicObj.cpp" />
<ClCompile Include="GameClientState\GameClientState.cpp" />
<ClCompile Include="GameClientState\GameState.cpp" />
<ClCompile Include="GameClientState\LobbyState.cpp" />
<ClCompile Include="GameClientState\GameState\C_Player.cpp" />
<ClCompile Include="GameClientState\GameState\C_StaticObj.cpp" />
<ClCompile Include="GameClientState\C_Object.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="GameClientState\GameState\C_DynamicObj.h" />
<ClInclude Include="GameClientState\GameClientState.h" />
<ClInclude Include="GameClientState\GameState.h" />
<ClInclude Include="Include\DanBiasGame.h" />
<ClInclude Include="GameClientState\LobbyState.h" />
<ClInclude Include="GameClientState\GameState\C_Player.h" />
<ClInclude Include="GameClientState\GameState\C_StaticObj.h" />
<ClInclude Include="GameClientState\C_Object.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -5,7 +5,7 @@
#include "GameClientState/GameClientState.h"
#include "GameClientState\GameState.h"
#include "GameClientState\LobbyState.h"
#include "vld.h"
namespace DanBias
{
@ -180,6 +180,9 @@ namespace DanBias
if(state != Client::GameClientState::ClientState_Same)
{
m_data->gameClientState->Release();
delete m_data->gameClientState;
m_data->gameClientState = NULL;
switch (state)
{
case Client::GameClientState::ClientState_Lobby:
@ -193,6 +196,7 @@ namespace DanBias
break;
}
m_data->gameClientState->Init();
}
return S_OK;
}
@ -221,8 +225,12 @@ namespace DanBias
HRESULT DanBiasGame::CleanUp()
{
m_data->gameClientState->Release();
delete m_data->gameClientState;
delete m_data;
delete inputObj;
Oyster::Graphics::API::Clean();
return S_OK;
}

View File

@ -0,0 +1,4 @@
#include "C_Object.h"
using namespace DanBias::Client;

View File

@ -0,0 +1,18 @@
#pragma once
namespace DanBias
{
namespace Client
{
class C_Object
{
private:
public:
virtual void Init() = 0;
virtual void setPos() = 0;
virtual void Render() = 0;
virtual void Release() = 0;
};};};

View File

@ -1,5 +1,6 @@
#include "GameState.h"
#include "DllInterfaces/GFXAPI.h"
#include "GameState/C_Player.h"
using namespace DanBias::Client;
struct GameState::myData
@ -7,7 +8,7 @@ struct GameState::myData
myData(){}
Oyster::Math3D::Float4x4 view;
Oyster::Math3D::Float4x4 proj;
Oyster::Graphics::Model::Model *model;
C_Object* player;
}privData;
GameState::GameState(void)
@ -17,12 +18,14 @@ GameState::GameState(void)
GameState::~GameState(void)
{
}
bool GameState::Init()
{
// load models
privData = new myData();
privData->model = Oyster::Graphics::API::CreateModel(L"crate");
privData->player = new C_Player;
privData->player->Init();
privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000);
Oyster::Graphics::API::SetProjection(privData->proj);
@ -46,11 +49,16 @@ bool GameState::Render()
Oyster::Graphics::API::SetView(privData->view);
Oyster::Graphics::API::SetProjection( privData->proj);
Oyster::Graphics::API::NewFrame();
//Oyster::Graphics::API::RenderModel(*(privData->model));
privData->player->Render();
Oyster::Graphics::API::EndFrame();
return true;
}
bool GameState::Release()
{
privData->player->Release();
delete privData->player;
privData->player = NULL;
delete privData;
privData = NULL;
return true;
}

View File

@ -0,0 +1,40 @@
#include "C_DynamicObj.h"
#include "DllInterfaces/GFXAPI.h"
using namespace DanBias::Client;
struct C_DynamicObj::myData
{
myData(){}
Oyster::Graphics::Model::Model *model;
// light
// sound
// effect
}privData;
C_DynamicObj::C_DynamicObj(void)
{
}
C_DynamicObj::~C_DynamicObj(void)
{
}
void C_DynamicObj::Init()
{
// load models
privData = new myData();
privData->model = Oyster::Graphics::API::CreateModel(L"crate");
}
void C_DynamicObj::setPos()
{
}
void C_DynamicObj::Render()
{
Oyster::Graphics::API::RenderModel(*(privData->model));
}
void C_DynamicObj::Release()
{
Oyster::Graphics::API::DeleteModel(privData->model);
delete privData;
}

View File

@ -0,0 +1,20 @@
#pragma once
namespace DanBias
{
namespace Client
{
class C_DynamicObj
{
private:
struct myData;
myData* privData;
public:
C_DynamicObj(void);
virtual ~C_DynamicObj(void);
void Init();
void setPos();
void Render();
void Release();
};};};

View File

@ -0,0 +1,42 @@
#include "C_Player.h"
#include "DllInterfaces/GFXAPI.h"
using namespace DanBias::Client;
struct C_Player::myData
{
myData(){}
Oyster::Math3D::Float4x4 view;
Oyster::Math3D::Float4x4 proj;
Oyster::Graphics::Model::Model *model;
}privData;
C_Player::C_Player(void)
{
}
C_Player::~C_Player(void)
{
}
void C_Player::Init()
{
// load models
privData = new myData();
privData->model = Oyster::Graphics::API::CreateModel(L"crate");
}
void C_Player::setPos()
{
}
void C_Player::Render()
{
Oyster::Graphics::API::RenderModel(*(privData->model));
}
void C_Player::Release()
{
Oyster::Graphics::API::DeleteModel(privData->model);
delete privData;
}

View File

@ -0,0 +1,23 @@
#pragma once
#include "../C_Object.h"
namespace DanBias
{
namespace Client
{
class C_Player : public C_Object
{
private:
struct myData;
myData* privData;
//Oyster::Graphics:: LIght
public:
C_Player(void);
~C_Player(void);
void Init();
void setPos();
void Render();
void Release();
};};};

View File

@ -0,0 +1,42 @@
#include "C_StaticObj.h"
#include "DllInterfaces/GFXAPI.h"
using namespace DanBias::Client;
struct C_StaticObj::myData
{
myData(){}
Oyster::Graphics::Model::Model *model;
// light
// sound
// effect
}privData;
C_StaticObj::C_StaticObj(void)
{
}
C_StaticObj::~C_StaticObj(void)
{
}
void C_StaticObj::Init()
{
// load models
privData = new myData();
privData->model = Oyster::Graphics::API::CreateModel(L"worldDummy");
}
void C_StaticObj::setPos()
{
}
void C_StaticObj::Render()
{
Oyster::Graphics::API::RenderModel(*(privData->model));
}
void C_StaticObj::Release()
{
Oyster::Graphics::API::DeleteModel(privData->model);
delete privData;
}

View File

@ -0,0 +1,21 @@
#pragma once
#include "../C_Object.h"
namespace DanBias
{
namespace Client
{
class C_StaticObj : public C_Object
{
private:
struct myData;
myData* privData;
public:
C_StaticObj(void);
virtual ~C_StaticObj(void);
void Init();
void setPos();
void Render();
void Release();
};};};

View File

@ -1,6 +1,8 @@
#include "LobbyState.h"
#include "DllInterfaces/GFXAPI.h"
#include "OysterMath.h"
#include "GameState/C_Player.h"
#include "GameState/C_StaticObj.h"
using namespace DanBias::Client;
struct LobbyState::myData
@ -8,7 +10,7 @@ struct LobbyState::myData
myData(){}
Oyster::Math3D::Float4x4 view;
Oyster::Math3D::Float4x4 proj;
Oyster::Graphics::Model::Model *model;
C_Object* object;
}privData;
@ -20,14 +22,14 @@ LobbyState::LobbyState(void)
LobbyState::~LobbyState(void)
{
Oyster::Graphics::API::DeleteModel(privData->model);
Oyster::Graphics::API::Clean();
}
bool LobbyState::Init()
{
// load models
privData = new myData();
privData->model = Oyster::Graphics::API::CreateModel(L"crate");
privData->object = new C_StaticObj();
privData->object->Init();
privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000);
//privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000);
@ -36,14 +38,12 @@ bool LobbyState::Init()
privData->view = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),Oyster::Math::Float3(0,0,5.4f));
privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
return true;
}
GameClientState::ClientState LobbyState::Update(float deltaTime, InputClass* KeyInput)
{
if( KeyInput->IsKeyPressed(DIK_Q))
if( KeyInput->IsKeyPressed(DIK_G))
return ClientState_Game;
return ClientState_Same;
}
@ -53,11 +53,17 @@ bool LobbyState::Render()
Oyster::Graphics::API::SetView(privData->view);
Oyster::Graphics::API::SetProjection( privData->proj);
Oyster::Graphics::API::NewFrame();
Oyster::Graphics::API::RenderModel(*(privData->model));
// render objects
privData->object->Render();
Oyster::Graphics::API::EndFrame();
return true;
}
bool LobbyState::Release()
{
privData->object->Release();
delete privData->object;
privData->object = NULL;
delete privData;
privData = NULL;
return true;
}

View File

@ -111,7 +111,7 @@
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<DelayLoadDLLs>DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<AdditionalDependencies>Input_$(PlatformShortName)D.lib;GameLogic_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Input_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -127,7 +127,7 @@
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<DelayLoadDLLs>DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<AdditionalDependencies>Input_$(PlatformShortName)D.lib;GameLogic_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Input_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -147,7 +147,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<DelayLoadDLLs>DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<AdditionalDependencies>Input_$(PlatformShortName).lib;GameLogic_$(PlatformShortName).lib;DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Input_$(PlatformShortName).lib;DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -167,7 +167,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<DelayLoadDLLs>DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<AdditionalDependencies>Input_$(PlatformShortName).lib;GameLogic_$(PlatformShortName).lib;DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Input_$(PlatformShortName).lib;DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
@ -195,9 +195,6 @@
<ProjectReference Include="..\DanBiasServer\DanBiasServer.vcxproj">
<Project>{52380daa-0f4a-4d97-8e57-98df39319caf}</Project>
</ProjectReference>
<ProjectReference Include="..\GameLogic\GameLogic.vcxproj">
<Project>{b1195bb9-b3a5-47f0-906c-8dea384d1520}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -5,6 +5,7 @@
#include "Player.h"
#include "IGame.h"
#include "Camera.h"
#include "DynamicObject.h"
namespace GameLogic
{

View File

@ -169,9 +169,7 @@
<ClInclude Include="Camera.h" />
<ClInclude Include="CollisionManager.h" />
<ClInclude Include="DynamicObject.h" />
<ClInclude Include="Game.h" />
<ClInclude Include="GameMode.h" />
<ClInclude Include="IGame.h" />
<ClInclude Include="Level.h" />
<ClInclude Include="Object.h" />
<ClInclude Include="Player.h" />
@ -183,15 +181,12 @@
<ClCompile Include="Camera.cpp" />
<ClCompile Include="CollisionManager.cpp" />
<ClCompile Include="DynamicObject.cpp" />
<ClCompile Include="Game.cpp" />
<ClCompile Include="GameMode.cpp" />
<ClCompile Include="IGame.cpp" />
<ClCompile Include="Level.cpp" />
<ClCompile Include="Object.cpp" />
<ClCompile Include="Player.cpp" />
<ClCompile Include="RefManager.cpp" />
<ClCompile Include="StaticObject.cpp" />
<ClCompile Include="TestGLMain.cpp" />
<ClCompile Include="Weapon.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />