Skip to content

Commit d7578ee

Browse files
committed
Return OpenGL renderer back!
Revert "Revert "Merge pull request #103 from Armada651/opengl"" This reverts commit 5f019d8.
1 parent 557c156 commit d7578ee

File tree

115 files changed

+1779
-725
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+1779
-725
lines changed

src/Include/xrAPI/xrAPI.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ class XRAPI_API EngineGlobalEnvironment
3535
SupportCheck CheckR2;
3636
SupportCheck CheckR3;
3737
SupportCheck CheckR4;
38+
SupportCheck CheckRGL;
3839
SetupEnv SetupR1;
3940
SetupEnv SetupR2;
4041
SetupEnv SetupR3;
4142
SetupEnv SetupR4;
43+
SetupEnv SetupRGL;
4244
SetupEnv SetupCurrentRenderer;
4345
};
4446

src/Layers/xrRender/Blender_BmmD.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,60 @@ void CBlender_BmmD::Compile(CBlender_Compile& C)
182182
break;
183183
}
184184
}
185+
#elif RENDER==R_GL
186+
//////////////////////////////////////////////////////////////////////////
187+
// GL
188+
//////////////////////////////////////////////////////////////////////////
189+
#include "uber_deffer.h"
190+
void CBlender_BmmD::Compile (CBlender_Compile& C)
191+
{
192+
IBlender::Compile (C);
193+
// codepath is the same, only the shaders differ
194+
// ***only pixel shaders differ***
195+
string256 mask;
196+
strconcat (sizeof(mask),mask,C.L_textures[0].c_str(),"_mask");
197+
switch(C.iElement)
198+
{
199+
case SE_R2_NORMAL_HQ: // deffer
200+
uber_deffer (C, true, "impl","impl",false,oT2_Name[0]?oT2_Name:0,true);
201+
C.r_Sampler ("s_mask", mask);
202+
C.r_Sampler ("s_lmap", C.L_textures[1]);
203+
204+
C.r_Sampler ("s_dt_r", oR_Name, false, D3DTADDRESS_WRAP, D3DTEXF_ANISOTROPIC,D3DTEXF_LINEAR, D3DTEXF_ANISOTROPIC);
205+
C.r_Sampler ("s_dt_g", oG_Name, false, D3DTADDRESS_WRAP, D3DTEXF_ANISOTROPIC,D3DTEXF_LINEAR, D3DTEXF_ANISOTROPIC);
206+
C.r_Sampler ("s_dt_b", oB_Name, false, D3DTADDRESS_WRAP, D3DTEXF_ANISOTROPIC,D3DTEXF_LINEAR, D3DTEXF_ANISOTROPIC);
207+
C.r_Sampler ("s_dt_a", oA_Name, false, D3DTADDRESS_WRAP, D3DTEXF_ANISOTROPIC,D3DTEXF_LINEAR, D3DTEXF_ANISOTROPIC);
208+
209+
C.r_Sampler ("s_dn_r", strconcat(sizeof(mask),mask,oR_Name,"_bump") );
210+
C.r_Sampler ("s_dn_g", strconcat(sizeof(mask),mask,oG_Name,"_bump") );
211+
C.r_Sampler ("s_dn_b", strconcat(sizeof(mask),mask,oB_Name,"_bump") );
212+
C.r_Sampler ("s_dn_a", strconcat(sizeof(mask),mask,oA_Name,"_bump") );
213+
214+
C.r_Stencil ( TRUE,D3DCMP_ALWAYS,0xff,0x7f,D3DSTENCILOP_KEEP,D3DSTENCILOP_REPLACE,D3DSTENCILOP_KEEP);
215+
C.r_StencilRef (0x01);
216+
217+
C.r_End ();
218+
break;
219+
case SE_R2_NORMAL_LQ: // deffer
220+
uber_deffer (C, false, "base","impl",false,oT2_Name[0]?oT2_Name:0,true);
221+
222+
C.r_Sampler ("s_lmap", C.L_textures[1]);
223+
224+
C.r_Stencil ( TRUE,D3DCMP_ALWAYS,0xff,0x7f,D3DSTENCILOP_KEEP,D3DSTENCILOP_REPLACE,D3DSTENCILOP_KEEP);
225+
C.r_StencilRef (0x01);
226+
227+
C.r_End ();
228+
break;
229+
case SE_R2_SHADOW: // smap
230+
//if (RImplementation.o.HW_smap) C.r_Pass ("shadow_direct_base","dumb", FALSE,TRUE,TRUE,FALSE);
231+
//else C.r_Pass ("shadow_direct_base","shadow_direct_base",FALSE);
232+
C.r_Pass ("shadow_direct_base","dumb", FALSE,TRUE,TRUE,FALSE);
233+
C.r_Sampler ("s_base",C.L_textures[0]);
234+
C.r_ColorWriteEnable(false, false, false, false);
235+
C.r_End ();
236+
break;
237+
}
238+
}
185239
#else
186240
//////////////////////////////////////////////////////////////////////////
187241
// R3

src/Layers/xrRender/Blender_Editor_Selection.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void CBlender_Editor_Selection::Load(IReader& fs, u16 version)
2929
void CBlender_Editor_Selection::Compile(CBlender_Compile& C)
3030
{
3131
IBlender::Compile(C);
32-
#if !defined(USE_DX10) && !defined(USE_DX11)
32+
#if !defined(USE_DX10) && !defined(USE_DX11) && !defined(USE_OGL)
3333
if (C.bEditor)
3434
{
3535
C.PassBegin();
@@ -51,9 +51,9 @@ void CBlender_Editor_Selection::Compile(CBlender_Compile& C)
5151
C.PassEnd();
5252
}
5353
else
54-
#endif // USE_DX10
54+
#endif // USE_DX10
5555
{
56-
C.r_Pass("editor", "simple_color", FALSE, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
56+
C.r_Pass("editor", "simple_color", true, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
5757
C.r_End();
5858
}
5959
}

src/Layers/xrRender/Blender_Editor_Wire.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void CBlender_Editor_Wire::Load(IReader& fs, u16 version)
2929
void CBlender_Editor_Wire::Compile(CBlender_Compile& C)
3030
{
3131
IBlender::Compile(C);
32-
#if !defined(USE_DX10) && !defined(USE_DX11)
32+
#if !defined(USE_DX10) && !defined(USE_DX11) && !defined(USE_OGL)
3333
if (C.bEditor)
3434
{
3535
C.PassBegin();
@@ -51,9 +51,9 @@ void CBlender_Editor_Wire::Compile(CBlender_Compile& C)
5151
C.PassEnd();
5252
}
5353
else
54-
#endif // USE_DX10
54+
#endif // USE_DX10
5555
{
56-
C.r_Pass("editor", "simple_color", FALSE, TRUE, TRUE);
56+
C.r_Pass("editor", "simple_color", false, TRUE, TRUE);
5757
C.r_End();
5858
}
5959
}

src/Layers/xrRender/Blender_Lm(EbB).cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void CBlender_LmEbB::Compile(CBlender_Compile& C)
143143
}
144144
}
145145
}
146-
#elif RENDER == R_R2
146+
#elif RENDER == R_R2 || RENDER == R_GL
147147
//////////////////////////////////////////////////////////////////////////
148148
// R2
149149
//////////////////////////////////////////////////////////////////////////

src/Layers/xrRender/Blender_Model_EbB.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,57 @@ void CBlender_Model_EbB::Compile(CBlender_Compile& C)
188188
}
189189
}
190190
}
191+
#elif RENDER == R_GL
192+
#include "uber_deffer.h"
193+
void CBlender_Model_EbB::Compile(CBlender_Compile& C)
194+
{
195+
IBlender::Compile(C);
196+
197+
if (oBlend.value)
198+
{
199+
// forward
200+
LPCSTR vsname = 0;
201+
LPCSTR psname = 0;
202+
switch (C.iElement)
203+
{
204+
case 0:
205+
case 1:
206+
vsname = psname = "model_env_lq";
207+
C.r_Pass(vsname, psname, TRUE, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA, TRUE, 0);
208+
C.r_Sampler ("s_base", C.L_textures[0]);
209+
C.r_Sampler ("s_env", oT2_Name,false,D3DTADDRESS_CLAMP);
210+
C.r_End();
211+
break;
212+
}
213+
}
214+
else
215+
{
216+
// deferred
217+
switch (C.iElement)
218+
{
219+
case SE_R2_NORMAL_HQ: // deffer
220+
uber_deffer(C, true, "model", "base", false, 0, true);
221+
C.r_Stencil(TRUE, D3DCMP_ALWAYS, 0xff, 0x7f, D3DSTENCILOP_KEEP, D3DSTENCILOP_REPLACE, D3DSTENCILOP_KEEP);
222+
C.r_StencilRef(0x01);
223+
C.r_End();
224+
break;
225+
case SE_R2_NORMAL_LQ: // deffer
226+
uber_deffer(C, false, "model", "base", false, 0, true);
227+
C.r_Stencil(TRUE, D3DCMP_ALWAYS, 0xff, 0x7f, D3DSTENCILOP_KEEP, D3DSTENCILOP_REPLACE, D3DSTENCILOP_KEEP);
228+
C.r_StencilRef(0x01);
229+
C.r_End();
230+
break;
231+
case SE_R2_SHADOW: // smap
232+
//if (RImplementation.o.HW_smap) C.r_Pass ("shadow_direct_model","dumb", FALSE,TRUE,TRUE,FALSE);
233+
//else C.r_Pass ("shadow_direct_model","shadow_direct_base",FALSE);
234+
C.r_Pass("shadow_direct_model", "dumb", FALSE, TRUE, TRUE, FALSE);
235+
C.r_Sampler ("s_base",C.L_textures[0]);
236+
C.r_ColorWriteEnable(false, false, false, false);
237+
C.r_End();
238+
break;
239+
}
240+
}
241+
}
191242
#else
192243
#include "uber_deffer.h"
193244
void CBlender_Model_EbB::Compile(CBlender_Compile& C)

src/Layers/xrRender/Blender_Particle.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void CBlender_Particle::Compile(CBlender_Compile& C)
9191
C.r_Sampler("s_base", C.L_textures[0], false, oClamp.value ? D3DTADDRESS_CLAMP : D3DTADDRESS_WRAP);
9292
C.r_End();
9393
}
94-
#elif RENDER == R_R2
94+
#elif RENDER == R_R2 || RENDER == R_GL
9595
void CBlender_Particle::Compile(CBlender_Compile& C)
9696
{
9797
IBlender::Compile(C);
@@ -128,7 +128,7 @@ void CBlender_Particle::Compile(CBlender_Compile& C)
128128
C.r_End();
129129
break;
130130
case SE_R2_SHADOW: // smap
131-
// HARD or SOFT: shadow-map
131+
// HARD or SOFT: shadow-map
132132
switch (oBlend.IDselected)
133133
{
134134
case 0:
@@ -184,18 +184,18 @@ void CBlender_Particle::Compile(CBlender_Compile& C)
184184
"particle", "particle", FALSE, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA, TRUE, 0);
185185
break; // BLEND
186186
case 2:
187-
C.r_Pass("particle", "particle", FALSE, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE, TRUE, 0);
187+
C.r_Pass("particle", "particle", false, TRUE, FALSE, TRUE, D3DBLEND_ONE, D3DBLEND_ONE, TRUE, 0);
188188
break; // ADD
189189
case 3:
190-
C.r_Pass("particle", "particle", FALSE, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO, TRUE, 0);
190+
C.r_Pass("particle", "particle", false, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO, TRUE, 0);
191191
break; // MUL
192192
case 4:
193-
C.r_Pass("particle", "particle", FALSE, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_SRCCOLOR, TRUE, 0);
193+
C.r_Pass("particle", "particle", false, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_SRCCOLOR, TRUE, 0);
194194
break; // MUL_2X
195195
case 5:
196-
C.r_Pass("particle", "particle", FALSE, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_ONE, TRUE, 0);
196+
C.r_Pass("particle", "particle", false, TRUE, FALSE, TRUE, D3DBLEND_SRCALPHA, D3DBLEND_ONE, TRUE, 0);
197197
break; // ALPHA-ADD
198-
};
198+
}
199199
{
200200
// C.r_Sampler ("s_base", C.L_textures[0],false,oClamp.value?D3DTADDRESS_CLAMP:D3DTADDRESS_WRAP);
201201
C.r_dx10Texture("s_base", C.L_textures[0]);
@@ -214,45 +214,45 @@ void CBlender_Particle::Compile(CBlender_Compile& C)
214214
switch (oBlend.IDselected)
215215
{
216216
case 0:
217-
C.r_Pass("particle", "particle", FALSE, TRUE, TRUE, FALSE, D3DBLEND_ONE, D3DBLEND_ZERO, TRUE, 200);
217+
C.r_Pass("particle", "particle", false, TRUE, TRUE, FALSE, D3DBLEND_ONE, D3DBLEND_ZERO, TRUE, 200);
218218
C.r_ColorWriteEnable(false, false, false, false);
219219
break; // SET
220220
case 1:
221-
C.r_Pass("particle-clip", "particle_s-blend", FALSE, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO,
222-
TRUE, 0);
221+
C.r_Pass("particle-clip", "particle_s-blend", false, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO,
222+
TRUE, 0);
223223
break; // BLEND
224224
case 2:
225-
C.r_Pass("particle-clip", "particle_s-add", FALSE, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO,
226-
TRUE, 0);
225+
C.r_Pass("particle-clip", "particle_s-add", false, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO,
226+
TRUE, 0);
227227
break; // ADD
228228
case 3:
229-
C.r_Pass("particle-clip", "particle_s-mul", FALSE, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO,
230-
TRUE, 0);
229+
C.r_Pass("particle-clip", "particle_s-mul", false, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO,
230+
TRUE, 0);
231231
break; // MUL
232232
case 4:
233-
C.r_Pass("particle-clip", "particle_s-mul", FALSE, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO,
234-
TRUE, 0);
233+
C.r_Pass("particle-clip", "particle_s-mul", false, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO,
234+
TRUE, 0);
235235
break; // MUL_2X
236236
case 5:
237-
C.r_Pass("particle-clip", "particle_s-aadd", FALSE, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO,
238-
TRUE, 0);
237+
C.r_Pass("particle-clip", "particle_s-aadd", false, TRUE, FALSE, TRUE, D3DBLEND_DESTCOLOR,
238+
D3DBLEND_ZERO, TRUE, 0);
239239
break; // ALPHA-ADD
240-
};
240+
}
241241
{
242-
// C.r_Sampler ("s_base", C.L_textures[0],false,oClamp.value?D3DTADDRESS_CLAMP:D3DTADDRESS_WRAP);
242+
//C.r_Sampler ("s_base", C.L_textures[0],false,oClamp.value?D3DTADDRESS_CLAMP:D3DTADDRESS_WRAP);
243243
C.r_dx10Texture("s_base", C.L_textures[0]);
244244
u32 hSampler = C.r_dx10Sampler("smp_base");
245245
if (oClamp.value && (hSampler != (u32)-1))
246246
C.i_dx10Address(hSampler, D3DTADDRESS_CLAMP);
247247
// Igor: soft particles
248-
// C.r_Sampler ("s_position", "$user$position");
248+
//C.r_Sampler ("s_position", "$user$position");
249249
C.r_dx10Texture("s_position", "$user$position");
250250
C.r_dx10Sampler("smp_nofilter");
251251
}
252252
C.r_End();
253253
break;
254254
case 4: // deffer-EMAP
255255
break;
256-
};
256+
}
257257
}
258258
#endif

src/Layers/xrRender/Blender_Recorder_R2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void CBlender_Compile::r_Pass(LPCSTR _vs, LPCSTR _ps, bool bFog, BOOL bZtest, BO
2727
SVS* vs = RImplementation.Resources->_CreateVS(_vs);
2828
dest.ps = ps;
2929
dest.vs = vs;
30-
#if defined(USE_DX10) || defined(USE_DX11)
30+
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
3131
SGS* gs = RImplementation.Resources->_CreateGS("null");
3232
dest.gs = gs;
3333
#ifdef USE_DX11

src/Layers/xrRender/Blender_Screen_SET.cpp

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,95 @@ void CBlender_Screen_SET::Compile(CBlender_Compile& C)
208208
C.r_End();
209209
}
210210

211-
#else // USE_DX10
211+
#elif defined(USE_OGL)
212+
void CBlender_Screen_SET::Compile(CBlender_Compile& C)
213+
{
214+
IBlender::Compile(C);
215+
//C.r_Pass ("stub_notransform_t", "Blender_Screen_SET", false);
216+
217+
if (oBlend.IDselected == 6)
218+
{
219+
// Usually for wallmarks
220+
C.r_Pass("stub_notransform_t", "stub_default_ma", false);
221+
222+
VERIFY(C.L_textures.size()>0);
223+
C.r_Sampler("s_base", C.L_textures[0], false, D3DTADDRESS_CLAMP);
224+
}
225+
else
226+
{
227+
if (9 == oBlend.IDselected)
228+
{
229+
// 4x R
230+
C.r_Pass("stub_notransform_t_m4", "stub_default", false);
231+
//C.StageSET_Color (D3DTA_TEXTURE, D3DTOP_MODULATE4X, D3DTA_DIFFUSE);
232+
//C.StageSET_Alpha (D3DTA_TEXTURE, D3DTOP_SELECTARG1, D3DTA_DIFFUSE);
233+
}
234+
else
235+
{
236+
if ((7 == oBlend.IDselected) || (8 == oBlend.IDselected))
237+
{
238+
// 2x R
239+
C.r_Pass("stub_notransform_t_m2", "stub_default", false);
240+
//C.StageSET_Color (D3DTA_TEXTURE, D3DTOP_MODULATE2X, D3DTA_DIFFUSE);
241+
//C.StageSET_Alpha (D3DTA_TEXTURE, D3DTOP_SELECTARG1, D3DTA_DIFFUSE);
242+
}
243+
else
244+
{
245+
// 1x R
246+
C.r_Pass("stub_notransform_t", "stub_default", false);
247+
//C.StageSET_Color (D3DTA_TEXTURE, D3DTOP_MODULATE, D3DTA_DIFFUSE);
248+
//C.StageSET_Alpha (D3DTA_TEXTURE, D3DTOP_MODULATE, D3DTA_DIFFUSE);
249+
}
250+
}
251+
//C.Stage_Texture (oT_Name);
252+
//C.Stage_Matrix (oT_xform, 0);
253+
//C.Stage_Constant ("$null");
254+
//C.StageEnd ();
255+
VERIFY(C.L_textures.size()>0);
256+
C.r_Sampler("s_base", C.L_textures[0], false, D3DTADDRESS_CLAMP);
257+
}
258+
259+
C.PassSET_ZB(oZTest.value, oZWrite.value);
260+
261+
switch (oBlend.IDselected)
262+
{
263+
case 0: // SET
264+
C.PassSET_Blend(FALSE, D3DBLEND_ONE, D3DBLEND_ZERO, FALSE, 0);
265+
break;
266+
case 1: // BLEND
267+
C.PassSET_Blend(TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA, TRUE, oAREF.value);
268+
break;
269+
case 2: // ADD
270+
C.PassSET_Blend(TRUE, D3DBLEND_ONE, D3DBLEND_ONE, FALSE, oAREF.value);
271+
break;
272+
case 3: // MUL
273+
C.PassSET_Blend(TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_ZERO, FALSE, oAREF.value);
274+
break;
275+
case 4: // MUL_2X
276+
C.PassSET_Blend(TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_SRCCOLOR, FALSE, oAREF.value);
277+
break;
278+
case 5: // ALPHA-ADD
279+
C.PassSET_Blend(TRUE, D3DBLEND_SRCALPHA, D3DBLEND_ONE, TRUE, oAREF.value);
280+
break;
281+
case 6: // MUL_2X + A-test
282+
C.PassSET_Blend(TRUE, D3DBLEND_DESTCOLOR, D3DBLEND_SRCCOLOR, FALSE, oAREF.value);
283+
break;
284+
case 7: // SET (2r)
285+
C.PassSET_Blend(TRUE, D3DBLEND_ONE, D3DBLEND_ZERO, TRUE, 0);
286+
break;
287+
case 8: // BLEND (2r)
288+
C.PassSET_Blend(TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA, TRUE, oAREF.value);
289+
break;
290+
case 9: // BLEND (2r)
291+
C.PassSET_Blend(TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA, TRUE, oAREF.value);
292+
break;
293+
}
294+
C.PassSET_LightFog(oLighting.value, oFog.value);
295+
296+
C.r_End();
297+
}
298+
299+
#else // USE_DX10
212300

213301
void CBlender_Screen_SET::Compile(CBlender_Compile& C)
214302
{

0 commit comments

Comments
 (0)