Skip to content

Commit bd458c0

Browse files
committed
- More r_dynamiclight options:
r_dynamiclight 2 = Slightly additive dynamic light projections, modeled after the PS2 port r_dynamiclight 3 = disables dynamic light projections but substitutes them with flashblends (ala GLQuake). If r_monolightmaps are enabled, the flashblends are orange. Viewblends are left out as the sudden duration of the dynamic lights when firing would be harmful. - Because of these changes, Riva 128 and Permedia 2 owners should be allowed to enjoy dynamic lights - option to use ReactOS's wspiapi.h header (file not included) - some makefile changes to allow an option for more Win 4 (95/NT4) compatiblity easier. Compiling with WINFOUR disables curl, uses SDL1, and has some additional workarounds to get it working on Windows 95 (winsock2 still required though)
1 parent 8b7378a commit bd458c0

File tree

11 files changed

+186
-11
lines changed

11 files changed

+186
-11
lines changed

Makefile

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,14 @@ ifndef USE_LOCAL_HEADERS
228228
USE_LOCAL_HEADERS=1
229229
endif
230230

231+
ifndef WINFOUR
232+
WINFOUR=0
233+
endif
234+
235+
ifndef USE_REACTOS_WINSOCK_HEADER
236+
USE_REACTOS_WINSOCK_HEADER=0
237+
endif
238+
231239
ifndef USE_RENDERER_DLOPEN
232240
USE_RENDERER_DLOPEN=1
233241
endif
@@ -244,6 +252,15 @@ ifndef SDL_VERSION
244252
SDL_VERSION=2
245253
endif
246254

255+
ifeq ($(WINFOUR),1)
256+
BASE_CFLAGS += -DWINFOUR
257+
BASE_CFLAGS += -DUSE_REACTOS_WINSOCK_HEADER
258+
BASE_CFLAGS += -DUSE_INTERNAL_JPEG
259+
SDL_VERSION=1
260+
USE_CURL=0
261+
CLIENTBIN=oa95
262+
endif
263+
247264
#############################################################################
248265

249266
BD=$(BUILD_DIR)/debug-$(PLATFORM)-$(ARCH)
@@ -1141,6 +1158,10 @@ ifeq ($(USE_LOCAL_HEADERS),1)
11411158
BASE_CFLAGS += -DUSE_LOCAL_HEADERS
11421159
endif
11431160

1161+
ifeq ($(USE_REACTOS_WINSOCK_HEADER),1)
1162+
BASE_CFLAGS += -DUSE_REACTOS_WINSOCK_HEADER
1163+
endif
1164+
11441165
ifeq ($(BUILD_STANDALONE),1)
11451166
BASE_CFLAGS += -DSTANDALONE
11461167
endif
@@ -3020,8 +3041,8 @@ else
30203041
@$(MAKE) VERSION=$(VERSION) -C $(LOKISETUPDIR) V=$(V)
30213042
endif
30223043

3023-
dist:
3024-
git archive --format zip --output $(CLIENTBIN)-$(VERSION).zip HEAD
3044+
# dist:
3045+
# git archive --format zip --output $(CLIENTBIN)-$(VERSION).zip HEAD
30253046

30263047
#############################################################################
30273048
# DEPENDENCIES

Makefile.OpenArena

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ BUILD_CLIENT=1
1010
BUILD_SERVER=1
1111
BUILD_GAME_SO=0
1212
BUILD_GAME_QVM=0
13+
USE_GIT=0
1314
BUILD_BASEGAME=0
1415
BUILD_MISSIONPACK=0
1516
BASEGAME=baseoa
1617
# VERSION=1.36+0.8.8
17-
VERSION=3.0.0a
18+
VERSION=TEST
19+
1820

1921
# OpenArena doesn't use opus yet
2022
USE_CODEC_VORBIS=1
@@ -24,13 +26,17 @@ ifndef USE_CODEC_XMP
2426
USE_CODEC_XMP=1
2527
endif
2628

29+
USE_CURL=1
30+
2731
# FLTO Test
2832

2933
OPTIMIZE += -flto
3034

31-
# This doesn't work with OpenArena yet
35+
# Not supported
3236
BUILD_RENDERER_OPENGL2=0
3337
# You can disable the renderer libraries and build in the OA renderer by default
38+
# This is disabled because we have some client builtins used (trace etc) and
39+
# we are scaling back some modularization for security and support reasons.
3440
USE_RENDERER_DLOPEN=0
3541

3642
# Choose version 1 or 2
@@ -58,6 +64,12 @@ CLIENTBIN=openarena
5864
SERVERBIN=oa_ded
5965
COPYDIR=/usr/local/games/openarena
6066

67+
# Use the Winsock2 headers from ReactOS, which doesn't give errors in Win9x
68+
# USE_REACTOS_WINSOCK_HEADER=1
69+
70+
# Enable changes to allow Windows 95 and NT4 to work
71+
# (Overrides enabling libraries above that don't work well, and outputs to oa95.exe)
72+
WINFOUR=0
6173

6274
# DEBUG_CFLAGS=-ggdb -O0
6375

code/qcommon/net_ip.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2727
# include <winsock2.h>
2828
# include <ws2tcpip.h>
2929
# if WINVER < 0x501
30+
3031
# ifdef __MINGW32__
3132
// wspiapi.h isn't available on MinGW, so if it's
3233
// present it's because the end user has added it
@@ -37,6 +38,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3738
# endif
3839
# else
3940
# include <ws2spi.h>
41+
# endif
42+
43+
// leilei - addition to fix win9x
44+
# ifdef USE_REACTOS_WINSOCK_HEADER
45+
# include "../reactos/wspiapi.h"
4046
# endif
4147

4248
typedef int socklen_t;

code/reactos/readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Place ReactOS' wspiapi.h file here.
2+

code/renderer_oa/tr_backend.c

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,95 @@ void RB_BeginDrawingView (void) {
849849

850850
#define MAC_EVENT_PUMP_MSEC 5
851851

852+
853+
/*
854+
===================
855+
R_RenderFlashblend
856+
857+
leilei - GLQuake RenderDlights
858+
Renders the classic GLQuake flashblend cone to subsitute dynamic lights. May be
859+
a little redundant with r_flaresDlight
860+
===================
861+
*/
862+
static void R_RenderFlashblend (dlight_t *light)
863+
{
864+
int i, j;
865+
float a;
866+
vec3_t v, vv;
867+
float rad;
868+
vec3_t vup, vpn, vright;
869+
vec3_t point;
870+
float ofs = 1;
871+
872+
if ( (backEnd.refdef.rdflags & RDF_NOWORLDMODEL)) return; // leilei - don't draw flashblends in the UI
873+
874+
VectorCopy( backEnd.refdef.viewaxis[0], vpn );
875+
VectorCopy( backEnd.refdef.viewaxis[1], vright );
876+
VectorCopy( backEnd.refdef.viewaxis[2], vup );
877+
878+
879+
rad = light->radius * 0.35f;
880+
881+
for (int qj=0 ; qj<3 ; qj++)
882+
v[qj] = light->origin[qj];
883+
884+
VectorSubtract (light->origin, backEnd.or.viewOrigin, vv);
885+
886+
RB_BeginSurface( tr.coneShader, tess.fogNum );
887+
888+
for (i=0 ; i<3 ; i++)
889+
tess.xyz[tess.numVertexes][i] = light->origin[i] - (vpn[i]*(rad*(ofs*.75)));
890+
tess.vertexColors[tess.numVertexes][0] = light->color[0] * 64;
891+
tess.vertexColors[tess.numVertexes][1] = light->color[1] * 64;
892+
tess.vertexColors[tess.numVertexes][2] = light->color[2] * 64;
893+
894+
// glquake's colors kick in if monolightmaps
895+
if (r_monolightmaps->integer){
896+
tess.vertexColors[tess.numVertexes][0] = 0.3 * 255;
897+
tess.vertexColors[tess.numVertexes][1] = 0.2 * 255;
898+
tess.vertexColors[tess.numVertexes][2] = 0.0 * 255;
899+
}
900+
tess.vertexColors[tess.numVertexes][3] = 255;
901+
tess.numVertexes++;
902+
903+
for (int qi=0 ; qi<(17) ; qi++)
904+
{
905+
a = qi/(float)(16) * M_PI*2;
906+
for (int qj=0 ; qj<3 ; qj++)
907+
point[qj] = v[qj] + vright[qj]*cos(a)*rad + vup[qj]*sin(a)*rad;
908+
VectorCopy (point, tess.xyz[tess.numVertexes] );
909+
tess.vertexColors[tess.numVertexes][0] = 0;
910+
tess.vertexColors[tess.numVertexes][1] = 0;
911+
tess.vertexColors[tess.numVertexes][2] = 0;
912+
tess.vertexColors[tess.numVertexes][3] = 0;
913+
tess.indexes[tess.numIndexes++] = 0;
914+
tess.indexes[tess.numIndexes++] = qi;
915+
tess.indexes[tess.numIndexes++] = qi+1;
916+
tess.numVertexes++;
917+
}
918+
RB_EndSurface();
919+
920+
}
921+
922+
923+
// leilei - go through the active dlights, and then draw them
924+
static void RB_RenderFlashblends() {
925+
int l;
926+
int i;
927+
if ( !backEnd.refdef.num_dlights ) {
928+
return;
929+
}
930+
l = backEnd.refdef.dlights;
931+
932+
for (i=0 ; i<backEnd.refdef.num_dlights ; i++, l++) {
933+
dlight_t *dl = &backEnd.refdef.dlights[i];
934+
935+
if (dl->additive == 2)
936+
R_RenderFlashblend(dl); // this is definitely flashblend.
937+
}
938+
939+
};
940+
852941
/*
853942
==================
854943
RB_RenderDrawSurfList
@@ -1038,6 +1127,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
10381127
// add the particles
10391128
//R_AddParticles ();
10401129
R_RenderParticles ();
1130+
RB_RenderFlashblends();
10411131

10421132
// add light flares on lights that aren't obscured
10431133
RB_RenderFlares();

code/renderer_oa/tr_local.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,8 @@ typedef struct {
11531153
shader_t *flareShaderAtlas; // leilei - lens reflections
11541154
shader_t *sunShader;
11551155

1156+
shader_t *coneShader; // leilei - flashblends
1157+
11561158
qhandle_t skipProgram;
11571159
qhandle_t defaultProgram;
11581160
qhandle_t vertexLitProgram;

code/renderer_oa/tr_scene.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,6 @@ void RE_AddDynamicLightToScene( const vec3_t org, float intensity, float r, floa
241241
if ( intensity <= 0 ) {
242242
return;
243243
}
244-
// these cards don't have the correct blend mode
245-
if ( glConfig.hardwareType == GLHW_RIVA128 || glConfig.hardwareType == GLHW_PERMEDIA2 ) {
246-
return;
247-
}
248244

249245
dl = &backEndData->dlights[r_numdlights++];
250246

@@ -266,6 +262,26 @@ void RE_AddDynamicLightToScene( const vec3_t org, float intensity, float r, floa
266262
dl->color[1] = g;
267263
dl->color[2] = b;
268264
dl->additive = additive;
265+
266+
// leilei - q3r/alice mode
267+
if ( r_dynamiclight->integer == 2){
268+
269+
dl->color[0] = r * 0.1;
270+
dl->color[1] = g * 0.1;
271+
dl->color[2] = b * 0.1;
272+
dl->additive = 1;
273+
}
274+
275+
// these cards don't have the correct blend mode
276+
// leilei - so force additive and keep going
277+
if ( glConfig.hardwareType == GLHW_RIVA128 || glConfig.hardwareType == GLHW_PERMEDIA2 ) {
278+
dl->additive = 1;
279+
}
280+
281+
// leilei - glquake mode - 2 shuts off the light projection to make room for flashblend
282+
if ( r_dynamiclight->integer == 3)
283+
dl->additive = 2;
284+
269285
}
270286

271287
/*
@@ -374,9 +390,10 @@ void RE_RenderScene( const refdef_t *fd ) {
374390

375391
// turn off dynamic lighting globally by clearing all the
376392
// dlights if it needs to be disabled or if vertex lighting is enabled
377-
if ( r_dynamiclight->integer == 0 ||
393+
if ( r_dynamiclight->integer == 0 // ||
378394
// r_vertexLight->integer == 1 || // leilei - commented this out, as we can now do dynamic lights with vertex light
379-
glConfig.hardwareType == GLHW_PERMEDIA2 ) {
395+
// glConfig.hardwareType == GLHW_PERMEDIA2 // leilei - commented this out, as permedia should play with flashblend/verts
396+
) {
380397
tr.refdef.num_dlights = 0;
381398
}
382399

code/renderer_oa/tr_shade.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,12 @@ static void ProjectDlightTexture_scalar( void ) {
644644
colors = colorArray[0];
645645

646646
dl = &backEnd.refdef.dlights[l];
647+
648+
if ( dl->additive == 2) // leilei - glquake flashblend mode
649+
{
650+
return;
651+
}
652+
647653
VectorCopy( dl->transformed, origin );
648654
radius = dl->radius;
649655
scale = 1.0f / radius;

code/renderer_oa/tr_shader.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5521,6 +5521,15 @@ static void CreateInternalShaders( void ) {
55215521
Q_strncpyz( shader.name, "<stencil shadow>", sizeof( shader.name ) );
55225522
shader.sort = SS_STENCIL_SHADOW;
55235523
tr.shadowShader = FinishShader();
5524+
5525+
// leilei - cone shader for flashblend
5526+
Q_strncpyz( shader.name, "<cone add>", sizeof( shader.name ) );
5527+
stages[0].bundle[0].image[0] = tr.whiteImage;
5528+
stages[0].active = qtrue;
5529+
stages[0].rgbGen = CGEN_VERTEX;
5530+
stages[0].alphaGen = AGEN_VERTEX;
5531+
stages[0].stateBits = GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE;
5532+
tr.coneShader = FinishShader();
55245533
}
55255534

55265535
static void CreateExternalShaders( void ) {

code/sys/sys_main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ qboolean Sys_WritePIDFile( void )
161161
FILE *f;
162162
qboolean stale = qfalse;
163163

164+
#ifdef WINFOUR
165+
// leilei - workaround to avoid crashes on WinNT4/W9X
166+
if ( pidFiles )
167+
return qfalse;
168+
#endif
169+
164170
if( pidFile == NULL )
165171
return qfalse;
166172

0 commit comments

Comments
 (0)