Skip to content

Commit 18be63b

Browse files
committed
xrEngine: Add OpenGL support.
1 parent 29e38f5 commit 18be63b

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

src/xrEngine/EngineAPI.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,24 @@ bool is_enough_address_space_available()
5555

5656
void CEngineAPI::InitializeNotDedicated()
5757
{
58+
LPCSTR gl_name = "xrRender_GL";
5859
LPCSTR r2_name = "xrRender_R2";
5960
LPCSTR r3_name = "xrRender_R3";
6061
LPCSTR r4_name = "xrRender_R4";
6162

63+
if (psDeviceFlags.test(rsGL))
64+
{
65+
// try to initialize GL
66+
Log("Loading DLL:", gl_name);
67+
hRender = LoadLibrary(gl_name);
68+
if (0 == hRender)
69+
{
70+
// try to load R1
71+
Msg("! ...Failed - incompatible hardware.");
72+
psDeviceFlags.set(rsR2, TRUE);
73+
}
74+
}
75+
6276
if (psDeviceFlags.test(rsR4))
6377
{
6478
// try to initialize R4
@@ -192,17 +206,20 @@ void CEngineAPI::CreateRendererList()
192206
#else
193207
// TODO: ask renderers if they are supported!
194208
if (vid_quality_token != NULL) return;
209+
bool bSupports_gl = false;
195210
bool bSupports_r2 = false;
196211
bool bSupports_r2_5 = false;
197212
bool bSupports_r3 = false;
198213
bool bSupports_r4 = false;
199214

215+
LPCSTR gl_name = "xrRender_GL";
200216
LPCSTR r2_name = "xrRender_R2";
201217
LPCSTR r3_name = "xrRender_R3";
202218
LPCSTR r4_name = "xrRender_R4";
203219

204220
if (strstr(Core.Params, "-perfhud_hack"))
205221
{
222+
bSupports_gl = true;
206223
bSupports_r2 = true;
207224
bSupports_r2_5 = true;
208225
bSupports_r3 = true;
@@ -251,6 +268,15 @@ void CEngineAPI::CreateRendererList()
251268
bSupports_r4 = test_dx11_rendering();
252269
FreeLibrary(hRender);
253270
}
271+
272+
// try to initialize GL
273+
Log("Loading DLL:", gl_name);
274+
hRender = LoadLibrary(gl_name);
275+
if (hRender)
276+
{
277+
bSupports_gl = true;
278+
FreeLibrary(hRender);
279+
}
254280
}
255281

256282
hRender = 0;
@@ -310,6 +336,10 @@ void CEngineAPI::CreateRendererList()
310336
if (bBreakLoop) break;
311337
_tmp.back() = xr_strdup(val);
312338
}
339+
340+
if (bSupports_gl)
341+
_tmp.push_back("renderer_gl");
342+
313343
u32 _cnt = _tmp.size() + 1;
314344
vid_quality_token = xr_alloc<xr_token>(_cnt);
315345

src/xrEngine/defines.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ enum
3737
rsR2 = (1ul << 19ul),
3838
rsR3 = (1ul << 20ul),
3939
rsR4 = (1ul << 21ul),
40-
// 22-32 bit - reserved to Editor
40+
rsGL = (1ul << 22ul),
41+
// 23-32 bit - reserved to Editor
4142
};
4243

4344

src/xrEngine/x_ray.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,15 @@ int APIENTRY WinMain_impl(HINSTANCE hInstance,
791791
return 0;
792792
}
793793
#ifndef DEDICATED_SERVER
794-
if (strstr(Core.Params, "-r2a"))
794+
if (strstr(Core.Params, "-gl"))
795+
Console->Execute("renderer renderer_gl");
796+
else if (strstr(Core.Params, "-r4"))
797+
Console->Execute("renderer renderer_r4");
798+
else if (strstr(Core.Params, "-r3"))
799+
Console->Execute("renderer renderer_r3");
800+
else if (strstr(Core.Params, "-r2.5"))
801+
Console->Execute("renderer renderer_r2.5");
802+
else if (strstr(Core.Params, "-r2a"))
795803
Console->Execute("renderer renderer_r2a");
796804
else if (strstr(Core.Params, "-r2"))
797805
Console->Execute("renderer renderer_r2");

0 commit comments

Comments
 (0)