summaryrefslogtreecommitdiff
path: root/Runtime/Interfaces/IGfxDevice.cpp
blob: 3e358a0f6b14d658d4cc56691b0260a78aec24ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "UnityPrefix.h"
#include "IGfxDevice.h"
#include "Runtime/GfxDevice/GfxDevice.h"
#include "Runtime/Graphics/RenderTexture.h"
#include "Runtime/Misc/Plugins.h"
#include "Runtime/Shaders/GraphicsCaps.h"
#include "Runtime/Shaders/Shader.h"

static IGfxDevice* gGfxDevice;

IGfxDevice* GetIGfxDevice ()
{
	return gGfxDevice;
}

void SetIGfxDevice (IGfxDevice* manager)
{
	gGfxDevice = manager;
}


void CommonReloadResources(int flags)
{
	if (flags & GfxDevice::kReloadTextures)
		Texture::ReloadAll();

	if (flags & GfxDevice::kReloadShaders)
		Shader::ReloadAllShaders();

	if (flags & GfxDevice::kReleaseRenderTextures)
		RenderTexture::ReleaseAll();
}

bool InitializeGfxDevice() {
	if (!GetIGfxDevice()->InitializeGfxDevice())
		return false;
	
	GfxDevice& device = GetGfxDevice();
	device.SetMarkerCallback (PluginsRenderMarker);
	device.SetSetNativeGfxDeviceCallback (PluginsSetGraphicsDevice);
	device.SetReloadCallback (CommonReloadResources);
	return true;
}

void ParseGfxDeviceArgs () { return GetIGfxDevice()->ParseGfxDeviceArgs(); }
bool				IsGfxDevice() { return GetIGfxDevice()->IsGfxDevice(); }
GfxDevice&			GetGfxDevice() { return GetIGfxDevice()->GetGfxDevice(); }
GfxDevice&			GetUncheckedGfxDevice() { return GetIGfxDevice()->GetUncheckedGfxDevice(); }
void				DestroyGfxDevice() { GetIGfxDevice()->DestroyGfxDevice(); }

GfxDevice&			GetRealGfxDevice() { return GetIGfxDevice()->GetRealGfxDevice(); }
bool				IsRealGfxDeviceThreadOwner()  { return GetIGfxDevice()->IsRealGfxDeviceThreadOwner(); }

GraphicsCaps&		gGraphicsCaps { return GetIGfxDevice()->gGraphicsCaps; }