Merge branch 'GameClient' of https://github.com/dean11/Danbias into GameClient

This commit is contained in:
lindaandersson 2014-02-21 12:38:34 +01:00
commit b0aa6acdd6
9 changed files with 85 additions and 1 deletions

View File

@ -76,7 +76,7 @@ bool GameState::Init( SharedStateContent &shared )
this->privData->camera.SetPerspectiveProjection( Utility::Value::Radian(90.0f), aspectRatio, 0.1f, 1000.0f ); this->privData->camera.SetPerspectiveProjection( Utility::Value::Radian(90.0f), aspectRatio, 0.1f, 1000.0f );
Graphics::API::SetProjection( this->privData->camera.GetProjectionMatrix() ); Graphics::API::SetProjection( this->privData->camera.GetProjectionMatrix() );
gfxOp.AmbientValue = 0.5f; gfxOp.AmbientValue = 0.5f;
gfxOp.GlobalGlowTint = Math::Float3(2,1,1); gfxOp.GlobalGlowTint = Math::Float3(1,1,1);
gfxOp.GlobalTint = Math::Float3(1,1,1); gfxOp.GlobalTint = Math::Float3(1,1,1);
Graphics::API::SetOptions(gfxOp); Graphics::API::SetOptions(gfxOp);

View File

@ -437,6 +437,38 @@ int ResourceManager::GetResourceId(const wchar_t c[])
return -1; return -1;
} }
int ResourceManager::GetResourceCount(const wchar_t filename[])
{
ResourceData *t = FindResource(this->resources, filename);
if(t) return t->referenceCount;
return 0;
}
int ResourceManager::GetResourceCount(const HRESOURCE& resource)
{
ResourceData *t = FindResource(this->resources, resource);
if(t) return t->referenceCount;
return 0;
}
int ResourceManager::GetResourceSize(const wchar_t filename[])
{
ResourceData *t = FindResource(this->resources, filename);
if(t) return t->resourceSize;
return 0;
}
int ResourceManager::GetResourceSize(const HRESOURCE& resource)
{
ResourceData *t = FindResource(this->resources, resource);
if(t) return t->resourceSize;
return 0;
}

View File

@ -148,6 +148,14 @@ namespace Oyster
* @return Returns the accociated ID * @return Returns the accociated ID
*/ */
int GetResourceId(const wchar_t filename[]); int GetResourceId(const wchar_t filename[]);
int GetResourceCount(const wchar_t filename[]);
int GetResourceCount(const HRESOURCE& resource);
int GetResourceSize(const wchar_t filename[]);
int GetResourceSize(const HRESOURCE& resource);
private: private:
ResourceManager(const ResourceManager& obj); ResourceManager(const ResourceManager& obj);

View File

@ -44,6 +44,7 @@ namespace Utility
ReferenceCount() :count(0) { } ReferenceCount() :count(0) { }
ReferenceCount(const ReferenceCount& o) { count = o.count; } ReferenceCount(const ReferenceCount& o) { count = o.count; }
inline const ReferenceCount& operator=(const ReferenceCount& o) { count = o.count; return *this;} inline const ReferenceCount& operator=(const ReferenceCount& o) { count = o.count; return *this;}
operator int() { return this->count; }
inline void Incref() { this->count++; } inline void Incref() { this->count++; }
inline void Incref(int c) { this->count += c; } inline void Incref(int c) { this->count += c; }
inline int Decref() { return --this->count;} inline int Decref() { return --this->count;}

View File

@ -90,6 +90,13 @@ namespace Oyster
Math::Float3 GlowTint; Math::Float3 GlowTint;
Math::Float PAD2; Math::Float PAD2;
}; };
struct RenderInstanceData
{
Math::Matrix WV;
Math::Matrix WVP;
TintData td;
};
} }
} }
} }

View File

@ -19,6 +19,7 @@ namespace Oyster
Math::Float4x4 Projection; Math::Float4x4 Projection;
std::vector<Definitions::Pointlight> Lights; std::vector<Definitions::Pointlight> Lights;
float deltaTime; float deltaTime;
int MostModel;
#ifdef _DEBUG #ifdef _DEBUG
Model::Model* cube; Model::Model* cube;
Model::Model* sphere; Model::Model* sphere;
@ -133,6 +134,16 @@ namespace Oyster
return API::Sucsess; return API::Sucsess;
} }
void API::BeginLoadingModels()
{
}
void API::EndLoadingModels()
{
//TODO finalize instance buffers and create rendering map;
}
//returns null for invalid filenames //returns null for invalid filenames
Model::Model* API::CreateModel(std::wstring filename) Model::Model* API::CreateModel(std::wstring filename)
{ {
@ -153,6 +164,15 @@ namespace Oyster
return NULL; return NULL;
} }
if(Core::loader.GetResourceCount(m->info) == 1)
{
Render::Resources::RenderData[m->info] = new Render::Resources::ModelDataWrapper();
}
else
{
Render::Resources::RenderData[m->info]->Models++;
}
return m; return m;
} }

View File

@ -42,6 +42,10 @@ namespace Oyster
static State Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Option options); static State Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Option options);
static void BeginLoadingModels();
static void EndLoadingModels();
static State ReloadShaders(); static State ReloadShaders();
//should be called after rendered normal models, before GUI or Text rendering //should be called after rendered normal models, before GUI or Text rendering

View File

@ -63,6 +63,8 @@ namespace Oyster
ID3D11ShaderResourceView* Resources::Gui::Text::Font = NULL; ID3D11ShaderResourceView* Resources::Gui::Text::Font = NULL;
ID3D11DepthStencilView* Resources::Gui::depth = NULL; ID3D11DepthStencilView* Resources::Gui::depth = NULL;
std::map<Model::ModelInfo*, Resources::ModelDataWrapper*> Resources::RenderData = std::map<Model::ModelInfo*, Resources::ModelDataWrapper*>();
#pragma endregion #pragma endregion

View File

@ -1,6 +1,8 @@
#pragma once #pragma once
#include "../Core/Core.h" #include "../Core/Core.h"
#include "../Model/ModelInfo.h"
#include "../Definitions/GraphicalDefinition.h"
namespace Oyster namespace Oyster
{ {
@ -11,6 +13,14 @@ namespace Oyster
class Resources class Resources
{ {
public: public:
struct ModelDataWrapper
{
Definitions::RenderInstanceData* rid;
int Models;
};
static std::map<Model::ModelInfo*, ModelDataWrapper*> RenderData;
static const int GBufferSize = 3; static const int GBufferSize = 3;
static const int LBufferSize = 3; static const int LBufferSize = 3;