Skip to content

Commit

Permalink
Return OpenGL renderer back!
Browse files Browse the repository at this point in the history
Revert "Revert "Merge pull request #103 from Armada651/opengl""
This reverts commit 5f019d8.
  • Loading branch information
Xottab-DUTY committed Jan 29, 2018
1 parent 557c156 commit d7578ee
Show file tree
Hide file tree
Showing 115 changed files with 1,779 additions and 725 deletions.
2 changes: 2 additions & 0 deletions src/Include/xrAPI/xrAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ class XRAPI_API EngineGlobalEnvironment
SupportCheck CheckR2;
SupportCheck CheckR3;
SupportCheck CheckR4;
SupportCheck CheckRGL;
SetupEnv SetupR1;
SetupEnv SetupR2;
SetupEnv SetupR3;
SetupEnv SetupR4;
SetupEnv SetupRGL;
SetupEnv SetupCurrentRenderer;
};

Expand Down
54 changes: 54 additions & 0 deletions src/Layers/xrRender/Blender_BmmD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,60 @@ void CBlender_BmmD::Compile(CBlender_Compile& C)
break;
}
}
#elif RENDER==R_GL
//////////////////////////////////////////////////////////////////////////
// GL
//////////////////////////////////////////////////////////////////////////
#include "uber_deffer.h"
void CBlender_BmmD::Compile (CBlender_Compile& C)
{
IBlender::Compile (C);
// codepath is the same, only the shaders differ
// ***only pixel shaders differ***
string256 mask;
strconcat (sizeof(mask),mask,C.L_textures[0].c_str(),"_mask");
switch(C.iElement)
{
case SE_R2_NORMAL_HQ: // deffer
uber_deffer (C, true, "impl","impl",false,oT2_Name[0]?oT2_Name:0,true);
C.r_Sampler ("s_mask", mask);
C.r_Sampler ("s_lmap", C.L_textures[1]);

C.r_Sampler ("s_dt_r", oR_Name, false, D3DTADDRESS_WRAP, D3DTEXF_ANISOTROPIC,D3DTEXF_LINEAR, D3DTEXF_ANISOTROPIC);
C.r_Sampler ("s_dt_g", oG_Name, false, D3DTADDRESS_WRAP, D3DTEXF_ANISOTROPIC,D3DTEXF_LINEAR, D3DTEXF_ANISOTROPIC);
C.r_Sampler ("s_dt_b", oB_Name, false, D3DTADDRESS_WRAP, D3DTEXF_ANISOTROPIC,D3DTEXF_LINEAR, D3DTEXF_ANISOTROPIC);
C.r_Sampler ("s_dt_a", oA_Name, false, D3DTADDRESS_WRAP, D3DTEXF_ANISOTROPIC,D3DTEXF_LINEAR, D3DTEXF_ANISOTROPIC);

C.r_Sampler ("s_dn_r", strconcat(sizeof(mask),mask,oR_Name,"_bump") );
C.r_Sampler ("s_dn_g", strconcat(sizeof(mask),mask,oG_Name,"_bump") );
C.r_Sampler ("s_dn_b", strconcat(sizeof(mask),mask,oB_Name,"_bump") );
C.r_Sampler ("s_dn_a", strconcat(sizeof(mask),mask,oA_Name,"_bump") );

C.r_Stencil ( TRUE,D3DCMP_ALWAYS,0xff,0x7f,D3DSTENCILOP_KEEP,D3DSTENCILOP_REPLACE,D3DSTENCILOP_KEEP);
C.r_StencilRef (0x01);

C.r_End ();
break;
case SE_R2_NORMAL_LQ: // deffer
uber_deffer (C, false, "base","impl",false,oT2_Name[0]?oT2_Name:0,true);

C.r_Sampler ("s_lmap", C.L_textures[1]);

C.r_Stencil ( TRUE,D3DCMP_ALWAYS,0xff,0x7f,D3DSTENCILOP_KEEP,D3DSTENCILOP_REPLACE,D3DSTENCILOP_KEEP);
C.r_StencilRef (0x01);

C.r_End ();
break;
case SE_R2_SHADOW: // smap
//if (RImplementation.o.HW_smap) C.r_Pass ("shadow_direct_base","dumb", FALSE,TRUE,TRUE,FALSE);
//else C.r_Pass ("shadow_direct_base","shadow_direct_base",FALSE);
C.r_Pass ("shadow_direct_base","dumb", FALSE,TRUE,TRUE,FALSE);
C.r_Sampler ("s_base",C.L_textures[0]);
C.r_ColorWriteEnable(false, false, false, false);
C.r_End ();
break;
}
}
#else
//////////////////////////////////////////////////////////////////////////
// R3
Expand Down
6 changes: 3 additions & 3 deletions src/Layers/xrRender/Blender_Editor_Selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void CBlender_Editor_Selection::Load(IReader& fs, u16 version)
void CBlender_Editor_Selection::Compile(CBlender_Compile& C)
{
IBlender::Compile(C);
#if !defined(USE_DX10) && !defined(USE_DX11)
#if !defined(USE_DX10) && !defined(USE_DX11) && !defined(USE_OGL)
if (C.bEditor)
{
C.PassBegin();
Expand All @@ -51,9 +51,9 @@ void CBlender_Editor_Selection::Compile(CBlender_Compile& C)
C.PassEnd();
}
else
#endif // USE_DX10
#endif // USE_DX10
{
C.r_Pass("editor", "simple_color", FALSE, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
C.r_Pass("editor", "simple_color", true, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
C.r_End();
}
}
6 changes: 3 additions & 3 deletions src/Layers/xrRender/Blender_Editor_Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void CBlender_Editor_Wire::Load(IReader& fs, u16 version)
void CBlender_Editor_Wire::Compile(CBlender_Compile& C)
{
IBlender::Compile(C);
#if !defined(USE_DX10) && !defined(USE_DX11)
#if !defined(USE_DX10) && !defined(USE_DX11) && !defined(USE_OGL)
if (C.bEditor)
{
C.PassBegin();
Expand All @@ -51,9 +51,9 @@ void CBlender_Editor_Wire::Compile(CBlender_Compile& C)
C.PassEnd();
}
else
#endif // USE_DX10
#endif // USE_DX10
{
C.r_Pass("editor", "simple_color", FALSE, TRUE, TRUE);
C.r_Pass("editor", "simple_color", false, TRUE, TRUE);
C.r_End();
}
}
2 changes: 1 addition & 1 deletion src/Layers/xrRender/Blender_Lm(EbB).cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void CBlender_LmEbB::Compile(CBlender_Compile& C)
}
}
}
#elif RENDER == R_R2
#elif RENDER == R_R2 || RENDER == R_GL
//////////////////////////////////////////////////////////////////////////
// R2
//////////////////////////////////////////////////////////////////////////
Expand Down
51 changes: 51 additions & 0 deletions src/Layers/xrRender/Blender_Model_EbB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,57 @@ void CBlender_Model_EbB::Compile(CBlender_Compile& C)
}
}
}
#elif RENDER == R_GL
#include "uber_deffer.h"
void CBlender_Model_EbB::Compile(CBlender_Compile& C)
{
IBlender::Compile(C);

if (oBlend.value)
{
// forward
LPCSTR vsname = 0;
LPCSTR psname = 0;
switch (C.iElement)
{
case 0:
case 1:
vsname = psname = "model_env_lq";
C.r_Pass(vsname, psname, TRUE, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA, TRUE, 0);
C.r_Sampler ("s_base", C.L_textures[0]);
C.r_Sampler ("s_env", oT2_Name,false,D3DTADDRESS_CLAMP);
C.r_End();
break;
}
}
else
{
// deferred
switch (C.iElement)
{
case SE_R2_NORMAL_HQ: // deffer
uber_deffer(C, true, "model", "base", false, 0, true);
C.r_Stencil(TRUE, D3DCMP_ALWAYS, 0xff, 0x7f, D3DSTENCILOP_KEEP, D3DSTENCILOP_REPLACE, D3DSTENCILOP_KEEP);
C.r_StencilRef(0x01);
C.r_End();
break;
case SE_R2_NORMAL_LQ: // deffer
uber_deffer(C, false, "model", "base", false, 0, true);
C.r_Stencil(TRUE, D3DCMP_ALWAYS, 0xff, 0x7f, D3DSTENCILOP_KEEP, D3DSTENCILOP_REPLACE, D3DSTENCILOP_KEEP);
C.r_StencilRef(0x01);
C.r_End();
break;
case SE_R2_SHADOW: // smap
//if (RImplementation.o.HW_smap) C.r_Pass ("shadow_direct_model","dumb", FALSE,TRUE,TRUE,FALSE);
//else C.r_Pass ("shadow_direct_model","shadow_direct_base",FALSE);
C.r_Pass("shadow_direct_model", "dumb", FALSE, TRUE, TRUE, FALSE);
C.r_Sampler ("s_base",C.L_textures[0]);
C.r_ColorWriteEnable(false, false, false, false);
C.r_End();
break;
}
}
}
#else
#include "uber_deffer.h"
void CBlender_Model_EbB::Compile(CBlender_Compile& C)
Expand Down
44 changes: 22 additions & 22 deletions src/Layers/xrRender/Blender_Particle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void CBlender_Particle::Compile(CBlender_Compile& C)
C.r_Sampler("s_base", C.L_textures[0], false, oClamp.value ? D3DTADDRESS_CLAMP : D3DTADDRESS_WRAP);
C.r_End();
}
#elif RENDER == R_R2
#elif RENDER == R_R2 || RENDER == R_GL
void CBlender_Particle::Compile(CBlender_Compile& C)
{
IBlender::Compile(C);
Expand Down Expand Up @@ -128,7 +128,7 @@ void CBlender_Particle::Compile(CBlender_Compile& C)
C.r_End();
break;
case SE_R2_SHADOW: // smap
// HARD or SOFT: shadow-map
// HARD or SOFT: shadow-map
switch (oBlend.IDselected)
{
case 0:
Expand Down Expand Up @@ -184,18 +184,18 @@ void CBlender_Particle::Compile(CBlender_Compile& C)
"particle", "particle", FALSE, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA, TRUE, 0);
break; // BLEND
case 2:
C.r_Pass("particle", "particle", FALSE, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE, TRUE, 0);
C.r_Pass("particle", "particle", false, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE, TRUE, 0);
break; // ADD
case 3:
C.r_Pass("particle", "particle", FALSE, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO, TRUE, 0);
C.r_Pass("particle", "particle", false, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO, TRUE, 0);
break; // MUL
case 4:
C.r_Pass("particle", "particle", FALSE, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_SRCCOLOR, TRUE, 0);
C.r_Pass("particle", "particle", false, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_SRCCOLOR, TRUE, 0);
break; // MUL_2X
case 5:
C.r_Pass("particle", "particle", FALSE, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_ONE, TRUE, 0);
C.r_Pass("particle", "particle", false, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_ONE, TRUE, 0);
break; // ALPHA-ADD
};
}
{
// C.r_Sampler ("s_base", C.L_textures[0],false,oClamp.value?D3DTADDRESS_CLAMP:D3DTADDRESS_WRAP);
C.r_dx10Texture("s_base", C.L_textures[0]);
Expand All @@ -214,45 +214,45 @@ void CBlender_Particle::Compile(CBlender_Compile& C)
switch (oBlend.IDselected)
{
case 0:
C.r_Pass("particle", "particle", FALSE, TRUE, TRUE, FALSE, D3DBLEND_ONE, D3DBLEND_ZERO, TRUE, 200);
C.r_Pass("particle", "particle", false, TRUE, TRUE, FALSE, D3DBLEND_ONE, D3DBLEND_ZERO, TRUE, 200);
C.r_ColorWriteEnable(false, false, false, false);
break; // SET
case 1:
C.r_Pass("particle-clip", "particle_s-blend", FALSE, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO,
TRUE, 0);
C.r_Pass("particle-clip", "particle_s-blend", false, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO,
TRUE, 0);
break; // BLEND
case 2:
C.r_Pass("particle-clip", "particle_s-add", FALSE, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO,
TRUE, 0);
C.r_Pass("particle-clip", "particle_s-add", false, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO,
TRUE, 0);
break; // ADD
case 3:
C.r_Pass("particle-clip", "particle_s-mul", FALSE, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO,
TRUE, 0);
C.r_Pass("particle-clip", "particle_s-mul", false, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO,
TRUE, 0);
break; // MUL
case 4:
C.r_Pass("particle-clip", "particle_s-mul", FALSE, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO,
TRUE, 0);
C.r_Pass("particle-clip", "particle_s-mul", false, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO,
TRUE, 0);
break; // MUL_2X
case 5:
C.r_Pass("particle-clip", "particle_s-aadd", FALSE, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO,
TRUE, 0);
C.r_Pass("particle-clip", "particle_s-aadd", false, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR,
D3DBLEND_ZERO, TRUE, 0);
break; // ALPHA-ADD
};
}
{
// C.r_Sampler ("s_base", C.L_textures[0],false,oClamp.value?D3DTADDRESS_CLAMP:D3DTADDRESS_WRAP);
//C.r_Sampler ("s_base", C.L_textures[0],false,oClamp.value?D3DTADDRESS_CLAMP:D3DTADDRESS_WRAP);
C.r_dx10Texture("s_base", C.L_textures[0]);
u32 hSampler = C.r_dx10Sampler("smp_base");
if (oClamp.value && (hSampler != (u32)-1))
C.i_dx10Address(hSampler, D3DTADDRESS_CLAMP);
// Igor: soft particles
// C.r_Sampler ("s_position", "$user$position");
//C.r_Sampler ("s_position", "$user$position");
C.r_dx10Texture("s_position", "$user$position");
C.r_dx10Sampler("smp_nofilter");
}
C.r_End();
break;
case 4: // deffer-EMAP
break;
};
}
}
#endif
2 changes: 1 addition & 1 deletion src/Layers/xrRender/Blender_Recorder_R2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void CBlender_Compile::r_Pass(LPCSTR _vs, LPCSTR _ps, bool bFog, BOOL bZtest, BO
SVS* vs = RImplementation.Resources->_CreateVS(_vs);
dest.ps = ps;
dest.vs = vs;
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
SGS* gs = RImplementation.Resources->_CreateGS("null");
dest.gs = gs;
#ifdef USE_DX11
Expand Down
90 changes: 89 additions & 1 deletion src/Layers/xrRender/Blender_Screen_SET.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,95 @@ void CBlender_Screen_SET::Compile(CBlender_Compile& C)
C.r_End();
}

#else // USE_DX10
#elif defined(USE_OGL)
void CBlender_Screen_SET::Compile(CBlender_Compile& C)
{
IBlender::Compile(C);
//C.r_Pass ("stub_notransform_t", "Blender_Screen_SET", false);

if (oBlend.IDselected == 6)
{
// Usually for wallmarks
C.r_Pass("stub_notransform_t", "stub_default_ma", false);

VERIFY(C.L_textures.size()>0);
C.r_Sampler("s_base", C.L_textures[0], false, D3DTADDRESS_CLAMP);
}
else
{
if (9 == oBlend.IDselected)
{
// 4x R
C.r_Pass("stub_notransform_t_m4", "stub_default", false);
//C.StageSET_Color (D3DTA_TEXTURE, D3DTOP_MODULATE4X, D3DTA_DIFFUSE);
//C.StageSET_Alpha (D3DTA_TEXTURE, D3DTOP_SELECTARG1, D3DTA_DIFFUSE);
}
else
{
if ((7 == oBlend.IDselected) || (8 == oBlend.IDselected))
{
// 2x R
C.r_Pass("stub_notransform_t_m2", "stub_default", false);
//C.StageSET_Color (D3DTA_TEXTURE, D3DTOP_MODULATE2X, D3DTA_DIFFUSE);
//C.StageSET_Alpha (D3DTA_TEXTURE, D3DTOP_SELECTARG1, D3DTA_DIFFUSE);
}
else
{
// 1x R
C.r_Pass("stub_notransform_t", "stub_default", false);
//C.StageSET_Color (D3DTA_TEXTURE, D3DTOP_MODULATE, D3DTA_DIFFUSE);
//C.StageSET_Alpha (D3DTA_TEXTURE, D3DTOP_MODULATE, D3DTA_DIFFUSE);
}
}
//C.Stage_Texture (oT_Name);
//C.Stage_Matrix (oT_xform, 0);
//C.Stage_Constant ("$null");
//C.StageEnd ();
VERIFY(C.L_textures.size()>0);
C.r_Sampler("s_base", C.L_textures[0], false, D3DTADDRESS_CLAMP);
}

C.PassSET_ZB(oZTest.value, oZWrite.value);

switch (oBlend.IDselected)
{
case 0: // SET
C.PassSET_Blend(FALSE, D3DBLEND_ONE, D3DBLEND_ZERO, FALSE, 0);
break;
case 1: // BLEND
C.PassSET_Blend(TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA, TRUE, oAREF.value);
break;
case 2: // ADD
C.PassSET_Blend(TRUE, D3DBLEND_ONE, D3DBLEND_ONE, FALSE, oAREF.value);
break;
case 3: // MUL
C.PassSET_Blend(TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO, FALSE, oAREF.value);
break;
case 4: // MUL_2X
C.PassSET_Blend(TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_SRCCOLOR, FALSE, oAREF.value);
break;
case 5: // ALPHA-ADD
C.PassSET_Blend(TRUE, D3DBLEND_SRCALPHA, D3DBLEND_ONE, TRUE, oAREF.value);
break;
case 6: // MUL_2X + A-test
C.PassSET_Blend(TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_SRCCOLOR, FALSE, oAREF.value);
break;
case 7: // SET (2r)
C.PassSET_Blend(TRUE, D3DBLEND_ONE, D3DBLEND_ZERO, TRUE, 0);
break;
case 8: // BLEND (2r)
C.PassSET_Blend(TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA, TRUE, oAREF.value);
break;
case 9: // BLEND (2r)
C.PassSET_Blend(TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA, TRUE, oAREF.value);
break;
}
C.PassSET_LightFog(oLighting.value, oFog.value);

C.r_End();
}

#else // USE_DX10

void CBlender_Screen_SET::Compile(CBlender_Compile& C)
{
Expand Down
Loading

0 comments on commit d7578ee

Please sign in to comment.