Skip to content

Commit b28ce3b

Browse files
author
nitrocaster
committed
Fix render env setup.
1 parent 0af6e60 commit b28ce3b

File tree

6 files changed

+75
-56
lines changed

6 files changed

+75
-56
lines changed

src/Layers/xrRenderPC_GL/xrRender_GL.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
#pragma comment(lib, "xrEngine.lib")
99
#pragma comment(lib, "xrScriptEngine.lib")
1010

11+
extern "C" void XR_EXPORT SetupEnv()
12+
{
13+
GlobalEnv.Render = &RImplementation;
14+
GlobalEnv.RenderFactory = &RenderFactoryImpl;
15+
GlobalEnv.DU = &DUImpl;
16+
GlobalEnv.UIRender = &UIRenderImpl;
17+
#ifdef DEBUG
18+
GlobalEnv.DRender = &DebugRenderImpl;
19+
#endif
20+
xrRender_initconsole();
21+
}
22+
1123
BOOL APIENTRY DllMain( HANDLE hModule,
1224
DWORD ul_reason_for_call,
1325
LPVOID lpReserved
@@ -16,18 +28,8 @@ BOOL APIENTRY DllMain( HANDLE hModule,
1628
switch (ul_reason_for_call)
1729
{
1830
case DLL_PROCESS_ATTACH :
19-
// Can't call CreateDXGIFactory from DllMain
20-
//if (!xrRender_test_hw()) return FALSE;
21-
GlobalEnv.Render = &RImplementation;
22-
GlobalEnv.RenderFactory = &RenderFactoryImpl;
23-
GlobalEnv.DU = &DUImpl;
24-
//GlobalEnv.vid_mode_token = inited by HW;
25-
GlobalEnv.UIRender = &UIRenderImpl;
26-
#ifdef DEBUG
27-
GlobalEnv.DRender = &DebugRenderImpl;
28-
#endif // DEBUG
29-
xrRender_initconsole ();
30-
break ;
31+
SetupEnv();
32+
break;
3133
case DLL_THREAD_ATTACH :
3234
case DLL_THREAD_DETACH :
3335
case DLL_PROCESS_DETACH :

src/Layers/xrRenderPC_R1/xrRender_R1.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
#pragma comment(lib, "xrEngine.lib")
77
#pragma comment(lib, "xrScriptEngine.lib")
88

9+
extern "C" void XR_EXPORT SetupEnv()
10+
{
11+
GlobalEnv.Render = &RImplementation;
12+
GlobalEnv.RenderFactory = &RenderFactoryImpl;
13+
GlobalEnv.DU = &DUImpl;
14+
GlobalEnv.UIRender = &UIRenderImpl;
15+
#ifdef DEBUG
16+
GlobalEnv.DRender = &DebugRenderImpl;
17+
#endif
18+
xrRender_initconsole();
19+
}
20+
921
BOOL APIENTRY DllMain( HANDLE hModule,
1022
DWORD ul_reason_for_call,
1123
LPVOID lpReserved
@@ -14,16 +26,8 @@ BOOL APIENTRY DllMain( HANDLE hModule,
1426
switch (ul_reason_for_call)
1527
{
1628
case DLL_PROCESS_ATTACH:
17-
GlobalEnv.Render = &RImplementation;
18-
GlobalEnv.RenderFactory = &RenderFactoryImpl;
19-
GlobalEnv.DU = &DUImpl;
20-
//GlobalEnv.vid_mode_token = inited by HW;
21-
GlobalEnv.UIRender = &UIRenderImpl;
22-
#ifdef DEBUG
23-
GlobalEnv.DRender = &DebugRenderImpl;
24-
#endif // DEBUG
25-
xrRender_initconsole ();
26-
break;
29+
SetupEnv();
30+
break;
2731
case DLL_THREAD_ATTACH:
2832
case DLL_THREAD_DETACH:
2933
case DLL_PROCESS_DETACH:

src/Layers/xrRenderPC_R2/xrRender_R2.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
#pragma comment(lib, "xrEngine.lib")
99
#pragma comment(lib, "xrScriptEngine.lib")
1010

11+
extern "C" void XR_EXPORT SetupEnv()
12+
{
13+
GlobalEnv.Render = &RImplementation;
14+
GlobalEnv.RenderFactory = &RenderFactoryImpl;
15+
GlobalEnv.DU = &DUImpl;
16+
GlobalEnv.UIRender = &UIRenderImpl;
17+
#ifdef DEBUG
18+
GlobalEnv.DRender = &DebugRenderImpl;
19+
#endif
20+
xrRender_initconsole();
21+
}
22+
1123
BOOL APIENTRY DllMain( HANDLE hModule,
1224
DWORD ul_reason_for_call,
1325
LPVOID lpReserved
@@ -16,16 +28,8 @@ BOOL APIENTRY DllMain( HANDLE hModule,
1628
switch (ul_reason_for_call)
1729
{
1830
case DLL_PROCESS_ATTACH :
19-
GlobalEnv.Render = &RImplementation;
20-
GlobalEnv.RenderFactory = &RenderFactoryImpl;
21-
GlobalEnv.DU = &DUImpl;
22-
//GlobalEnv.vid_mode_token = inited by HW;
23-
GlobalEnv.UIRender = &UIRenderImpl;
24-
#ifdef DEBUG
25-
GlobalEnv.DRender = &DebugRenderImpl;
26-
#endif // DEBUG
27-
xrRender_initconsole ();
28-
break ;
31+
SetupEnv();
32+
break;
2933
case DLL_THREAD_ATTACH :
3034
case DLL_THREAD_DETACH :
3135
case DLL_PROCESS_DETACH :

src/Layers/xrRenderPC_R3/xrRender_R3.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
#pragma comment(lib, "xrEngine.lib")
99
#pragma comment(lib, "xrScriptEngine.lib")
1010

11+
extern "C" void XR_EXPORT SetupEnv()
12+
{
13+
GlobalEnv.Render = &RImplementation;
14+
GlobalEnv.RenderFactory = &RenderFactoryImpl;
15+
GlobalEnv.DU = &DUImpl;
16+
GlobalEnv.UIRender = &UIRenderImpl;
17+
#ifdef DEBUG
18+
GlobalEnv.DRender = &DebugRenderImpl;
19+
#endif
20+
xrRender_initconsole();
21+
}
22+
1123
BOOL APIENTRY DllMain( HANDLE hModule,
1224
DWORD ul_reason_for_call,
1325
LPVOID lpReserved
@@ -16,18 +28,8 @@ BOOL APIENTRY DllMain( HANDLE hModule,
1628
switch (ul_reason_for_call)
1729
{
1830
case DLL_PROCESS_ATTACH :
19-
// Can't call CreateDXGIFactory from DllMain
20-
//if (!xrRender_test_hw()) return FALSE;
21-
GlobalEnv.Render = &RImplementation;
22-
GlobalEnv.RenderFactory = &RenderFactoryImpl;
23-
GlobalEnv.DU = &DUImpl;
24-
//GlobalEnv.vid_mode_token = inited by HW;
25-
GlobalEnv.UIRender = &UIRenderImpl;
26-
#ifdef DEBUG
27-
GlobalEnv.DRender = &DebugRenderImpl;
28-
#endif // DEBUG
29-
xrRender_initconsole ();
30-
break ;
31+
SetupEnv();
32+
break;
3133
case DLL_THREAD_ATTACH :
3234
case DLL_THREAD_DETACH :
3335
case DLL_PROCESS_DETACH :

src/Layers/xrRenderPC_R4/xrRender_R4.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
#pragma comment(lib, "xrEngine.lib")
99
#pragma comment(lib, "xrScriptEngine.lib")
1010

11+
extern "C" void XR_EXPORT SetupEnv()
12+
{
13+
GlobalEnv.Render = &RImplementation;
14+
GlobalEnv.RenderFactory = &RenderFactoryImpl;
15+
GlobalEnv.DU = &DUImpl;
16+
GlobalEnv.UIRender = &UIRenderImpl;
17+
#ifdef DEBUG
18+
GlobalEnv.DRender = &DebugRenderImpl;
19+
#endif
20+
xrRender_initconsole();
21+
}
22+
1123
BOOL APIENTRY DllMain( HANDLE hModule,
1224
DWORD ul_reason_for_call,
1325
LPVOID lpReserved
@@ -16,18 +28,8 @@ BOOL APIENTRY DllMain( HANDLE hModule,
1628
switch (ul_reason_for_call)
1729
{
1830
case DLL_PROCESS_ATTACH :
19-
// Can't call CreateDXGIFactory from DllMain
20-
//if (!xrRender_test_hw()) return FALSE;
21-
GlobalEnv.Render = &RImplementation;
22-
GlobalEnv.RenderFactory = &RenderFactoryImpl;
23-
GlobalEnv.DU = &DUImpl;
24-
//GlobalEnv.vid_mode_token = inited by HW;
25-
GlobalEnv.UIRender = &UIRenderImpl;
26-
#ifdef DEBUG
27-
GlobalEnv.DRender = &DebugRenderImpl;
28-
#endif // DEBUG
29-
xrRender_initconsole ();
30-
break ;
31+
SetupEnv();
32+
break;
3133
case DLL_THREAD_ATTACH :
3234
case DLL_THREAD_DETACH :
3335
case DLL_PROCESS_DETACH :

src/xrEngine/EngineAPI.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ void CEngineAPI::Initialize(void)
142142
R_ASSERT(hRender);
143143
g_current_renderer = 1;
144144
}
145+
// ask current renderer to setup GlobalEnv
146+
using SetupEnvFunc = void(*)();
147+
auto setupEnv = (SetupEnvFunc)XRay::GetProcAddress(hRender, "SetupEnv");
148+
R_ASSERT(setupEnv);
149+
setupEnv();
145150
// game
146151
{
147152
LPCSTR g_name = "xrGame";

0 commit comments

Comments
 (0)