Skip to content

Commit

Permalink
GLCore wip
Browse files Browse the repository at this point in the history
  • Loading branch information
i-saint committed Mar 5, 2016
1 parent c0867d7 commit 40a4bc0
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Plugin/FrameCapturer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ BOOL WINAPI DllMain(HINSTANCE module_handle, DWORD reason_for_call, LPVOID reser
if (proc) {
fcIGraphicsDevice *dev = proc();
if (dev) {
UnitySetGraphicsDevice(dev->getDevicePtr(), dev->getDeviceType(), kGfxDeviceEventInitialize);
UnitySetGraphicsDevice(dev->getDevicePtr(), dev->getDeviceType(), kUnityGfxDeviceEventInitialize);
}
}
}
Expand Down
21 changes: 12 additions & 9 deletions Plugin/GraphicsDevice/fcGraphicsDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,31 @@ fcCLinkage fcExport fcIGraphicsDevice* fcGetGraphicsDevice() { return g_the_grap

fcCLinkage fcExport void UnitySetGraphicsDevice(void* device, int deviceType, int eventType)
{
if (eventType == kGfxDeviceEventInitialize) {
if (eventType == kUnityGfxDeviceEventInitialize) {
#ifdef fcSupportD3D9
if (deviceType == kGfxRendererD3D9)
if (deviceType == kUnityGfxRendererD3D9)
{
g_the_graphics_device = fcCreateGraphicsDeviceD3D9(device);
}
#endif // fcSupportD3D9
#ifdef fcSupportD3D11
if (deviceType == kGfxRendererD3D11)
if (deviceType == kUnityGfxRendererD3D11)
{
g_the_graphics_device = fcCreateGraphicsDeviceD3D11(device);
}
#endif // fcSupportD3D11
#ifdef fcSupportOpenGL
if (deviceType == kGfxRendererOpenGL)
if (deviceType == kUnityGfxRendererOpenGL ||
deviceType == kUnityGfxRendererOpenGLES20 ||
deviceType == kUnityGfxRendererOpenGLES30 ||
deviceType == kUnityGfxRendererOpenGLCore )
{
g_the_graphics_device = fcCreateGraphicsDeviceOpenGL(device);
}
#endif // fcSupportOpenGL
}

if (eventType == kGfxDeviceEventShutdown) {
if (eventType == kUnityGfxDeviceEventShutdown) {
delete g_the_graphics_device;
g_the_graphics_device = nullptr;
}
Expand All @@ -50,27 +53,27 @@ fcCLinkage fcExport void UnityRenderEvent(int)
#ifdef fcSupportOpenGL
fcCLinkage fcExport void fcInitializeOpenGL()
{
UnitySetGraphicsDevice(nullptr, kGfxRendererOpenGL, kGfxDeviceEventInitialize);
UnitySetGraphicsDevice(nullptr, kUnityGfxRendererOpenGL, kUnityGfxDeviceEventInitialize);
}
#endif

#ifdef fcSupportD3D9
fcCLinkage fcExport void fcInitializeD3D9(void *device)
{
UnitySetGraphicsDevice(device, kGfxRendererD3D9, kGfxDeviceEventInitialize);
UnitySetGraphicsDevice(device, kUnityGfxRendererD3D9, kUnityGfxDeviceEventInitialize);
}
#endif

#ifdef fcSupportD3D11
fcCLinkage fcExport void fcInitializeD3D11(void *device)
{
UnitySetGraphicsDevice(device, kGfxRendererD3D11, kGfxDeviceEventInitialize);
UnitySetGraphicsDevice(device, kUnityGfxRendererD3D11, kUnityGfxDeviceEventInitialize);
}
#endif

fcCLinkage fcExport void fcFinalizeGraphicsDevice()
{
UnitySetGraphicsDevice(nullptr, kGfxRendererNull, kGfxDeviceEventShutdown);
UnitySetGraphicsDevice(nullptr, kUnityGfxRendererNull, kUnityGfxDeviceEventShutdown);
}

fcCLinkage fcExport void fcGfxSync()
Expand Down
45 changes: 23 additions & 22 deletions Plugin/GraphicsDevice/fcGraphicsDevice.h
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
#include "pch.h"


// Graphics device identifiers in Unity
enum GfxDeviceRenderer
typedef enum UnityGfxRenderer
{
kGfxRendererOpenGL = 0, // OpenGL
kGfxRendererD3D9, // Direct3D 9
kGfxRendererD3D11, // Direct3D 11
kGfxRendererGCM, // Sony PlayStation 3 GCM
kGfxRendererNull, // "null" device (used in batch mode)
kGfxRendererHollywood, // Nintendo Wii
kGfxRendererXenon, // Xbox 360
kGfxRendererOpenGLES, // OpenGL ES 1.1
kGfxRendererOpenGLES20Mobile, // OpenGL ES 2.0 mobile variant
kGfxRendererMolehill, // Flash 11 Stage3D
kGfxRendererOpenGLES20Desktop, // OpenGL ES 2.0 desktop variant (i.e. NaCl)
kGfxRendererCount
};
kUnityGfxRendererOpenGL = 0, // Legacy OpenGL
kUnityGfxRendererD3D9 = 1, // Direct3D 9
kUnityGfxRendererD3D11 = 2, // Direct3D 11
kUnityGfxRendererGCM = 3, // PlayStation 3
kUnityGfxRendererNull = 4, // "null" device (used in batch mode)
kUnityGfxRendererXenon = 6, // Xbox 360
kUnityGfxRendererOpenGLES20 = 8, // OpenGL ES 2.0
kUnityGfxRendererOpenGLES30 = 11, // OpenGL ES 3.0
kUnityGfxRendererGXM = 12, // PlayStation Vita
kUnityGfxRendererPS4 = 13, // PlayStation 4
kUnityGfxRendererXboxOne = 14, // Xbox One
kUnityGfxRendererMetal = 16, // iOS Metal
kUnityGfxRendererOpenGLCore = 17, // OpenGL core
kUnityGfxRendererD3D12 = 18, // Direct3D 12
} UnityGfxRenderer;

// Event types for UnitySetGraphicsDevice
enum GfxDeviceEventType {
kGfxDeviceEventInitialize = 0,
kGfxDeviceEventShutdown,
kGfxDeviceEventBeforeReset,
kGfxDeviceEventAfterReset,
};
typedef enum UnityGfxDeviceEventType
{
kUnityGfxDeviceEventInitialize = 0,
kUnityGfxDeviceEventShutdown = 1,
kUnityGfxDeviceEventBeforeReset = 2,
kUnityGfxDeviceEventAfterReset = 3,
} UnityGfxDeviceEventType;


class fcIGraphicsDevice
Expand Down
2 changes: 1 addition & 1 deletion Plugin/GraphicsDevice/fcGraphicsDeviceD3D11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fcGraphicsDeviceD3D11::~fcGraphicsDeviceD3D11()
}

void* fcGraphicsDeviceD3D11::getDevicePtr() { return m_device; }
int fcGraphicsDeviceD3D11::getDeviceType() { return kGfxRendererD3D11; }
int fcGraphicsDeviceD3D11::getDeviceType() { return kUnityGfxRendererD3D11; }


static DXGI_FORMAT fcGetInternalFormatD3D11(fcPixelFormat fmt)
Expand Down
2 changes: 1 addition & 1 deletion Plugin/GraphicsDevice/fcGraphicsDeviceD3D9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fcGraphicsDeviceD3D9::~fcGraphicsDeviceD3D9()
}

void* fcGraphicsDeviceD3D9::getDevicePtr() { return m_device; }
int fcGraphicsDeviceD3D9::getDeviceType() { return kGfxRendererD3D9; }
int fcGraphicsDeviceD3D9::getDeviceType() { return kUnityGfxRendererD3D9; }


void fcGraphicsDeviceD3D9::clearStagingTextures()
Expand Down
2 changes: 1 addition & 1 deletion Plugin/GraphicsDevice/fcGraphicsDeviceOpenGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fcIGraphicsDevice* fcCreateGraphicsDeviceOpenGL(void *device)


void* fcGraphicsDeviceOpenGL::getDevicePtr() { return m_device; }
int fcGraphicsDeviceOpenGL::getDeviceType() { return kGfxRendererOpenGL; }
int fcGraphicsDeviceOpenGL::getDeviceType() { return kUnityGfxRendererOpenGL; }

fcGraphicsDeviceOpenGL::fcGraphicsDeviceOpenGL(void *device)
: m_device(device)
Expand Down

0 comments on commit 40a4bc0

Please sign in to comment.