Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pandora and OpenGLES renderer.The PANDORA define is used for Pandora spe... #280

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions Makefile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
# make CC=i686-mingw32-gcc
CC=gcc

PANDORA=1

# general compiler settings
ifeq ($(M32),1)
FLAGS= -m32
endif
ifeq ($(PANDORA),1)
FLAGS= -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -mno-unaligned-access -DHAVE_GLES -DPANDORA -DARM
HAVE_GLES=1
endif
FLAGS+= -std=gnu99 -pipe
CFLAGS=$(FLAGS) -Wall -Wextra
LDFLAGS=$(FLAGS)
Expand All @@ -19,7 +25,7 @@ LDFLAGS=$(FLAGS)
DEBUG=1

# might as well leave gprof support on by default as well
PROFILE=1
PROFILE=0

# use this if you want to build everything statically
STATIC=0
Expand All @@ -45,7 +51,7 @@ ifeq ($(SSP),1)
endif

ifeq ($(DEBUG),1)
FLAGS+= -g
FLAGS+= -g -gdwarf-2
else
CFLAGS+=-O3 -Winit-self
LDFLAGS+=-s
Expand All @@ -64,13 +70,14 @@ endif
#

# some systems use lua5.1
LUA=$(shell pkg-config lua && echo lua || echo lua5.1)
LUA=$(shell libs/pkgconfig.sh lua && echo lua || echo lua5.1)
MACOSX=$(shell uname -a | grep -qi darwin && echo 1 || echo 0)

# which version of sdl do you want to ask pkgconfig for ?
SDL=1
ifeq ($(SDL),1)
SDL_=sdl
CFLAGS+=`sdl-config --cflags`
else
SDL_=sdl$(SDL)
endif
Expand All @@ -82,7 +89,8 @@ $(if $(shell test "$(GL)" -ge 3 -a "$(SDL)" -lt 2 && echo fail), \
$(error "GL >= 3 only supported with SDL >= 2"))

# library headers
CFLAGS+= `pkg-config --cflags $(SDL_) $(LUA) $(LUA)-socket libenet libpng zlib openal`
CFLAGS+= `libs/pkgconfig.sh --cflags $(LUA) $(LUA)-socket libenet`
CFLAGS+= `pkg-config --cflags $(SDL_) libpng zlib openal`
ifeq ($(MACOSX),1)
CFLAGS += -DMACOSX
endif
Expand All @@ -95,13 +103,16 @@ ifeq ($(STATIC),1)
LIB+= -Wl,-dn
PKG_CFG_OPTS= --static
endif
LIB+= `pkg-config $(PKG_CFG_OPTS) --libs $(LUA) $(LUA)-socket libenet libpng zlib openal` -lm
LIB+= `libs/pkgconfig.sh $(PKG_CFG_OPTS) --libs $(LUA) $(LUA)-socket libenet`
LIB+= `pkg-config $(PKG_CFG_OPTS) --libs libpng zlib openal`
LIB+= -lm
ifeq ($(STATIC),1)
LIB+= -Wl,-dy
endif

# dynamic only libraries
LIB+= `pkg-config --libs $(SDL_)`
#LIB+= `pkg-config --libs $(SDL_)`
LIB+= `sdl-config --libs`
ifeq ($(MINGW),1)
LIB += -L./mingw/bin
LIB += -lglu32 -lopengl32
Expand All @@ -111,9 +122,14 @@ else ifeq ($(MACOSX),1)
#LIB += -L/usr/X11/lib/ -lGL -lGLU
LIB += -framework OpenGL # OpenGL bundle on OSX.
LIB += -framework Cocoa # Used to target Quartz by SDL_.
else
ifeq ($(HAVE_GLES),1)
LIB += -lGLES_CM -lEGL
CFLAGS += -DHAVE_GLES -DPANDORA
else
LIB += -lGL -lGLU
endif
endif
ifneq ($(MINGW),1)
# apparently on some systems -ldl is explicitly required
# perhaps this is part of the default libs on others...?
Expand Down
8 changes: 8 additions & 0 deletions bsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,18 @@ static bool BSP_LoadPortal( BSP_PORTAL *p, char **Buffer )
int16_tpnt = (int16_t *) *Buffer;
p->group = *int16_tpnt++;
floatpnt = (float *) int16_tpnt;
#ifdef ARM
memcpy(&p->normal, floatpnt, 4*3);
floatpnt+=3;
memcpy(&p->offset, floatpnt, 4);
floatpnt++;
#else
p->normal.x = *floatpnt++;
p->normal.y = *floatpnt++;
p->normal.z = *floatpnt++;
p->offset = *floatpnt++;

#endif
*Buffer = (char *) floatpnt;

return BSP_Loadtree( &p->bsp, Buffer );
Expand Down
10 changes: 9 additions & 1 deletion camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,14 @@ bool Cameraload( char * Filename )
int16Pnt = (int16_t*) Buffer;
CamPnt->Group = *int16Pnt++;
FloatPnt = (float*) int16Pnt;

#ifdef ARM
memcpy(&CamPnt->Pos, FloatPnt, 4*3);
FloatPnt+=3;
memcpy(&CamPnt->Dir, FloatPnt, 4*3);
FloatPnt+=3;
memcpy(&CamPnt->Up, FloatPnt, 4*3);
FloatPnt+=3;
#else
CamPnt->Pos.x = *FloatPnt++;
CamPnt->Pos.y = *FloatPnt++;
CamPnt->Pos.z = *FloatPnt++;
Expand All @@ -121,6 +128,7 @@ bool Cameraload( char * Filename )
CamPnt->Up.x = *FloatPnt++;
CamPnt->Up.y = *FloatPnt++;
CamPnt->Up.z = *FloatPnt++;
#endif
Buffer = (char*) FloatPnt;
Tempv.x = CamPnt->Pos.x + CamPnt->Dir.x;
Tempv.y = CamPnt->Pos.y + CamPnt->Dir.y;
Expand Down
93 changes: 91 additions & 2 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,31 @@ USERCONFIG default_config = {
"Player", // player name
0, // bike (0=Lokasenna)
1, // bike computer ( 1 = Brenda )
#ifdef PANDORA
0.3F, // mouse x sensitivity
0.2F, // mouse y sensitivity
#else
0.6F, // mouse x sensitivity
0.6F, // mouse y sensitivity
#endif
0, // pilot control (pitch forward = down, backward = up)
0, // roll control...
0.05F, // autolevel rate
// { num_keys, { key list [ num_keys ] } },
#ifdef PANDORA
{ 2, { SDLK_q } }, // pitch forward
{ 2, { SDLK_e } }, // pitch backward
{ 2, { SDLK_1 } }, // yaw left
{ 2, { SDLK_3 } }, // yaw right
{ 2, { SDLK_LEFT } }, // roll left
{ 2, { SDLK_RIGHT } }, // roll right
{ 1, { SDLK_q } }, // slide left
{ 1, { SDLK_e } }, // slide right
{ 1, { SDLK_UP } }, // slide up
{ 1, { SDLK_DOWN } }, // slide down
{ 1, { SDLK_2 } }, // forward
{ 1, { SDLK_4 } }, // backward
#else
{ 2, { SDLK_DOWN } }, // pitch forward
{ 2, { SDLK_UP } }, // pitch backward
{ 2, { SDLK_LEFT } }, // yaw left
Expand All @@ -56,22 +75,31 @@ USERCONFIG default_config = {
{ 1, { SDLK_KP_PLUS } }, // slide down
{ 1, { SDLK_a } }, // forward
{ 1, { SDLK_z } }, // backward
#endif
{ 1, { SDLK_LALT } }, // slide
{ 0, {} }, // roll
{ 1, { SDLK_s } }, // turbo
{ 0, {} }, // cruise faster
{ 0, {} }, // cruise slower
{ 2, { LEFT_MOUSE } }, // fire primary
{ 2, { RIGHT_MOUSE } }, // fire secondary
#ifdef PANDORA
{ 1, { SDLK_BACKSPACE } }, // fire mine
#else
{ 1, { SDLK_b } }, // fire mine
#endif
{ 1, { SDLK_PAGEDOWN } }, // select next primary
{ 1, { SDLK_PAGEUP } }, // select prev primary
{ 1, { SDLK_HOME } }, // select next secondary
{ 1, { SDLK_END } }, // select prev secondary
{ 1, { SDLK_r } }, // select rear view
{ 1, { SDLK_h } }, // toggle headlights
{
#ifdef PANDORA
{ 1, { SDLK_q } }, // select primary #1
#else
{ 1, { SDLK_BACKQUOTE } }, // select primary #1
#endif
{ 1, { SDLK_1 } }, // select primary #2
{ 1, { SDLK_4 } }, // select primary #3
{ 1, { SDLK_3 } }, // select primary #4
Expand Down Expand Up @@ -156,12 +184,31 @@ USERCONFIG my_controls = {
"Player", // player name
0, // bike (0=Lokasenna)
1, // bike computer ( 1 = Brenda )
#ifdef PANDORA
0.3F, // mouse x sensitivity
0.2F, // mouse y sensitivity
#else
0.6F, // mouse x sensitivity
0.6F, // mouse y sensitivity
#endif
0, // pilot control (pitch forward = down, backward = up)
0, // roll control...
0.05F, // autolevel rate
// { num_keys, { key list [ num_keys ] } },
#ifdef PANDORA
{ 2, { SDLK_q } }, // pitch forward
{ 2, { SDLK_e } }, // pitch backward
{ 2, { SDLK_1 } }, // yaw left
{ 2, { SDLK_3 } }, // yaw right
{ 2, { SDLK_LEFT } }, // roll left
{ 2, { SDLK_RIGHT } }, // roll right
{ 1, { SDLK_q } }, // slide left
{ 1, { SDLK_e } }, // slide right
{ 1, { SDLK_UP } }, // slide up
{ 1, { SDLK_DOWN } }, // slide down
{ 1, { SDLK_2 } }, // forward
{ 1, { SDLK_4 } }, // backward
#else
{ 2, { SDLK_UP } }, // pitch forward
{ 2, { SDLK_DOWN } }, // pitch backward
{ 2, { SDLK_LEFT } }, // yaw left
Expand All @@ -174,22 +221,31 @@ USERCONFIG my_controls = {
{ 1, { SDLK_KP_PLUS } }, // slide down
{ 1, { SDLK_a } }, // forward
{ 1, { SDLK_z } }, // backward
#endif
{ 1, { SDLK_LALT } }, // slide
{ 0, {} }, // roll
{ 1, { SDLK_s } }, // turbo
{ 0, {} }, // cruise faster
{ 0, {} }, // cruise slower
{ 2, { LEFT_MOUSE } }, // fire primary
{ 2, { RIGHT_MOUSE } }, // fire secondary
#ifdef PANDORA
{ 1, { SDLK_BACKSPACE } }, // fire mine
#else
{ 1, { SDLK_b } }, // fire mine
#endif
{ 1, { SDLK_PAGEDOWN } }, // select next primary
{ 1, { SDLK_PAGEUP } }, // select prev primary
{ 1, { SDLK_HOME } }, // select next secondary
{ 1, { SDLK_END } }, // select prev secondary
{ 1, { SDLK_r } }, // select rear view
{ 1, { SDLK_h } }, // toggle headlights
{
#ifdef PANDORA
{ 1, { SDLK_q } }, // select primary #1
#else
{ 1, { SDLK_BACKQUOTE } }, // select primary #1
#endif
{ 1, { SDLK_1 } }, // select primary #2
{ 1, { SDLK_4 } }, // select primary #3
{ 1, { SDLK_3 } }, // select primary #4
Expand Down Expand Up @@ -1156,10 +1212,17 @@ void ConfigureSpaceorbAxis( int joystick )
JoystickInfo[ joystick ].Axis[ k ].fine = false;
}

#ifdef PANDORA
JoystickInfo[ joystick ].Axis[ AXIS_XAxis ].action = SHIPACTION_SlideLeft;
JoystickInfo[ joystick ].Axis[ AXIS_YAxis ].action = SHIPACTION_MoveForward;
JoystickInfo[ joystick ].Axis[ AXIS_ZAxis ].action = SHIPACTION_SlideUp;
JoystickInfo[ joystick ].Axis[ AXIS_RzAxis ].action = SHIPACTION_RotateUp;
#else
JoystickInfo[ joystick ].Axis[ AXIS_XAxis ].action = SHIPACTION_SlideLeft;
JoystickInfo[ joystick ].Axis[ AXIS_YAxis ].action = SHIPACTION_SlideUp;
JoystickInfo[ joystick ].Axis[ AXIS_ZAxis ].action = SHIPACTION_MoveForward;
JoystickInfo[ joystick ].Axis[ AXIS_RzAxis ].action = SHIPACTION_RotateUp;
#endif
JoystickInfo[ joystick ].Axis[ AXIS_SliderAxis0 ].action = SHIPACTION_RotateLeft;
JoystickInfo[ joystick ].Axis[ AXIS_SliderAxis1 ].action = SHIPACTION_RollLeft;
#if NOT_DONE_THIS_WAY
Expand Down Expand Up @@ -1230,13 +1293,22 @@ void DefaultJoystickSettings( USERCONFIG *u )
for ( k = AXIS_Start; k <= AXIS_End; k++ )
{
JoystickInfo[ j ].Axis[ k ].action = SHIPACTION_Nothing;
#ifdef PANDORA
JoystickInfo[ j ].Axis[ k ].sensitivity = 0.01F;
#else
JoystickInfo[ j ].Axis[ k ].sensitivity = 0.02F;
#endif
JoystickInfo[ j ].Axis[ k ].deadzone = 20;
JoystickInfo[ j ].Axis[ k ].inverted = false;
JoystickInfo[ j ].Axis[ k ].fine = true;
}
#ifdef PANDORA
JoystickInfo[ j ].Axis[ AXIS_XAxis ].action = SHIPACTION_SlideLeft;
JoystickInfo[ j ].Axis[ AXIS_YAxis ].action = SHIPACTION_MoveForward;
#else
JoystickInfo[ j ].Axis[ AXIS_XAxis ].action = SHIPACTION_RotateLeft;
JoystickInfo[ j ].Axis[ AXIS_YAxis ].action = SHIPACTION_RotateUp;
#endif
}
AddButton( j, 0, &u->fire_primary );
AddButton( j, 1, &u->fire_secondary );
Expand Down Expand Up @@ -1281,11 +1353,21 @@ void ReInitJoysticks( void )
for ( k = AXIS_Start; k <= AXIS_End; k++ )
{
tempJoystickInfo[ j ].Axis[ k ].action = SHIPACTION_Nothing;
#ifdef PANDORA
tempJoystickInfo[ j ].Axis[ k ].sensitivity = 0.01F;
#else
tempJoystickInfo[ j ].Axis[ k ].sensitivity = 0.02F;
#endif
tempJoystickInfo[ j ].Axis[ k ].deadzone = 20;
tempJoystickInfo[ j ].Axis[ k ].inverted = false;
tempJoystickInfo[ j ].Axis[ k ].fine = true;
}
#ifdef PANDORA
tempJoystickInfo[ j ].Axis[ AXIS_XAxis ].action = SHIPACTION_SlideLeft;
tempJoystickInfo[ j ].Axis[ AXIS_YAxis ].action = SHIPACTION_MoveForward;
if (j==0) tempJoystickInfo[j].assigned = true; // always 1 nub activated, we want it enabled

#endif
j++;
}
}
Expand All @@ -1303,7 +1385,6 @@ read_config( USERCONFIG *u, char *cfg_name )
FILE *f;
char token[80];
int j;

// all the config settings
static READCONFIGTABLE jumptab[] = {
{ "down", read_down },
Expand Down Expand Up @@ -1372,6 +1453,10 @@ read_config( USERCONFIG *u, char *cfg_name )

// tell debuggers
DebugPrintf( "read_config: couldn't open '%s'\n", cfg_name );
printf( "read_config: couldn't open '%s'\n", cfg_name );

// reset all joystick settings before exiting...
ReInitJoysticks();

// failed ...
return 0;
Expand All @@ -1386,14 +1471,18 @@ read_config( USERCONFIG *u, char *cfg_name )
// files...
u->invert_turn = 0;
u->invert_pitch = 0;
#ifdef PANDORA
u->mouse_x_sensitivity = 0.3F;
u->mouse_y_sensitivity = 0.2F;
#else
u->mouse_x_sensitivity = 0.6F;
u->mouse_y_sensitivity = 0.6F;
#endif
u->send_msg.key[ 0 ] = SDLK_RETURN;

// reset all joystick settings
ReInitJoysticks();


// get a 80 character wide string from file
if ( fscanf( f, " %80s", token ) == 1 )
{
Expand Down
Loading