Skip to content

Commit

Permalink
xrEngine: Add OpenGL support.
Browse files Browse the repository at this point in the history
  • Loading branch information
CrossVR committed Nov 22, 2015
1 parent 29e38f5 commit 18be63b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
30 changes: 30 additions & 0 deletions src/xrEngine/EngineAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,24 @@ bool is_enough_address_space_available()

void CEngineAPI::InitializeNotDedicated()
{
LPCSTR gl_name = "xrRender_GL";
LPCSTR r2_name = "xrRender_R2";
LPCSTR r3_name = "xrRender_R3";
LPCSTR r4_name = "xrRender_R4";

if (psDeviceFlags.test(rsGL))
{
// try to initialize GL
Log("Loading DLL:", gl_name);
hRender = LoadLibrary(gl_name);
if (0 == hRender)
{
// try to load R1
Msg("! ...Failed - incompatible hardware.");
psDeviceFlags.set(rsR2, TRUE);
}
}

if (psDeviceFlags.test(rsR4))
{
// try to initialize R4
Expand Down Expand Up @@ -192,17 +206,20 @@ void CEngineAPI::CreateRendererList()
#else
// TODO: ask renderers if they are supported!
if (vid_quality_token != NULL) return;
bool bSupports_gl = false;
bool bSupports_r2 = false;
bool bSupports_r2_5 = false;
bool bSupports_r3 = false;
bool bSupports_r4 = false;

LPCSTR gl_name = "xrRender_GL";
LPCSTR r2_name = "xrRender_R2";
LPCSTR r3_name = "xrRender_R3";
LPCSTR r4_name = "xrRender_R4";

if (strstr(Core.Params, "-perfhud_hack"))
{
bSupports_gl = true;
bSupports_r2 = true;
bSupports_r2_5 = true;
bSupports_r3 = true;
Expand Down Expand Up @@ -251,6 +268,15 @@ void CEngineAPI::CreateRendererList()
bSupports_r4 = test_dx11_rendering();
FreeLibrary(hRender);
}

// try to initialize GL
Log("Loading DLL:", gl_name);
hRender = LoadLibrary(gl_name);
if (hRender)
{
bSupports_gl = true;
FreeLibrary(hRender);
}
}

hRender = 0;
Expand Down Expand Up @@ -310,6 +336,10 @@ void CEngineAPI::CreateRendererList()
if (bBreakLoop) break;
_tmp.back() = xr_strdup(val);
}

if (bSupports_gl)
_tmp.push_back("renderer_gl");

u32 _cnt = _tmp.size() + 1;
vid_quality_token = xr_alloc<xr_token>(_cnt);

Expand Down
3 changes: 2 additions & 1 deletion src/xrEngine/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ enum
rsR2 = (1ul << 19ul),
rsR3 = (1ul << 20ul),
rsR4 = (1ul << 21ul),
// 22-32 bit - reserved to Editor
rsGL = (1ul << 22ul),
// 23-32 bit - reserved to Editor
};


Expand Down
10 changes: 9 additions & 1 deletion src/xrEngine/x_ray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,15 @@ int APIENTRY WinMain_impl(HINSTANCE hInstance,
return 0;
}
#ifndef DEDICATED_SERVER
if (strstr(Core.Params, "-r2a"))
if (strstr(Core.Params, "-gl"))
Console->Execute("renderer renderer_gl");
else if (strstr(Core.Params, "-r4"))
Console->Execute("renderer renderer_r4");
else if (strstr(Core.Params, "-r3"))
Console->Execute("renderer renderer_r3");
else if (strstr(Core.Params, "-r2.5"))
Console->Execute("renderer renderer_r2.5");
else if (strstr(Core.Params, "-r2a"))
Console->Execute("renderer renderer_r2a");
else if (strstr(Core.Params, "-r2"))
Console->Execute("renderer renderer_r2");
Expand Down

0 comments on commit 18be63b

Please sign in to comment.