Danbias/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp

132 lines
2.9 KiB
C++
Raw Normal View History

2013-11-26 13:44:58 +01:00
#include "GFXAPI.h"
#include "../Core/Core.h"
#include "../Render/Resources/Debug.h"
#include "../Render/Resources/Deffered.h"
2013-11-26 13:44:58 +01:00
#include "../Render/Rendering/Render.h"
2013-11-26 15:33:05 +01:00
#include "../FileLoader/ObjReader.h"
#include "../../Misc/Resource/OysterResource.h"
#include "../FileLoader/GeneralLoader.h"
2013-11-26 13:44:58 +01:00
namespace Oyster
{
namespace Graphics
{
namespace
{
Math::Float4x4 View;
Math::Float4x4 Projection;
std::vector<Definitions::Pointlight> Lights;
}
2013-11-26 15:33:05 +01:00
API::State API::Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Math::Float2 resulotion)
2013-11-26 13:44:58 +01:00
{
2013-11-26 15:33:05 +01:00
Core::resolution = resulotion;
2013-11-26 13:44:58 +01:00
if(Core::Init::FullInit(Window, MSAA_Quality, Fullscreen) == Core::Init::Fail)
{
return API::Fail;
}
#ifdef _DEBUG
if(Render::Resources::Debug::Init() == Core::Init::Fail)
2013-11-26 13:44:58 +01:00
{
return API::Fail;
}
#endif
Render::Resources::Deffered::Init();
2013-11-26 15:33:05 +01:00
Render::Preparations::Basic::SetViewPort();
2013-11-26 13:44:58 +01:00
return API::Sucsess;
}
void API::SetProjection(Math::Float4x4& projection)
{
Projection = projection;
}
void API::SetView(Math::Float4x4& view)
{
View = view;
}
void API::NewFrame()
2013-11-26 13:44:58 +01:00
{
if(Lights.size())
{
Render::Rendering::Basic::NewFrame(View, Projection, &Lights[0], Lights.size());
}
else
{
Render::Rendering::Basic::NewFrame(View, Projection, NULL, 0);
}
2013-11-26 13:44:58 +01:00
}
void API::RenderScene(Model::Model models[], int count)
2013-11-26 13:44:58 +01:00
{
Render::Rendering::Basic::RenderScene(models,count);
}
void API::RenderModel(Model::Model& m)
{
Render::Rendering::Basic::RenderScene(&m,1);
}
2013-11-26 15:33:05 +01:00
void API::EndFrame()
{
Render::Rendering::Basic::EndFrame();
}
API::State API::SetOptions(API::Option option)
{
return API::Sucsess;
}
Model::Model* API::CreateModel(std::wstring filename)
{
Model::Model* m = new Model::Model();
m->WorldMatrix = Oyster::Math::Float4x4::identity;
m->Visible = true;
m->info = Oyster::Resource::OysterResource::LoadResource(filename.c_str(),Oyster::Graphics::Loading::LoadOBJ);
2013-11-26 15:33:05 +01:00
return m;
}
void API::DeleteModel(Model::Model* model)
{
Model::ModelInfo* info = (Model::ModelInfo*)model->info;
2013-11-26 15:33:05 +01:00
delete model;
Oyster::Resource::OysterResource::ReleaseResource((Oyster::Resource::OHRESOURCE)info);
}
void API::Clean()
{
SAFE_DELETE(Core::viewPort);
Oyster::Resource::OysterResource::Clean();
Oyster::Graphics::Core::PipelineManager::Clean();
#ifdef _DEBUG
Oyster::Graphics::Render::Resources::Debug::Clean();
#endif
Oyster::Graphics::Render::Resources::Deffered::Clean();
SAFE_RELEASE(Core::depthStencil);
SAFE_RELEASE(Core::depthStencilUAV);
SAFE_RELEASE(Core::backBufferRTV);
SAFE_RELEASE(Core::backBufferUAV);
SAFE_RELEASE(Core::swapChain);
SAFE_RELEASE(Core::deviceContext);
SAFE_RELEASE(Core::device);
2013-11-26 15:33:05 +01:00
}
void API::AddLight(Definitions::Pointlight light)
{
Lights.push_back(light);
}
void API::ClearLights()
{
Lights.clear();
}
2013-11-26 13:44:58 +01:00
}
}