Merge branch 'master' into feature_openxr

This commit is contained in:
Lubos 2022-04-22 14:13:18 +02:00
commit 3e9c80679e
109 changed files with 2507 additions and 3153 deletions

1
.gitignore vendored
View file

@ -58,3 +58,4 @@ Release/
local.properties
drbeef-release-key.keystore
android/app/src/main/cpp/code/vr/vr_version.h
android/app/src/main/assets/pakQ3Q.pk3

View file

@ -354,6 +354,9 @@ ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu" "gnu")
-pipe -DUSE_ICON -DARCH_STRING=\\\"$(ARCH)\\\"
CLIENT_CFLAGS += $(SDL_CFLAGS)
# Flag -ffast-math replacement: https://pspdfkit.com/blog/2021/understanding-fast-math/
# Flags -ffp-contract=fast -fno-trapping-math are unused because they are causing lightmap issues
OPTIMIZEFASTMATH = -ffinite-math-only -fno-math-errno -fassociative-math -freciprocal-math -fno-signed-zeros
OPTIMIZEVM = -O3
OPTIMIZE = $(OPTIMIZEVM) -ffast-math
@ -1264,6 +1267,11 @@ $(echo_cmd) "REF_CC $<"
$(Q)$(CC) $(SHLIBCFLAGS) $(CFLAGS) $(CLIENT_CFLAGS) $(OPTIMIZE) -o $@ -c $<
endef
define DO_REF_CC_PRECISE
$(echo_cmd) "REF_CC $<"
$(Q)$(CC) $(SHLIBCFLAGS) $(CFLAGS) $(CLIENT_CFLAGS) $(OPTIMIZEVM) $(OPTIMIZEFASTMATH) -o $@ -c $<
endef
define DO_REF_CC_ALTIVEC
$(echo_cmd) "REF_CC $<"
$(Q)$(CC) $(SHLIBCFLAGS) $(CFLAGS) $(CLIENT_CFLAGS) $(OPTIMIZE) $(ALTIVEC_CFLAGS) -o $@ -c $<
@ -2596,7 +2604,6 @@ Q3UIOBJ_ = \
$(B)/$(BASEGAME)/ui/ui_team.o \
$(B)/$(BASEGAME)/ui/ui_teamorders.o \
$(B)/$(BASEGAME)/ui/ui_video.o \
$(B)/$(BASEGAME)/ui/ui_vr.o \
$(B)/$(BASEGAME)/ui/ui_controls3.o \
$(B)/$(BASEGAME)/ui/ui_comfort.o \
\
@ -2723,7 +2730,7 @@ $(B)/renderergles3/%.o: $(RCOMMONDIR)/%.c
$(DO_REF_CC)
$(B)/renderergles3/%.o: $(RGL2DIR)/%.c
$(DO_REF_CC)
$(DO_REF_CC_PRECISE)
$(B)/renderergles3/glsl/%.c: $(RGL2DIR)/glsl/%.glsl
$(DO_REF_STR)

View file

@ -4,7 +4,7 @@ ANDROID_NDK_VERSION=21.1.6352462
UNAME := $(shell uname)
ifeq ($(UNAME), Linux)
ANDROID_SDK_ROOT?=/opt/AndroidSDK
ANDROID_SDK_ROOT?=$(HOME)/Android/Sdk
ANDROID_NDK=$(ANDROID_SDK_ROOT)/ndk/$(ANDROID_NDK_VERSION)
ANDROID_CC=$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-$(ANDROID_SDK_VERSION)-clang
ANDROID_CFLAGS=--target=aarch64-linux-$(ANDROID_SDK_VERSION)

View file

@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.drbeef.ioq3quest"
android:installLocation="preferExternal"
android:versionCode="40"
android:versionName="0.28.0">
android:versionCode="47"
android:versionName="0.31.2">
<uses-feature android:name="android.hardware.vr.headtracking" android:version="1" android:required="true" />
<uses-feature android:glEsVersion="0x00030001" />
<!-- <uses-feature android:name="oculus.software.overlay_keyboard" android:required="false"/>-->
@ -23,6 +23,7 @@
<meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only"/>
<meta-data android:name="com.oculus.supportedDevices" android:value="quest|quest2"/>
<meta-data android:name="com.oculus.ossplash" android:value="true"/>
<meta-data android:name="com.oculus.environmentVersion" android:value="1"/>
<activity android:name="com.drbeef.ioq3quest.MainActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"

View file

@ -14,36 +14,52 @@ set cg_weaponbob 0
set sv_pure 0
set sv_master1 "13.36.227.32:27950"
// VR Button mappings - ONLY put overrides of defaults in here, such as alt key mappings
// set vr_button_map_A ""
//////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Custom Button mappings - ONLY put overrides of defaults in here, such as alt key mappings. //
// //
// Contained sample mapping corresponds to default control schema. Note that by mapping //
// thumbstick diagonals, thumbstick switches to 8-way mode requiring more precise input! //
// //
// To activate mapping, do not forget to remove "//" (marking commented out / inactive line). //
// Also note that custom mappings will be overridden by defaults until game restart in case //
// controls are changed from in-game menu. //
// //
//////////////////////////////////////////////////////////////////////////////////////////////////
// set vr_button_map_A "+moveup"
// set vr_button_map_A_ALT ""
// set vr_button_map_B ""
// set vr_button_map_B "+movedown"
// set vr_button_map_B_ALT ""
// set vr_button_map_X ""
// set vr_button_map_X "+button2"
// set vr_button_map_X_ALT ""
// set vr_button_map_Y ""
// set vr_button_map_Y "+button3"
// set vr_button_map_Y_ALT ""
// set vr_button_map_SECONDARYTHUMBSTICK ""
// set vr_button_map_SECONDARYTHUMBSTICK "+scores"
// set vr_button_map_SECONDARYTHUMBSTICK_ALT ""
// set vr_button_map_PRIMARYTHUMBSTICK ""
// set vr_button_map_PRIMARYTHUMBSTICK_ALT ""
// set vr_button_map_RTHUMBFORWARD ""
// set vr_button_map_SECONDARYTRIGGER "+moveup"
// set vr_button_map_SECONDARYTRIGGER_ALT ""
// set vr_button_map_PRIMARYTRIGGER "+attack"
// set vr_button_map_PRIMARYTRIGGER_ALT ""
// set vr_button_map_SECONDARYGRIP "+weapon_stabilise"
// set vr_button_map_SECONDARYGRIP_ALT ""
// set vr_button_map_PRIMARYGRIP "+weapon_select"
// set vr_button_map_PRIMARYGRIP_ALT ""
// set vr_button_map_RTHUMBFORWARD "weapnext"
// set vr_button_map_RTHUMBFORWARD_ALT ""
// set vr_button_map_RTHUMBFORWARDLEFT ""
// set vr_button_map_RTHUMBFORWARDLEFT_ALT ""
// set vr_button_map_RTHUMBFORWARDRIGHT ""
// set vr_button_map_RTHUMBFORWARDRIGHT_ALT ""
// set vr_button_map_RTHUMBBACK ""
// set vr_button_map_RTHUMBRIGHT "turnright"
// set vr_button_map_RTHUMBRIGHT_ALT ""
// set vr_button_map_RTHUMBBACKRIGHT ""
// set vr_button_map_RTHUMBBACKRIGHT_ALT ""
// set vr_button_map_RTHUMBBACK "weapprev"
// set vr_button_map_RTHUMBBACK_ALT ""
// set vr_button_map_RTHUMBBACKLEFT ""
// set vr_button_map_RTHUMBBACKLEFT_ALT ""
// set vr_button_map_RTHUMBBACKRIGHT ""
// set vr_button_map_RTHUMBBACKRIGHT_ALT ""
// set vr_button_map_SECONDARYTRIGGER ""
// set vr_button_map_SECONDARYTRIGGER_ALT ""
// set vr_button_map_PRIMARYTRIGGER ""
// set vr_button_map_PRIMARYTRIGGER_ALT ""
// set vr_button_map_SECONDARYGRIP ""
// set vr_button_map_SECONDARYGRIP_ALT ""
// set vr_button_map_PRIMARYGRIP "+alt"
// set vr_button_map_PRIMARYGRIP_ALT ""
// set vr_button_map_RTHUMBLEFT "turnleft"
// set vr_button_map_RTHUMBLEFT_ALT ""
// set vr_button_map_RTHUMBFORWARDLEFT ""
// set vr_button_map_RTHUMBFORWARDLEFT_ALT ""

View file

@ -0,0 +1,75 @@
bind LEFTARROW +moveleft
bind RIGHTARROW +moveright
sensitivity 100
set in_joystick 1
set r_externalGLSL 1
set r_stereoEnabled 1
set r_mode -2
set cg_runpitch 0
set cg_runroll 0
set cg_bobup 0
set cg_bobpitch 0
set cg_bobroll 0
set cg_weaponbob 0
set sv_pure 0
set sv_master1 "13.36.227.32:27950"
set vr_weapon_adjustment_1 "1.0,0,12,-13,-36,0,100"
set vr_weapon_adjustment_2 "1.0,-6,6,-3,0,0,0"
set vr_weapon_adjustment_3 "0.8,-6,8,-8,0,0,0"
set vr_weapon_adjustment_4 "1.0,-5,7,-4,0,0,0"
set vr_weapon_adjustment_5 "1.0,-5,6,-4,0,0,0"
set vr_weapon_adjustment_6 "0.8,-3,10,8,0,0,-10"
set vr_weapon_adjustment_7 "0.8,-5,8,0,0,0,0"
set vr_weapon_adjustment_8 "0.9,-4,8,-2,0,0,0"
set vr_weapon_adjustment_9 "1.0,-7,10,-4,0,0,0"
//////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Custom Button mappings - ONLY put overrides of defaults in here, such as alt key mappings. //
// //
// Contained sample mapping corresponds to default control schema. Note that by mapping //
// thumbstick diagonals, thumbstick switches to 8-way mode requiring more precise input! //
// //
// To activate mapping, do not forget to remove "//" (marking commented out / inactive line). //
// Also note that custom mappings will be overridden by defaults until game restart in case //
// controls are changed from in-game menu. //
// //
//////////////////////////////////////////////////////////////////////////////////////////////////
// set vr_button_map_A "+moveup"
// set vr_button_map_A_ALT ""
// set vr_button_map_B "+movedown"
// set vr_button_map_B_ALT ""
// set vr_button_map_X "+button2"
// set vr_button_map_X_ALT ""
// set vr_button_map_Y "+button3"
// set vr_button_map_Y_ALT ""
// set vr_button_map_SECONDARYTHUMBSTICK "+scores"
// set vr_button_map_SECONDARYTHUMBSTICK_ALT ""
// set vr_button_map_PRIMARYTHUMBSTICK ""
// set vr_button_map_PRIMARYTHUMBSTICK_ALT ""
// set vr_button_map_SECONDARYTRIGGER "+moveup"
// set vr_button_map_SECONDARYTRIGGER_ALT ""
// set vr_button_map_PRIMARYTRIGGER "+attack"
// set vr_button_map_PRIMARYTRIGGER_ALT ""
// set vr_button_map_SECONDARYGRIP "+weapon_stabilise"
// set vr_button_map_SECONDARYGRIP_ALT ""
// set vr_button_map_PRIMARYGRIP "+weapon_select"
// set vr_button_map_PRIMARYGRIP_ALT ""
// set vr_button_map_RTHUMBFORWARD "weapnext"
// set vr_button_map_RTHUMBFORWARD_ALT ""
// set vr_button_map_RTHUMBFORWARDRIGHT ""
// set vr_button_map_RTHUMBFORWARDRIGHT_ALT ""
// set vr_button_map_RTHUMBRIGHT "turnright"
// set vr_button_map_RTHUMBRIGHT_ALT ""
// set vr_button_map_RTHUMBBACKRIGHT ""
// set vr_button_map_RTHUMBBACKRIGHT_ALT ""
// set vr_button_map_RTHUMBBACK "weapprev"
// set vr_button_map_RTHUMBBACK_ALT ""
// set vr_button_map_RTHUMBBACKLEFT ""
// set vr_button_map_RTHUMBBACKLEFT_ALT ""
// set vr_button_map_RTHUMBLEFT "turnleft"
// set vr_button_map_RTHUMBLEFT_ALT ""
// set vr_button_map_RTHUMBFORWARDLEFT ""
// set vr_button_map_RTHUMBFORWARDLEFT_ALT ""

Binary file not shown.

Binary file not shown.

View file

@ -5,7 +5,7 @@ set(${CMAKE_C_FLAGS}, "${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -Wall -Werror")
link_directories(../jniLibs/arm64-v8a)
add_library(main SHARED main.cpp)
add_library(main SHARED main.c)
SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE)
SET(BUILD_FOLDER release-android-aarch64)

View file

@ -304,6 +304,8 @@ void CG_Draw3DModel( float x, float y, float w, float h, qhandle_t model, qhandl
refdef.time = cg.time;
refdef.isHUD = qtrue;
trap_R_ClearScene();
trap_R_AddRefEntityToScene( &ent );
trap_R_RenderScene( &refdef );
@ -477,7 +479,7 @@ static void CG_DrawStatusBarHead( float x ) {
}
#endif // MISSIONPACK
/*
/*c
================
CG_DrawStatusBarFlag
@ -539,7 +541,7 @@ static void CG_DrawStatusBar( void ) {
{ 0.5f, 0.5f, 0.5f, 1.0f }, // weapon firing
{ 1.0f, 1.0f, 1.0f, 1.0f } }; // health > 100
if ( cg_drawStatus.integer == 0 ) {
if ( trap_Cvar_VariableValue( "vr_hudDrawStatus" ) == 0 ) {
return;
}
@ -2647,10 +2649,10 @@ static void CG_DrawVignette( void )
/*
=================
CG_Draw2D
CG_DrawHUD2D - Draw 2D elements always intended for the in-world HUD
=================
*/
static void CG_Draw2D()
static void CG_DrawHUD2D()
{
#ifdef MISSIONPACK
if (cgs.orderPending && cg.time > cgs.orderTime) {
@ -2662,40 +2664,26 @@ static void CG_Draw2D()
return;
}
if ( cg_draw2D.integer == 0 ) {
return;
}
if ( cg.snap->ps.pm_type == PM_INTERMISSION ) {
CG_DrawIntermission();
return;
}
/*
if (cg.cameraMode) {
return;
}
*/
if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR ) {
CG_DrawSpectator();
// if(stereoFrame == STEREO_CENTER)
// CG_DrawCrosshair();
CG_DrawCrosshairNames();
} else {
// don't draw any status if dead or the scoreboard is being explicitly shown
if ( !cg.showScores && cg.snap->ps.stats[STAT_HEALTH] > 0 ) {
CG_DrawVignette();
// If weapon selector is active, check whether draw HUD
if (cg.weaponSelectorTime != 0 && trap_Cvar_VariableValue("vr_weaponSelectorWithHud") == 0) {
return;
}
#ifdef MISSIONPACK
if ( cg_drawStatus.integer ) {
if ( trap_Cvar_VariableValue( "vr_hudDrawStatus" ) != 0.0f ) {
Menu_PaintAll();
CG_DrawTimedMenus();
}
@ -2709,10 +2697,6 @@ static void CG_Draw2D()
CG_DrawProxWarning();
#endif
if(vr->weapon_zoomed) {
CG_DrawWeapReticle();
}
CG_DrawCrosshairNames();
CG_DrawWeaponSelect();
@ -2760,6 +2744,61 @@ static void CG_Draw2D()
}
}
/*
=================
CG_DrawScreen2D - Draws 2D elements always intended for the screen
=================
*/
static void CG_DrawScreen2D()
{
// if we are taking a levelshot for the menu, don't draw anything
if ( cg.levelShot ) {
return;
}
if ( cg.snap->ps.pm_type == PM_INTERMISSION ) {
return;
}
if ( cg.snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR &&
!cg.showScores && cg.snap->ps.stats[STAT_HEALTH] > 0 ) {
CG_DrawVignette();
if(vr->weapon_zoomed) {
CG_DrawWeapReticle();
}
}
}
//
// HACK HACK HACK
//
//Render an empty scene - seems to sort the weird out-of-body thing
//when the HUD isn't being drawn. Need to get to the bottom of this
//it shouldn't cost frames, but it is ugly
static void CG_EmptySceneHackHackHack( void )
{
refdef_t refdef;
memset( &refdef, 0, sizeof( refdef ) );
refdef.rdflags = RDF_NOWORLDMODEL;
AxisClear( refdef.viewaxis );
refdef.fov_x = 30;
refdef.fov_y = 30;
refdef.x = 0;
refdef.y = 0;
refdef.width = cgs.glconfig.vidWidth;
refdef.height = cgs.glconfig.vidHeight;
refdef.time = cg.time;
trap_R_ClearScene();
trap_R_RenderScene( &refdef );
}
/*
=====================
@ -2797,20 +2836,24 @@ void CG_DrawActive( void ) {
if ( cg.demoPlayback || CG_IsThirdPersonFollowMode(VRFM_THIRDPERSON_1))
{
worldscale *= SPECTATOR_WORLDSCALE_MULTIPLIER;
trap_Cvar_SetValue("vr_worldscaleScaler", SPECTATOR_WORLDSCALE_MULTIPLIER);
//Just move camera down about 20cm
heightOffset = -0.2f;
}
else if (CG_IsDeathCam() || CG_IsThirdPersonFollowMode(VRFM_THIRDPERSON_2))
{
worldscale *= SPECTATOR2_WORLDSCALE_MULTIPLIER;
trap_Cvar_SetValue("vr_worldscaleScaler", SPECTATOR2_WORLDSCALE_MULTIPLIER);
//Just move camera down about 50cm
heightOffset = -0.5f;
}
else
{
float zoomCoeff = ((2.5f-vr->weapon_zoomLevel)/1.5f); // normally 1.0
trap_Cvar_SetValue("vr_worldscaleScaler", zoomCoeff);
}
float ipd = trap_Cvar_VariableValue("r_stereoSeparation") / 1000.0f;
float separation = worldscale * (ipd / 2) * (cg.stereoView == STEREO_LEFT ? -1.0f : 1.0f);
if (cg.snap->ps.pm_flags & PMF_FOLLOW && vr->follow_mode == VRFM_FIRSTPERSON)
{
//Do nothing to view height if we are following in first person
@ -2821,9 +2864,9 @@ void CG_DrawActive( void ) {
cg.refdef.vieworg[2] += (vr->hmdposition[1] + heightOffset) * worldscale;
}
if (!cgs.localServer)
if (vr->use_fake_6dof)
{
//If connected to a remote server, allow some amount of faked positional tracking
//If running multiplayer, allow some amount of faked positional tracking
if (cg.snap->ps.stats[STAT_HEALTH] > 0 &&
//Don't use fake positional if following another player - this is handled in the
//VR third person code
@ -2848,16 +2891,87 @@ void CG_DrawActive( void ) {
}
}
float zoomCoeff = ((2.5f-vr->weapon_zoomLevel)/1.5f);
VectorMA(cg.refdef.vieworg, -separation * zoomCoeff, cg.refdef.viewaxis[1], cg.refdef.vieworg);
//Now draw the HUD shader in the world
if (trap_Cvar_VariableValue("vr_hudDrawStatus") != 2.0f)
{
refEntity_t ent;
trace_t trace;
vec3_t viewaxis[3];
vec3_t origin, endpos, angles;
vec3_t forward, right, up;
float scale = trap_Cvar_VariableValue("vr_worldscaleScaler");
float dist = (trap_Cvar_VariableValue("vr_hudDepth")+3) * 3 * scale;
float radius = dist / 3.0f;
if (cg.snap->ps.stats[STAT_HEALTH] > 0 &&
cg.snap->ps.pm_type != PM_INTERMISSION)
{
float viewYaw = SHORT2ANGLE(cg.predictedPlayerState.delta_angles[YAW]) +
(vr->clientviewangles[YAW] - vr->hmdorientation[YAW]);
static float hmd_yaw_x = 0.0f;
static float hmd_yaw_y = 1.0f;
static float prevPitch = 0.0f;
{
hmd_yaw_x = 0.95f * hmd_yaw_x + 0.05f * cosf(DEG2RAD(vr->hmdorientation[YAW]));
hmd_yaw_y = 0.95f * hmd_yaw_y + 0.05f * sinf(DEG2RAD(vr->hmdorientation[YAW]));
}
angles[YAW] = viewYaw + RAD2DEG(atan2(hmd_yaw_y, hmd_yaw_x));
angles[PITCH] = 0.95f * prevPitch + 0.05f * vr->hmdorientation[PITCH];
prevPitch = angles[PITCH];
angles[ROLL] = 0;
AngleVectors(angles, forward, right, up);
VectorMA(cg.refdef.vieworg, dist, forward, endpos);
VectorMA(endpos, trap_Cvar_VariableValue("vr_hudYOffset") / 20, up, endpos);
}
else
{
//Lock to face
VectorMA(cg.refdef.vieworg, dist, cg.refdef.viewaxis[0], endpos);
}
memset(&ent, 0, sizeof(ent));
ent.reType = RT_SPRITE;
ent.renderfx = RF_DEPTHHACK | RF_FIRST_PERSON;
VectorCopy(endpos, ent.origin);
ent.radius = radius;
ent.invert = qtrue;
ent.customShader = cgs.media.hudShader;
trap_R_AddRefEntityToScene(&ent);
}
// draw 3D view
trap_R_RenderScene( &cg.refdef );
VectorCopy( baseOrg, cg.refdef.vieworg );
{
//Now draw the screen 2D stuff
CG_DrawScreen2D();
if (!vr->weapon_zoomed)
{
cg.drawingHUD = qtrue;
//Tell renderer we want to draw to the HUD buffer
trap_R_HUDBufferStart(qtrue);
// draw status bar and other floating elements
CG_Draw2D();
CG_DrawHUD2D();
trap_R_HUDBufferEnd();
cg.drawingHUD = qfalse;
}
}
CG_EmptySceneHackHackHack();
}

View file

@ -44,12 +44,18 @@ CG_AdjustFrom640
Adjusted for resolution and screen aspect ratio
================
*/
void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
if (vr->virtual_screen ||
vr->weapon_zoomed)
void CG_AdjustFrom640( float *x, float *y, float *w, float *h )
{
int hudDrawStatus = (int)trap_Cvar_VariableValue("vr_hudDrawStatus");
//If using floating HUD and we are drawing it, then no need to scale as the HUD
//buffer is 640x480
if ( hudDrawStatus == 1 && cg.drawingHUD)
{
return;
}
if (!cg.drawingHUD)
{
// scale for screen sizes
*x *= cgs.screenXScale;
*y *= cgs.screenYScale;
*w *= cgs.screenXScale;
@ -57,22 +63,16 @@ void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
}
else // scale to clearly visible portion of VR screen
{
float screenXScale = cgs.screenXScale / 2.75f;
float screenYScale = cgs.screenYScale / 2.25f;
const auto depth = (int)trap_Cvar_VariableValue( "vr_hudDepth" );
int xoffset = 120 - (depth * 20);
if (cg.stereoView == STEREO_RIGHT) {
xoffset *= -1;
}
float screenXScale = cgs.screenXScale / 2.8f;
float screenYScale = cgs.screenYScale / 2.3f;
*x *= screenXScale;
*y *= screenYScale;
if (hudflags & HUD_FLAGS_DRAWMODEL)
{
*w *= (cgs.screenXScale * 2.0f);
*w *= (screenXScale * 2.0f);
*x -= (*w / 3);
*h *= (cgs.screenYScale * 2.0f);
*h *= (screenYScale * 2.0f);
*y -= (*h / 3);
}
else
@ -81,8 +81,9 @@ void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
*h *= screenYScale;
}
*x += (cg.refdef.width - (640 * screenXScale)) / 2.0f + xoffset;
*y += (cg.refdef.height - (480 * screenYScale)) / 2.0f - trap_Cvar_VariableValue( "vr_hudYOffset" );
*x += (cg.refdef.width - (640 * screenXScale)) / 2.0f;
*y += (cg.refdef.height - (480 * screenYScale)) / 2.0f -
trap_Cvar_VariableValue("vr_hudYOffset");
}
}

View file

@ -837,7 +837,6 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
DEBUGNAME("EV_CHANGE_WEAPON");
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.selectSound );
if ( clientNum == cg.predictedPlayerState.clientNum ) {
vr->realign = 3; // auto trigger weapon re-align in 4 frames
int position = vr->weapon_stabilised ? 4 : (vr->right_handed ? 1 : 2);
trap_HapticEvent("weapon_switch", 0, 0, 100, 0, 0);
}
@ -922,7 +921,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.teleInSound );
CG_SpawnEffect( position);
if (clientNum == cg.predictedPlayerState.clientNum) {
vr->realign = 3; // auto trigger weapon re-align in 4 frames
vr->realign = 3; // Initiate position reset for fake 6DoF
trap_HapticEvent("spark", 0, 0, 80, 0, 0);
}
break;

View file

@ -499,6 +499,8 @@ typedef struct {
qboolean renderingThirdPerson; // during deaths, chasecams, etc
qboolean drawingHUD;
// prediction state
qboolean hyperspace; // true if prediction has hit a trigger_teleport
playerState_t predictedPlayerState;
@ -833,6 +835,8 @@ typedef struct {
qhandle_t invulnerabilityPowerupModel;
#endif
qhandle_t hudShader;
// scoreboard headers
qhandle_t scoreboardName;
qhandle_t scoreboardPing;
@ -1122,6 +1126,7 @@ extern vmCvar_t cg_bobroll;
extern vmCvar_t cg_weaponbob;
extern vmCvar_t cg_swingSpeed;
extern vmCvar_t cg_shadows;
extern vmCvar_t cg_playerShadow;
extern vmCvar_t cg_gibs;
extern vmCvar_t cg_megagibs;
extern vmCvar_t cg_drawTimer;
@ -1142,8 +1147,6 @@ extern vmCvar_t cg_crosshairX;
extern vmCvar_t cg_crosshairY;
extern vmCvar_t cg_crosshairSize;
extern vmCvar_t cg_crosshairHealth;
extern vmCvar_t cg_drawStatus;
extern vmCvar_t cg_draw2D;
extern vmCvar_t cg_animSpeed;
extern vmCvar_t cg_debugAnim;
extern vmCvar_t cg_debugPosition;
@ -1543,6 +1546,7 @@ int trap_Milliseconds( void );
void trap_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags );
void trap_Cvar_Update( vmCvar_t *vmCvar );
void trap_Cvar_Set( const char *var_name, const char *value );
void trap_Cvar_SetValue( const char *var_name, const float value );
void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize );
float trap_Cvar_VariableValue( const char *var_name );
@ -1658,6 +1662,9 @@ int trap_R_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int
void trap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset );
qboolean trap_R_inPVS( const vec3_t p1, const vec3_t p2 );
void trap_R_HUDBufferStart( qboolean clear );
void trap_R_HUDBufferEnd( void );
// The glconfig_t will not change during the life of a cgame.
// If it needs to change, the entire cgame will be restarted, because
// all the qhandle_t are then invalid.

View file

@ -106,6 +106,7 @@ vmCvar_t cg_bobroll;
vmCvar_t cg_weaponbob;
vmCvar_t cg_swingSpeed;
vmCvar_t cg_shadows;
vmCvar_t cg_playerShadow;
vmCvar_t cg_gibs;
vmCvar_t cg_megagibs;
vmCvar_t cg_drawTimer;
@ -124,8 +125,6 @@ vmCvar_t cg_crosshairSize;
vmCvar_t cg_crosshairX;
vmCvar_t cg_crosshairY;
vmCvar_t cg_crosshairHealth;
vmCvar_t cg_draw2D;
vmCvar_t cg_drawStatus;
vmCvar_t cg_animSpeed;
vmCvar_t cg_debugAnim;
vmCvar_t cg_debugPosition;
@ -228,10 +227,9 @@ static cvarTable_t cvarTable[] = {
{ &cg_fov, "cg_fov", "90", CVAR_ARCHIVE },
{ &cg_viewsize, "cg_viewsize", "100", CVAR_ARCHIVE },
{ &cg_shadows, "cg_shadows", "1", CVAR_ARCHIVE },
{ &cg_playerShadow, "cg_playerShadow", "1", CVAR_ARCHIVE },
{ &cg_gibs, "cg_gibs", "1", CVAR_ARCHIVE },
{ &cg_megagibs, "cg_megagibs", "0", CVAR_ARCHIVE },
{ &cg_draw2D, "cg_draw2D", "1", CVAR_ARCHIVE },
{ &cg_drawStatus, "cg_drawStatus", "1", CVAR_ARCHIVE },
{ &cg_drawTimer, "cg_drawTimer", "0", CVAR_ARCHIVE },
{ &cg_drawFPS, "cg_drawFPS", "0", CVAR_ARCHIVE },
{ &cg_drawSnapshot, "cg_drawSnapshot", "0", CVAR_ARCHIVE },
@ -1026,13 +1024,11 @@ static void CG_RegisterGraphics( void ) {
cgs.media.medalAssist = trap_R_RegisterShaderNoMip( "medal_assist" );
cgs.media.medalCapture = trap_R_RegisterShaderNoMip( "medal_capture" );
memset( cg_items, 0, sizeof( cg_items ) );
memset( cg_weapons, 0, sizeof( cg_weapons ) );
// only register the items that the server says we need
Q_strncpyz(items, CG_ConfigString(CS_ITEMS), sizeof(items));
for ( i = 1 ; i < bg_numItems ; i++ ) {
if ( items[ i ] == '1' || cg_buildScript.integer ) {
CG_LoadingItem( i );
@ -1040,6 +1036,14 @@ static void CG_RegisterGraphics( void ) {
}
}
// register all weapons (as they are used on weapon wheel selector)
for (int weaponId = 1; weaponId < WP_NUM_WEAPONS; ++weaponId) {
if (weaponId == WP_GRAPPLING_HOOK) {
continue;
}
CG_RegisterWeapon(weaponId);
}
// wall marks
cgs.media.bulletMarkShader = trap_R_RegisterShader( "gfx/damage/bullet_mrk" );
cgs.media.burnMarkShader = trap_R_RegisterShader( "gfx/damage/burn_med_mrk" );
@ -1053,6 +1057,9 @@ static void CG_RegisterGraphics( void ) {
cgs.media.reticleShader = trap_R_RegisterShader( "gfx/weapon/scope" );
cgs.media.vignetteShader = trap_R_RegisterShader( "gfx/vignette" );
//HUD
cgs.media.hudShader = trap_R_RegisterShader( "sprites/vr/hud" );
//Used for the weapon selector
cgs.media.smallSphereModel = trap_R_RegisterModel("models/powerups/health/small_sphere.md3");
@ -1974,6 +1981,13 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) {
const char *serverinfo = CG_ConfigString( CS_SERVERINFO );
vr->no_crosshair = (strcasestr(serverinfo, "nocrosshair") != NULL || strcasestr(serverinfo, "no crosshair") != NULL);
vr->local_server = cgs.localServer;
#ifdef MISSIONPACK
vr->single_player = trap_Cvar_VariableValue("ui_singlePlayerActive");
#else
vr->single_player = trap_Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER;
#endif
vr->use_fake_6dof = !vr->single_player;
}
/*

View file

@ -165,7 +165,7 @@ static void CG_DrawPlayerArmorIcon( rectDef_t *rect, qboolean draw2D ) {
vec3_t angles;
vec3_t origin;
if ( cg_drawStatus.integer == 0 ) {
if ( trap_Cvar_VariableValue( "vr_hudDrawStatus" ) == 0 ) {
return;
}
@ -1501,7 +1501,7 @@ void CG_DrawMedal(int ownerDraw, rectDef_t *rect, float scale, vec4_t color, qha
void CG_OwnerDraw(float x, float y, float w, float h, float text_x, float text_y, int ownerDraw, int ownerDrawFlags, int align, float special, float scale, vec4_t color, qhandle_t shader, int textStyle) {
rectDef_t rect;
if ( cg_drawStatus.integer == 0 ) {
if ( trap_Cvar_VariableValue( "vr_hudDrawStatus" ) == 0 ) {
return;
}

View file

@ -1908,39 +1908,39 @@ static void CG_PlayerPowerups( centity_t *cent, refEntity_t *torso ) {
ci = &cgs.clientinfo[ cent->currentState.clientNum ];
// redflag
if ( powerups & ( 1 << PW_REDFLAG ) ) {
if (ci->newAnims) {
if (ci->newAnims && cent->currentState.clientNum != vr->clientNum) {
CG_PlayerFlag( cent, cgs.media.redFlagFlapSkin, torso );
}
else {
vec3_t offset;
VectorSet(offset, 0, -16, 0);
CG_TrailItem( cent, cgs.media.redFlagModel, offset, 1.0f );
VectorSet(offset, 0, -1, 0);
CG_TrailItem( cent, cgs.media.redFlagModel, offset, 0.1f );
}
trap_R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 1.0, 0.2f, 0.2f );
}
// blueflag
if ( powerups & ( 1 << PW_BLUEFLAG ) ) {
if (ci->newAnims){
if (ci->newAnims && cent->currentState.clientNum != vr->clientNum){
CG_PlayerFlag( cent, cgs.media.blueFlagFlapSkin, torso );
}
else {
vec3_t offset;
VectorSet(offset, 0, -16, 0);
CG_TrailItem( cent, cgs.media.blueFlagModel, offset, 1.0f );
VectorSet(offset, 0, -1, 0);
CG_TrailItem( cent, cgs.media.blueFlagModel, offset, 0.1f );
}
trap_R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 0.2f, 0.2f, 1.0 );
}
// neutralflag
if ( powerups & ( 1 << PW_NEUTRALFLAG ) ) {
if (ci->newAnims) {
if (ci->newAnims && cent->currentState.clientNum != vr->clientNum) {
CG_PlayerFlag( cent, cgs.media.neutralFlagFlapSkin, torso );
}
else {
vec3_t offset;
VectorSet(offset, 0, -16, 0);
CG_TrailItem( cent, cgs.media.neutralFlagModel, offset, 1.0f );
VectorSet(offset, 0, -1, 0);
CG_TrailItem( cent, cgs.media.neutralFlagModel, offset, 0.1f );
}
trap_R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 1.0, 1.0, 1.0 );
}
@ -2071,7 +2071,9 @@ static qboolean CG_PlayerShadow( centity_t *cent, float *shadowPlane ) {
*shadowPlane = 0;
if ( cg_shadows.integer == 0 ) {
qboolean clientPlayer = cent->currentState.number == cg.snap->ps.clientNum;
if ( (clientPlayer && cg_playerShadow.integer == 0) || (!clientPlayer && cg_shadows.integer == 0) ) {
return qfalse;
}
@ -2080,6 +2082,11 @@ static qboolean CG_PlayerShadow( centity_t *cent, float *shadowPlane ) {
return qfalse;
}
// no shadow if VR player is dead
if ( clientPlayer && ( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) ) {
return qfalse;
}
// send a trace down from the player to the ground
VectorCopy( cent->lerpOrigin, end );
end[2] -= SHADOW_DISTANCE;
@ -2093,7 +2100,8 @@ static qboolean CG_PlayerShadow( centity_t *cent, float *shadowPlane ) {
*shadowPlane = trace.endpos[2] + 1;
if ( cg_shadows.integer != 1 ) { // no mark for stencil or projection shadows
// no mark for stencil or projection shadows
if ( (clientPlayer && cg_playerShadow.integer != 1) || (!clientPlayer && cg_shadows.integer != 1) ) {
return qtrue;
}
@ -2125,7 +2133,9 @@ static void CG_PlayerSplash( centity_t *cent ) {
int contents;
polyVert_t verts[4];
if ( !cg_shadows.integer ) {
qboolean clientPlayer = cent->currentState.number == cg.snap->ps.clientNum;
if ( (clientPlayer && !cg_playerShadow.integer) || (!clientPlayer && !cg_shadows.integer) ) {
return;
}
@ -2391,7 +2401,9 @@ void CG_Player( centity_t *cent ) {
// add a water splash if partially in and out of water
CG_PlayerSplash( cent );
if ( cg_shadows.integer == 3 && shadow ) {
qboolean clientPlayer = cent->currentState.number == cg.snap->ps.clientNum;
if ( shadow && ( (clientPlayer && cg_playerShadow.integer == 3) || (!clientPlayer && cg_shadows.integer == 3) ) ) {
renderfx |= RF_SHADOW_PLANE;
}
renderfx |= RF_LIGHTING_ORIGIN; // use the same origin for all

View file

@ -297,7 +297,7 @@ static void CG_TouchItem( centity_t *cent ) {
return;
}
if (cg.stereoView == STEREO_LEFT)
//if (cg.stereoView == STEREO_LEFT)
{
// grab it
BG_AddPredictableEventToPlayerstate(EV_ITEM_PICKUP, cent->currentState.modelindex,

View file

@ -166,6 +166,8 @@ typedef enum {
CG_FS_SEEK,
CG_HAPTICEVENT,
CG_R_HUDBUFFER_START,
CG_R_HUDBUFFER_END,
/*
CG_LOADCAMERA,

View file

@ -69,6 +69,12 @@ void trap_Cvar_Set( const char *var_name, const char *value ) {
syscall( CG_CVAR_SET, var_name, value );
}
void trap_Cvar_SetValue( const char *var_name, const float value ) {
char buffer[256];
Com_sprintf(buffer, 255, "%g", value);
syscall( CG_CVAR_SET, var_name, buffer );
}
void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize ) {
syscall( CG_CVAR_VARIABLESTRINGBUFFER, var_name, buffer, bufsize );
}
@ -282,6 +288,14 @@ void trap_R_RenderScene( const refdef_t *fd ) {
syscall( CG_R_RENDERSCENE, fd );
}
void trap_R_HUDBufferStart( qboolean clear ) {
syscall( CG_R_HUDBUFFER_START, clear );
}
void trap_R_HUDBufferEnd( void ) {
syscall( CG_R_HUDBUFFER_END );
}
void trap_R_SetColor( const float *rgba ) {
syscall( CG_R_SETCOLOR, rgba );
}

View file

@ -745,7 +745,7 @@ static int CG_CalcViewValues( ) {
VectorCopy(cg.refdef.vieworg, cg.vr_vieworigin);
}
if (!cgs.localServer && cg.stereoView == STEREO_LEFT)
if (vr->use_fake_6dof && !vr->virtual_screen)
{
vec3_t weaponorigin, weaponangles;
CG_CalculateVRWeaponPosition(weaponorigin, weaponangles);
@ -768,6 +768,12 @@ static int CG_CalcViewValues( ) {
CG_LaserSight(weaponorigin, trace.endpos, colour, 1.0f);
}
if (cg.predictedPlayerState.pm_flags == PM_SPECTATOR)
{
//If spectating, just take the weapon angles directly
VectorCopy(weaponangles, vr->calculated_weaponangles);
}
else
{
VectorSubtract(trace.endpos, cg.refdef.vieworg, dir);
vectoangles(dir, vr->calculated_weaponangles);
@ -807,7 +813,7 @@ static int CG_CalcViewValues( ) {
}
// position eye relative to origin
if (!cgs.localServer)
if (vr->use_fake_6dof && !vr->virtual_screen)
{
if (vr->weapon_zoomed) {
//If we are zoomed, then we use the refdefViewANgles (which are the weapon angles)
@ -998,7 +1004,7 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo
// this counter will be bumped for every valid scene we generate
cg.clientFrame++;
if (cg.stereoView == STEREO_LEFT)
//if (cg.stereoView == STEREO_LEFT)
{
// update cg.predictedPlayerState - only do this on the first eye render
CG_PredictPlayerState();

View file

@ -231,9 +231,9 @@ void CG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out)
VectorSet(vrSpace, in[2], in[0], in[1] );
vec2_t r;
if (!cgs.localServer)
if (vr->use_fake_6dof)
{
//We are connected to a multiplayer server, so make the appropriate adjustment to the view
//We are running multiplayer, so make the appropriate adjustment to the view
//angles as we send orientation to the server that includes the weapon angles
float deltaYaw = SHORT2ANGLE(cg.predictedPlayerState.delta_angles[YAW]);
if (cg.snap->ps.pm_flags & PMF_FOLLOW)
@ -262,7 +262,7 @@ void CG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out)
static void CG_CalculateVRPositionInWorld( vec3_t in_position, vec3_t in_offset, vec3_t in_orientation, vec3_t origin, vec3_t angles )
{
if (!cgs.localServer)
if (vr->use_fake_6dof)
{
//Use absolute position for the faked 6DoF for multiplayer
vec3_t offset;
@ -274,7 +274,7 @@ static void CG_CalculateVRPositionInWorld( vec3_t in_position, vec3_t in_offset
}
else
{
//Local server - true 6DoF offset from HMD
//Singleplayer - true 6DoF offset from HMD
vec3_t offset;
VectorCopy(in_offset, offset);
offset[1] = 0; // up/down is index 1 in this case
@ -284,7 +284,7 @@ static void CG_CalculateVRPositionInWorld( vec3_t in_position, vec3_t in_offset
}
VectorCopy(in_orientation, angles);
if ( !cgs.localServer )
if ( vr->use_fake_6dof )
{
//Calculate the offhand angles from "first principles"
float deltaYaw = SHORT2ANGLE(cg.predictedPlayerState.delta_angles[YAW]);
@ -534,7 +534,9 @@ CG_RailTrail
==========================
*/
void CG_RailTrail (clientInfo_t *ci, vec3_t start, vec3_t end) {
vec3_t axis[36], move, move2, vec, temp;
#define NUM_PARTICLE_PER_ROTATION 18
vec3_t axis[NUM_PARTICLE_PER_ROTATION], move, move2, vec, vec2, temp;
float len;
int i, j, skip;
@ -586,33 +588,35 @@ void CG_RailTrail (clientInfo_t *ci, vec3_t start, vec3_t end) {
VectorSubtract (end, start, vec);
len = VectorNormalize (vec);
PerpendicularVector(temp, vec);
for (i = 0 ; i < 36; i++)
for (i = 0 ; i < NUM_PARTICLE_PER_ROTATION; i++)
{
RotatePointAroundVector(axis[i], vec, temp, i * 10);//banshee 2.4 was 10
RotatePointAroundVector(axis[i], vec, temp, i * (360.0f / NUM_PARTICLE_PER_ROTATION));//banshee 2.4 was 10
}
VectorMA(move, 20, vec, move);
VectorScale (vec, SPACING, vec);
VectorMA(move, (360.0f / NUM_PARTICLE_PER_ROTATION), vec, move);
VectorScale (vec, SPACING, vec2);
skip = -1;
j = 18;
for (i = 0; i < len; i += SPACING)
j = 0;
int spacing = SPACING;
for (i = 0; i < len; i += spacing, spacing++)
{
if (i != skip)
{
skip = i + SPACING;
VectorScale (vec, spacing, vec2);
skip = i + spacing;
le = CG_AllocLocalEntity();
re = &le->refEntity;
le->leFlags = LEF_PUFF_DONT_SCALE;
le->leType = LE_MOVE_SCALE_FADE;
le->startTime = cg.time;
le->endTime = cg.time + (i>>1) + 600;
le->endTime = cg.time + (i>>1) + 500;
le->lifeRate = 1.0 / (le->endTime - le->startTime);
re->shaderTime = cg.time / 1000.0f;
re->reType = RT_SPRITE;
re->radius = 1.1f;
re->radius = 1.2f;
re->customShader = cgs.media.railRingsShader;
re->shaderRGBA[0] = ci->color2[0] * 255;
@ -637,9 +641,9 @@ void CG_RailTrail (clientInfo_t *ci, vec3_t start, vec3_t end) {
le->pos.trDelta[2] = axis[j][2]*6;
}
VectorAdd (move, vec, move);
VectorAdd (move, vec2, move);
j = (j + ROTATION) % 36;
j = (j + ROTATION) % NUM_PARTICLE_PER_ROTATION;
}
}
@ -1720,6 +1724,10 @@ void CG_AddViewWeapon( playerState_t *ps ) {
return;
}
if (vr->weapon_zoomed) {
return; // do not draw weapon model with enabled weapon scope
}
cent = &cg.predictedPlayerEntity; // &cg_entities[cg.snap->ps.clientNum];
CG_RegisterWeapon( ps->weapon );
weapon = &cg_weapons[ ps->weapon ];
@ -1818,7 +1826,7 @@ void CG_AddViewWeapon( playerState_t *ps ) {
}
hand.hModel = weapon->handsModel;
hand.renderfx = RF_DEPTHHACK | RF_FIRST_PERSON | RF_MINLIGHT;
hand.renderfx = /*RF_DEPTHHACK |*/ RF_FIRST_PERSON | RF_MINLIGHT;
//scale the whole model
for ( int i = 0; i < 3; i++ ) {
@ -1856,6 +1864,11 @@ void CG_DrawWeaponSelect( void ) {
return;
}
// don't display when weapon wheel is opened
if (vr->weapon_select) {
return;
}
color = CG_FadeColor( cg.weaponSelectTime, WEAPON_SELECT_TIME );
if ( !color ) {
return;
@ -2064,19 +2077,21 @@ void CG_DrawWeaponSelector( void )
}
const int selectorMode = (int)trap_Cvar_VariableValue("vr_weaponSelectorMode");
float DEPTH = 5.0f;
float RAD = 4.0f;
float SCALE = 0.05f;
float dist = 10.0f;
float radius = 4.0f;
float scale = 0.05f;
if (selectorMode == WS_HMD) // HMD locked
{
VectorCopy(vr->hmdorientation, cg.weaponSelectorAngles);
VectorCopy(vr->hmdposition, cg.weaponSelectorOrigin);
VectorClear(cg.weaponSelectorOffset);
DEPTH = 7.5f; // push a bit further away from the HMD origin
dist = (trap_Cvar_VariableValue("vr_hudDepth")+3) * 3;
radius = dist / 3.0f;
scale = 0.04f + 0.01f * (trap_Cvar_VariableValue("vr_hudDepth")+1);
}
float frac = (cg.time - cg.weaponSelectorTime) / (20 * DEPTH);
float frac = (cg.time - cg.weaponSelectorTime) / 100.0f;
if (frac > 1.0f) frac = 1.0f;
vec3_t controllerOrigin, controllerAngles, controllerOffset, selectorOrigin;
@ -2099,7 +2114,7 @@ void CG_DrawWeaponSelector( void )
}
VectorCopy(wheelOrigin, beamOrigin);
VectorMA(wheelOrigin, ((DEPTH*2.0f)*((selectorMode == WS_CONTROLLER) ? frac : 1.0f)), wheelForward, wheelOrigin);
VectorMA(wheelOrigin, (dist * ((selectorMode == WS_CONTROLLER) ? frac : 1.0f)), wheelForward, wheelOrigin);
VectorCopy(wheelOrigin, selectorOrigin);
const int switchThumbsticks = (int)trap_Cvar_VariableValue("vr_switchThumbsticks");
@ -2108,7 +2123,8 @@ void CG_DrawWeaponSelector( void )
float thumbstickAxisX = 0.0f;
float thumbstickAxisY = 0.0f;
float a = atan2(vr->thumbstick_location[thumb][0], vr->thumbstick_location[thumb][1]);
if (length(vr->thumbstick_location[thumb][0], vr->thumbstick_location[thumb][1]) > 0.95f)
float thumbstickValue = length(vr->thumbstick_location[thumb][0], vr->thumbstick_location[thumb][1]);
if (thumbstickValue > 0.95f)
{
thumbstickAxisX = sinf(a) * 0.95f;
thumbstickAxisY = cosf(a) * 0.95f;
@ -2134,17 +2150,17 @@ void CG_DrawWeaponSelector( void )
y = thumbstickAxisY;
}
VectorMA(selectorOrigin, RAD * x, wheelRight, selectorOrigin);
VectorMA(selectorOrigin, RAD * y, wheelUp, selectorOrigin);
VectorMA(selectorOrigin, radius * x, wheelRight, selectorOrigin);
VectorMA(selectorOrigin, radius * y, wheelUp, selectorOrigin);
{
refEntity_t blob;
memset( &blob, 0, sizeof( blob ) );
VectorCopy( selectorOrigin, blob.origin );
AnglesToAxis(vec3_origin, blob.axis);
VectorScale( blob.axis[0], SCALE - 0.01f, blob.axis[0] );
VectorScale( blob.axis[1], SCALE - 0.01f, blob.axis[1] );
VectorScale( blob.axis[2], SCALE - 0.01f, blob.axis[2] );
VectorScale( blob.axis[0], scale - 0.01f, blob.axis[0] );
VectorScale( blob.axis[1], scale - 0.01f, blob.axis[1] );
VectorScale( blob.axis[2], scale - 0.01f, blob.axis[2] );
blob.nonNormalizedAxes = qtrue;
blob.hModel = cgs.media.smallSphereModel;
trap_R_AddRefEntityToScene( &blob );
@ -2193,7 +2209,7 @@ void CG_DrawWeaponSelector( void )
vec3_t forward, up;
AngleVectors(angles, forward, NULL, up);
VectorMA(wheelOrigin, (RAD*frac), up, iconOrigin);
VectorMA(wheelOrigin, (radius*frac), up, iconOrigin);
VectorMA(iconOrigin, 0.2f, forward, iconBackground);
VectorMA(iconOrigin, -0.2f, forward, iconForeground);
@ -2276,7 +2292,7 @@ void CG_DrawWeaponSelector( void )
iconAngles[ROLL] -= 90.0f;
}
float weaponScale = ((SCALE+0.02f)*frac) +
float weaponScale = ((scale+0.02f)*frac) +
(cg.weaponSelectorSelection == weaponId ? 0.04f : 0);
AnglesToAxis(iconAngles, ent.axis);
@ -2330,10 +2346,13 @@ void CG_DrawWeaponSelector( void )
refEntity_t sprite;
memset( &sprite, 0, sizeof( sprite ) );
float sRadius = 0.7f
+ (0.2f * (trap_Cvar_VariableValue("vr_hudDepth")-1));
VectorCopy(iconOrigin, sprite.origin);
sprite.reType = RT_SPRITE;
sprite.customShader = cg_weapons[weaponId].weaponIcon;
sprite.radius = 0.6f + (cg.weaponSelectorSelection == weaponId ? 0.1f : 0);
sprite.radius = sRadius * 0.9f * (cg.weaponSelectorSelection == weaponId ? 1.1f : 1.0);
sprite.shaderRGBA[0] = 255;
sprite.shaderRGBA[1] = 255;
sprite.shaderRGBA[2] = 255;
@ -2345,7 +2364,7 @@ void CG_DrawWeaponSelector( void )
VectorCopy( iconBackground, sprite.origin );
sprite.reType = RT_SPRITE;
sprite.customShader = cgs.media.selectShader;
sprite.radius = 0.7f + (cg.weaponSelectorSelection == weaponId ? 0.1f : 0);
sprite.radius = sRadius * (cg.weaponSelectorSelection == weaponId ? 1.1f : 1.0);
sprite.shaderRGBA[0] = 255;
sprite.shaderRGBA[1] = 255;
sprite.shaderRGBA[2] = 255;
@ -2358,7 +2377,7 @@ void CG_DrawWeaponSelector( void )
VectorCopy(iconForeground, sprite.origin);
sprite.reType = RT_SPRITE;
sprite.customShader = cgs.media.noammoShader;
sprite.radius = 0.7f;
sprite.radius = sRadius;
sprite.shaderRGBA[0] = 255;
sprite.shaderRGBA[1] = 255;
sprite.shaderRGBA[2] = 255;
@ -2378,12 +2397,13 @@ void CG_DrawWeaponSelector( void )
// In case was invoked by thumbstick axis and thumbstick is centered
// select weapon (if any selected) and close the selector
if (vr->weapon_select_autoclose && frac > 0.25f) {
if (thumbstickAxisX > -0.1f && thumbstickAxisX < 0.1f && thumbstickAxisY > -0.1f && thumbstickAxisY < 0.1f) {
if (thumbstickValue < 0.1f) {
if (selected) {
cg.weaponSelect = cg.weaponSelectorSelection;
}
vr->weapon_select = qfalse;
vr->weapon_select_autoclose = qfalse;
vr->weapon_select_using_thumbstick = qfalse;
}
}
}

View file

@ -697,6 +697,12 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) {
case CG_HAPTICEVENT:
VR_HapticEvent( VMA(1), args[2], args[3], args[4], VMF(5), VMF(6) );
return 0;
case CG_R_HUDBUFFER_START:
re.HUDBufferStart(args[1]);
return 0;
case CG_R_HUDBUFFER_END:
re.HUDBufferEnd();
return 0;
default:

View file

@ -28,6 +28,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
int g_console_field_width = 78;
extern vr_clientinfo_t vr;
extern cvar_t *vr_hudDrawStatus;
extern cvar_t *vr_showConsoleMessages;
#define NUM_CON_TIMES 4
@ -555,12 +557,6 @@ void Con_DrawInput (void) {
SCREEN_WIDTH - 3 * SMALLCHAR_WIDTH, qtrue, qtrue );
}
static int Con_GetChatOffsetY( void )
{
return vr.show_console ? (-30 * vr.hmdorientation[PITCH]) : 0;
}
/*
================
Con_DrawNotify
@ -580,6 +576,11 @@ void Con_DrawNotify (void)
currentColor = 7;
re.SetColor( g_color_table[currentColor] );
re.HUDBufferStart(qfalse);
int xadjust = (vr_hudDrawStatus->integer != 1) ? 500 : 10;
int yadjust = (vr_hudDrawStatus->integer != 1) ? 600 : 10;
v = 0;
for (i= con.current-NUM_CON_TIMES+1 ; i<=con.current ; i++)
{
@ -605,7 +606,13 @@ void Con_DrawNotify (void)
currentColor = ColorIndexForNumber( text[x]>>8 );
re.SetColor( g_color_table[currentColor] );
}
SCR_DrawSmallChar( cl_conXOffset->integer + con.xadjust + (x+1)*SMALLCHAR_WIDTH + 500, v + Con_GetChatOffsetY(), text[x] & 0xff );
if (vr_showConsoleMessages->integer)
{
SCR_DrawSmallChar(
cl_conXOffset->integer + con.xadjust + (x + 1) * SMALLCHAR_WIDTH + xadjust,
v + yadjust, text[x] & 0xff);
}
}
v += SMALLCHAR_HEIGHT;
@ -613,6 +620,8 @@ void Con_DrawNotify (void)
re.SetColor( NULL );
re.HUDBufferEnd();
if (Key_GetCatcher( ) & (KEYCATCH_UI | KEYCATCH_CGAME) ) {
return;
}

View file

@ -599,12 +599,10 @@ void CL_FinishMove( usercmd_t *cmd ) {
vr.clientNum = cl.snap.ps.clientNum;
//If we are running with a remote non-vr server, then the best we can do is pass the angles from the weapon
//and adjust the move values accordingly, to "fake" a 3DoF weapon but keeping the movement correct
if ( !com_sv_running || !com_sv_running->integer )
//If we are running multiplayer, pass the angles from the weapon and adjust the move values accordingly,
// to "fake" a 3DoF weapon but keeping the movement correct (necessary with a remote non-vr server)
if ( vr.use_fake_6dof )
{
vr.local_server = qfalse;
//Realign in playspace
if (--vr.realign == 0)
{
@ -633,10 +631,6 @@ void CL_FinishMove( usercmd_t *cmd ) {
cmd->forwardmove = out[1];
}
else {
//Record client number - local server uses this to know we can use absolute angles
//rather than deltas
vr.local_server = qtrue;
for (i = 0; i < 3; i++) {
cmd->angles[i] = ANGLE2SHORT(cl.viewangles[i]);
}

View file

@ -3580,7 +3580,6 @@ void CL_Init( void ) {
// init autoswitch and hud toggle so the ui will have it correctly even
// if the cgame hasn't been started
Cvar_Get ("cg_autoswitch", "1", CVAR_ARCHIVE);
Cvar_Get ("cg_drawStatus", "1", CVAR_ARCHIVE);
m_pitch = Cvar_Get ("m_pitch", "0.022", CVAR_ARCHIVE);
m_yaw = Cvar_Get ("m_yaw", "0.022", CVAR_ARCHIVE);

View file

@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "../vr/vr_clientinfo.h"
extern vr_clientinfo_t vr;
extern cvar_t *vr_hudDrawStatus;
qboolean scr_initialized; // ready to draw
@ -74,7 +75,7 @@ void SCR_AdjustFrom640( float *x, float *y, float *w, float *h ) {
xscale = cls.glconfig.vidWidth / 640.0;
yscale = cls.glconfig.vidHeight / 480.0;
if (vr.virtual_screen) {
if (vr.virtual_screen || vr_hudDrawStatus->integer != 2) {
if (x) {
*x *= xscale;
}
@ -599,7 +600,8 @@ void SCR_UpdateScreen( void ) {
// XXX
int in_anaglyphMode = Cvar_VariableIntegerValue("r_anaglyphMode");
// if running in stereo, we need to draw the frame twice
if ( cls.glconfig.stereoEnabled || in_anaglyphMode) {
if ( qfalse )//cls.glconfig.stereoEnabled || in_anaglyphMode)
{
SCR_DrawScreenField( STEREO_LEFT );
SCR_DrawScreenField( STEREO_RIGHT );
} else {

View file

@ -50,7 +50,7 @@ extern vr_clientinfo_t *vr;
float PM_GetFrictionCoefficient( void ) {
if (vr != NULL && vr->clientNum == pm->ps->clientNum && vr->local_server) {
if (vr != NULL && vr->clientNum == pm->ps->clientNum && !vr->use_fake_6dof) {
return 10.0f;
} else {
return 6.0f;
@ -58,7 +58,7 @@ float PM_GetFrictionCoefficient( void ) {
}
float PM_GetAccelerationCoefficient( void ) {
if (vr != NULL && vr->clientNum == pm->ps->clientNum && vr->local_server) {
if (vr != NULL && vr->clientNum == pm->ps->clientNum && !vr->use_fake_6dof) {
return 1000.0f;
} else {
return 10.0f;
@ -1828,14 +1828,14 @@ void PM_UpdateViewAngles( playerState_t *ps, const usercmd_t *cmd ) {
// circularly clamp the angles with deltas
for (i=0 ; i<3 ; i++) {
if (vr != NULL && vr->clientNum == ps->clientNum && vr->local_server)
if (vr != NULL && vr->clientNum == ps->clientNum && !vr->use_fake_6dof)
{
//Client is the VR player on the "local" server
//Client is the VR player in the singleplayer game
temp = cmd->angles[i] + (i == YAW ? ps->delta_angles[i] : 0);
}
else
{
//Client is either a BOT or a remote/connected player, or
//Client is either a BOT or we are running multiplayer, or
//the vr player playing on a remote server (since this is shared code by game and cgame)
temp = cmd->angles[i] + ps->delta_angles[i];
}

View file

@ -519,6 +519,13 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) {
char serverinfo[MAX_INFO_STRING];
trap_GetServerinfo( serverinfo, sizeof( serverinfo ) );
vr->no_crosshair = (strcasestr(serverinfo, "nocrosshair") != NULL || strcasestr(serverinfo, "no crosshair") != NULL);
vr->local_server = qtrue;
#ifdef MISSIONPACK
vr->single_player = trap_Cvar_VariableValue("ui_singlePlayerActive");
#else
vr->single_player = trap_Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER;
#endif
vr->use_fake_6dof = !vr->single_player;
}

View file

@ -109,7 +109,8 @@ qboolean CheckGauntletAttack( gentity_t *ent ) {
vec3_t angles;
if ( !( ent->r.svFlags & SVF_BOT ) &&
vr != NULL &&
(ent->client->ps.clientNum == vr->clientNum))
(ent->client->ps.clientNum == vr->clientNum) &&
!vr->use_fake_6dof)
{
VectorCopy(vr->weaponangles, angles);
angles[YAW] += ent->client->ps.viewangles[YAW] - vr->hmdorientation[YAW];
@ -817,7 +818,8 @@ set muzzle location relative to pivoting eye
void CalcMuzzlePoint ( gentity_t *ent, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint ) {
if ( ( ent->r.svFlags & SVF_BOT ) ||
//Can't use the vr_clientinfo if this isn't the vr client
vr == NULL || (ent->client->ps.clientNum != vr->clientNum))
vr == NULL || (ent->client->ps.clientNum != vr->clientNum) ||
vr->use_fake_6dof)
{
VectorCopy( ent->s.pos.trBase, muzzlePoint );
muzzlePoint[2] += ent->client->ps.viewheight;
@ -881,7 +883,8 @@ void FireWeapon( gentity_t *ent ) {
vec3_t viewang;
if ( !( ent->r.svFlags & SVF_BOT ) &&
vr != NULL &&
(ent->client->ps.clientNum == vr->clientNum))
(ent->client->ps.clientNum == vr->clientNum) &&
!vr->use_fake_6dof)
{
VectorCopy(vr->weaponangles, viewang);
viewang[YAW] += ent->client->ps.viewangles[YAW] - vr->hmdorientation[YAW];

View file

@ -62,7 +62,7 @@ typedef struct {
menuslider_s heightadjust;
menuradiobutton_s rollhit;
menuslider_s hapticintensity;
menulist_s huddepth;
menuslider_s huddepth;
menuslider_s hudyoffset;
menubitmap_s back;
@ -104,7 +104,7 @@ static void Comfort_MenuEvent( void* ptr, int notification ) {
break;
case ID_HUDDEPTH:
trap_Cvar_SetValue( "vr_hudDepth", s_comfort.huddepth.curvalue );
trap_Cvar_SetValue( "vr_hudDepth", ((int)s_comfort.huddepth.curvalue % NUM_HUDDEPTH));
break;
case ID_HUDYOFFSET:
@ -120,17 +120,6 @@ static void Comfort_MenuEvent( void* ptr, int notification ) {
static void Comfort_MenuInit( void ) {
int y;
static const char *s_hud_depths[] =
{
"Very Close",
"Close",
"Middle",
"Further",
"Far",
"Distant",
NULL
};
memset( &s_comfort, 0 ,sizeof(comfort_t) );
Comfort_Cache();
@ -204,22 +193,22 @@ static void Comfort_MenuInit( void ) {
s_comfort.hapticintensity.maxvalue = 1.0;
y += BIGCHAR_HEIGHT+2;
s_comfort.huddepth.generic.type = MTYPE_SPINCONTROL;
s_comfort.huddepth.generic.type = MTYPE_SLIDER;
s_comfort.huddepth.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_comfort.huddepth.generic.x = VR_X_POS;
s_comfort.huddepth.generic.y = y;
s_comfort.huddepth.generic.name = "HUD Depth:";
s_comfort.huddepth.generic.callback = Comfort_MenuEvent;
s_comfort.huddepth.generic.id = ID_HUDDEPTH;
s_comfort.huddepth.itemnames = s_hud_depths;
s_comfort.huddepth.numitems = NUM_HUDDEPTH;
s_comfort.huddepth.minvalue = 0;
s_comfort.huddepth.maxvalue = 5;
y += BIGCHAR_HEIGHT+2;
s_comfort.hudyoffset.generic.type = MTYPE_SLIDER;
s_comfort.hudyoffset.generic.x = VR_X_POS;
s_comfort.hudyoffset.generic.y = y;
s_comfort.hudyoffset.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_comfort.hudyoffset.generic.name = "HUD Y Offset:";
s_comfort.hudyoffset.generic.name = "HUD Vertical Position:";
s_comfort.hudyoffset.generic.id = ID_HUDYOFFSET;
s_comfort.hudyoffset.generic.callback = Comfort_MenuEvent;
s_comfort.hudyoffset.minvalue = 0;

View file

@ -91,7 +91,7 @@ static void Controls3_SetMenuItems( void ) {
s_controls3.righthanded.curvalue = trap_Cvar_VariableValue( "vr_righthanded" ) != 0;
s_controls3.weaponpitch.curvalue = trap_Cvar_VariableValue( "vr_weaponPitch" ) + 25;
s_controls3.weaponselectormode.curvalue = (int)trap_Cvar_VariableValue( "vr_weaponSelectorMode" ) % 2;
s_controls3.controlschema.curvalue = (int)trap_Cvar_VariableValue( "vr_controlSchema" ) % 2;
s_controls3.controlschema.curvalue = (int)trap_Cvar_VariableValue( "vr_controlSchema" ) % 3;
s_controls3.switchthumbsticks.curvalue = trap_Cvar_VariableValue( "vr_switchThumbsticks" ) != 0;
}
@ -137,16 +137,18 @@ static void Controls3_MenuEvent( void* ptr, int notification ) {
case ID_UTURN:
{
if (s_controls3.uturn.curvalue) {
if (s_controls3.controlschema.curvalue == 0) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "uturn");
} else {
if (s_controls3.controlschema.curvalue == 1) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "uturn");
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "uturn");
}
} else {
if (s_controls3.controlschema.curvalue == 0) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "");
if (s_controls3.controlschema.curvalue == 1) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "blank");
} else if (s_controls3.controlschema.curvalue == 2) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "weapprev");
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "");
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "blank");
}
}
}
@ -157,7 +159,39 @@ static void Controls3_MenuEvent( void* ptr, int notification ) {
{
switch (s_controls3.controlschema.curvalue)
{
case 0: // Default schema
case 0: // Default schema (weapon wheel on grip)
trap_Cvar_Set("vr_button_map_RTHUMBLEFT", "turnleft"); // turn left
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT", "turnright"); // turn right
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD", ""); // unmapped
if (s_controls3.uturn.curvalue) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "uturn"); // u-turn
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", ""); // unmapped
}
trap_Cvar_Set("vr_button_map_PRIMARYGRIP", "+weapon_select"); // weapon selector
trap_Cvar_Set("vr_button_map_PRIMARYTHUMBSTICK", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBLEFT_ALT", ""); // unmapped
break;
case 1: // Weapon wheel on thumbstick - all directions as weapon select (useful for HMD wheel)
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBLEFT", "+weapon_select");
trap_Cvar_Set("vr_button_map_PRIMARYTHUMBSTICK", "+weapon_select");
trap_Cvar_Set("vr_button_map_PRIMARYGRIP", "+alt"); // switch to alt layout
trap_Cvar_Set("vr_button_map_RTHUMBLEFT_ALT", "turnleft"); // turn left
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT_ALT", "turnright"); // turn right
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD_ALT", "blank");
if (s_controls3.uturn.curvalue) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "uturn");
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "blank");
}
break;
default: // Weapon wheel disabled - only prev/next weapon switch is active
trap_Cvar_Set("vr_button_map_RTHUMBLEFT", "turnleft"); // turn left
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT", "turnright"); // turn right
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD", "weapnext"); // next weapon
@ -166,45 +200,12 @@ static void Controls3_MenuEvent( void* ptr, int notification ) {
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "weapprev"); // previous weapon
}
trap_Cvar_Set("vr_button_map_PRIMARYGRIP", "+weapon_select"); // weapon selector
trap_Cvar_Set("vr_button_map_PRIMARYGRIP", "+alt"); // switch to alt layout
trap_Cvar_Set("vr_button_map_PRIMARYTHUMBSTICK", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDRIGHT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDRIGHT_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACKRIGHT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACKRIGHT_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACKLEFT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACKLEFT_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBLEFT_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT_ALT", ""); // unmapped
break;
default: // Now we have only two schemas
// All directions as weapon select (useful for HMD wheel)
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDRIGHT", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBBACKRIGHT", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBBACKLEFT", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBLEFT", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT", "+weapon_select");
trap_Cvar_Set("vr_button_map_PRIMARYTHUMBSTICK", "+weapon_select");
trap_Cvar_Set("vr_button_map_PRIMARYGRIP", "+alt"); // switch to alt layout
trap_Cvar_Set("vr_button_map_RTHUMBLEFT_ALT", "turnleft"); // turn left
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT_ALT", "turnright"); // turn right
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD_ALT", "weapnext");
if (s_controls3.uturn.curvalue) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "uturn");
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "weapprev");
}
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDRIGHT_ALT", "blank"); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACKRIGHT_ALT", "blank"); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACKLEFT_ALT", "blank"); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT_ALT", "blank"); // unmapped
break;
}
}
@ -241,8 +242,8 @@ static void Controls3_MenuInit( void ) {
static const char *s_weaponselectormode[] =
{
"Controller Based",
"HMD/Thumbstick Based",
"VR Style / Pointing",
"Classic / Thumbstick",
NULL
};
@ -250,6 +251,7 @@ static void Controls3_MenuInit( void ) {
{
"Weapon Wheel on Grip",
"Weapon Wheel on Thumbstick",
"Weapon Wheel Disabled",
NULL
};
@ -390,7 +392,7 @@ static void Controls3_MenuInit( void ) {
s_controls3.controlschema.generic.callback = Controls3_MenuEvent;
s_controls3.controlschema.generic.id = ID_CONTROLSCHEMA;
s_controls3.controlschema.itemnames = s_controlschema;
s_controls3.controlschema.numitems = 2;
s_controls3.controlschema.numitems = 3;
s_controls3.back.generic.type = MTYPE_BITMAP;
s_controls3.back.generic.name = ART_BACK0;

View file

@ -128,9 +128,9 @@ Special Thanks to the whole discord!
UI_DrawString( 320, y, "DrBeef", UI_CENTER|UI_SMALLFONT, color_white );
y += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Companion App", UI_CENTER|UI_SMALLFONT, color_red );
UI_DrawProportionalString( 320, y, "Companion App Custom Quest Home", UI_CENTER|UI_SMALLFONT, color_red );
y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawString( 320, y, "Baggyg", UI_CENTER|UI_SMALLFONT, color_white );
UI_DrawString( 320, y, "Baggyg ROBYER1", UI_CENTER|UI_SMALLFONT, color_white );
y += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Additional Quake3Quest coding", UI_CENTER|UI_SMALLFONT, color_red );

View file

@ -405,12 +405,6 @@ extern void PlayerSettings_Cache( void );
extern void UI_PreferencesMenu( void );
extern void Preferences_Cache( void );
//
// ui_vr.c
//
extern void UI_VRMenu( void );
extern void VR_Cache( void );
//
// ui_controls3.c
//

View file

@ -228,18 +228,22 @@ static void Main_MenuDraw( void ) {
int yPos = 410;
if (uis.demoversion) {
UI_DrawProportionalString( 320, 372, "DEMO DEMO DEMO DEMO DEMO DEMO DEMO DEMO DEMO", UI_CENTER|UI_SMALLFONT, color );
yPos = 372;
UI_DrawString( 320, yPos, "Demo: Play the 1st tier of SP or MP on our demo servers", UI_CENTER|UI_SMALLFONT, color_white );
yPos += SMALLCHAR_HEIGHT;
UI_DrawString( 320, yPos, "Install full game for more!", UI_CENTER|UI_SMALLFONT, color_white );
yPos += SMALLCHAR_HEIGHT;
UI_DrawString( 320, yPos, "Quake III Arena(c) 1999-2000, Id Software, Inc. All Rights Reserved", UI_CENTER|UI_SMALLFONT, color );
} else {
UI_DrawString( 320, yPos, "Quake III Arena(c) 1999-2000, Id Software, Inc. All Rights Reserved", UI_CENTER|UI_SMALLFONT, color );
}
yPos += SMALLCHAR_HEIGHT;
UI_DrawString( 320, yPos, "Quake3Quest " Q3QVERSION " - Visit quake3.quakevr.com for discord invite.", UI_CENTER|UI_SMALLFONT, color );
UI_DrawString( 320, yPos, "Quake3Quest " Q3QVERSION " - Visit quake3.quakevr.com for discord invite.", UI_CENTER|UI_SMALLFONT, color_white );
yPos += SMALLCHAR_HEIGHT;
UI_DrawString( 320, yPos, "Join our discord for news, leaderboards and community!", UI_CENTER|UI_SMALLFONT, color );
UI_DrawString( 320, yPos, "Join our discord for news, leaderboards and community!", UI_CENTER|UI_SMALLFONT, color_white );
yPos += SMALLCHAR_HEIGHT;
UI_DrawString( 320, yPos, "Get mods & mappacks via the companion app!", UI_CENTER|UI_SMALLFONT, color );
UI_DrawString( 320, yPos, "Get mods & mappacks via the companion app!", UI_CENTER|UI_SMALLFONT, color_white );
}

View file

@ -41,22 +41,19 @@ GAME OPTIONS MENU
#define ID_CROSSHAIR 127
#define ID_SIMPLEITEMS 128
#define ID_HIGHQUALITYSKY 129
#define ID_EJECTINGBRASS 130
#define ID_WALLMARKS 131
#define ID_DYNAMICLIGHTS 132
#define ID_IDENTIFYTARGET 133
#define ID_SYNCEVERYFRAME 134
#define ID_FORCEMODEL 135
#define ID_DRAWTEAMOVERLAY 136
#define ID_ALLOWDOWNLOAD 137
#define ID_LASERSIGHT 138
#define ID_DRAWHUD 139
#define ID_HOLSTER2D 140
#define ID_GORE 141
#define ID_SHOWINHAND 142
#define ID_SELECTORWITHHUD 143
#define ID_BACK 144
#define ID_EJECTINGBRASS 129
#define ID_WALLMARKS 130
#define ID_IDENTIFYTARGET 131
#define ID_FORCEMODEL 132
#define ID_DRAWTEAMOVERLAY 133
#define ID_LASERSIGHT 134
#define ID_DRAWHUD 135
#define ID_HOLSTER2D 136
#define ID_GORE 137
#define ID_SHOWINHAND 138
#define ID_SELECTORWITHHUD 139
#define ID_SHOWCONSOLE 140
#define ID_BACK 141
#define NUM_CROSSHAIRS 10
#define NUM_GORE 4
@ -74,18 +71,15 @@ typedef struct {
menuradiobutton_s simpleitems;
menuradiobutton_s brass;
menuradiobutton_s wallmarks;
menuradiobutton_s dynamiclights;
menuradiobutton_s identifytarget;
menuradiobutton_s highqualitysky;
menuradiobutton_s synceveryframe;
menuradiobutton_s forcemodel;
menulist_s drawteamoverlay;
menuradiobutton_s drawhud;
menuradiobutton_s allowdownload;
menulist_s drawhud;
menuradiobutton_s holster2d;
menulist_s gore;
menuradiobutton_s showinhand;
menuradiobutton_s selectorwithhud;
menuradiobutton_s showconsole;
menubitmap_s back;
qhandle_t crosshairShader[NUM_CROSSHAIRS];
@ -93,12 +87,20 @@ typedef struct {
static preferences_t s_preferences;
static const char *hud_names[] =
{
"Off",
"Floating",
"Fixed to View",
NULL
};
static const char *teamoverlay_names[] =
{
"off",
"upper right",
"lower right",
"lower left",
"Off",
"Upper Right",
"Lower Right",
"Lower Left",
NULL
};
@ -118,17 +120,14 @@ static void Preferences_SetMenuItems( void ) {
s_preferences.brass.curvalue = trap_Cvar_VariableValue( "cg_brassTime" ) != 0;
s_preferences.wallmarks.curvalue = trap_Cvar_VariableValue( "cg_marks" ) != 0;
s_preferences.identifytarget.curvalue = trap_Cvar_VariableValue( "cg_drawCrosshairNames" ) != 0;
// s_preferences.dynamiclights.curvalue = trap_Cvar_VariableValue( "r_dynamiclight" ) != 0;
s_preferences.highqualitysky.curvalue = trap_Cvar_VariableValue ( "r_fastsky" ) == 0;
// s_preferences.synceveryframe.curvalue = trap_Cvar_VariableValue( "r_finish" ) != 0;
s_preferences.forcemodel.curvalue = trap_Cvar_VariableValue( "cg_forcemodel" ) != 0;
s_preferences.drawteamoverlay.curvalue = Com_Clamp( 0, 3, trap_Cvar_VariableValue( "cg_drawTeamOverlay" ) );
s_preferences.drawhud.curvalue = trap_Cvar_VariableValue( "cg_drawStatus" ) != 0;
// s_preferences.allowdownload.curvalue = trap_Cvar_VariableValue( "cl_allowDownload" ) != 0;
s_preferences.drawhud.curvalue = trap_Cvar_VariableValue( "vr_hudDrawStatus" );
s_preferences.holster2d.curvalue = trap_Cvar_VariableValue( "cg_weaponSelectorSimple2DIcons" ) != 0;
s_preferences.gore.curvalue = trap_Cvar_VariableValue( "vr_goreLevel" );
s_preferences.showinhand.curvalue = trap_Cvar_VariableValue( "vr_showItemInHand" ) != 0;
s_preferences.selectorwithhud.curvalue = trap_Cvar_VariableValue( "vr_weaponSelectorWithHud" ) != 0;
s_preferences.showconsole.curvalue = trap_Cvar_VariableValue( "vr_showConsoleMessages" ) != 0;
}
@ -146,10 +145,6 @@ static void Preferences_Event( void* ptr, int notification ) {
trap_Cvar_SetValue( "cg_simpleItems", s_preferences.simpleitems.curvalue );
break;
case ID_HIGHQUALITYSKY:
trap_Cvar_SetValue( "r_fastsky", !s_preferences.highqualitysky.curvalue );
break;
case ID_EJECTINGBRASS:
if ( s_preferences.brass.curvalue )
trap_Cvar_Reset( "cg_brassTime" );
@ -161,18 +156,10 @@ static void Preferences_Event( void* ptr, int notification ) {
trap_Cvar_SetValue( "cg_marks", s_preferences.wallmarks.curvalue );
break;
case ID_DYNAMICLIGHTS:
trap_Cvar_SetValue( "r_dynamiclight", s_preferences.dynamiclights.curvalue );
break;
case ID_IDENTIFYTARGET:
trap_Cvar_SetValue( "cg_drawCrosshairNames", s_preferences.identifytarget.curvalue );
break;
case ID_SYNCEVERYFRAME:
trap_Cvar_SetValue( "r_finish", s_preferences.synceveryframe.curvalue );
break;
case ID_FORCEMODEL:
trap_Cvar_SetValue( "cg_forcemodel", s_preferences.forcemodel.curvalue );
break;
@ -181,17 +168,13 @@ static void Preferences_Event( void* ptr, int notification ) {
trap_Cvar_SetValue( "cg_drawTeamOverlay", s_preferences.drawteamoverlay.curvalue );
break;
case ID_ALLOWDOWNLOAD:
trap_Cvar_SetValue( "cl_allowDownload", s_preferences.allowdownload.curvalue );
trap_Cvar_SetValue( "sv_allowDownload", s_preferences.allowdownload.curvalue );
break;
case ID_LASERSIGHT:
trap_Cvar_SetValue( "vr_lasersight", s_preferences.lasersight.curvalue);
break;
case ID_DRAWHUD:
trap_Cvar_SetValue( "cg_drawStatus", s_preferences.drawhud.curvalue );
trap_Cvar_SetValue( "vr_hudDrawStatus", s_preferences.drawhud.curvalue );
trap_Cvar_SetValue("cg_draw3dIcons", (s_preferences.drawhud.curvalue == 2) ? 0 : 1);
break;
case ID_HOLSTER2D:
@ -232,6 +215,10 @@ static void Preferences_Event( void* ptr, int notification ) {
trap_Cvar_SetValue( "vr_weaponSelectorWithHud", s_preferences.selectorwithhud.curvalue);
break;
case ID_SHOWCONSOLE:
trap_Cvar_SetValue( "vr_showConsoleMessages", s_preferences.showconsole.curvalue);
break;
case ID_BACK:
UI_PopMenu();
break;
@ -321,7 +308,7 @@ static void Preferences_MenuInit( void ) {
s_preferences.framer.width = 256;
s_preferences.framer.height = 334;
y = 92;
y = 100;
s_preferences.crosshair.generic.type = MTYPE_SPINCONTROL;
s_preferences.crosshair.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT|QMF_NODEFAULTINIT|QMF_OWNERDRAW;
s_preferences.crosshair.generic.x = PREFERENCES_X_POS;
@ -390,15 +377,6 @@ static void Preferences_MenuInit( void ) {
s_preferences.brass.generic.x = PREFERENCES_X_POS;
s_preferences.brass.generic.y = y;
// y += BIGCHAR_HEIGHT+2;
// s_preferences.dynamiclights.generic.type = MTYPE_RADIOBUTTON;
// s_preferences.dynamiclights.generic.name = "Dynamic Lights:";
// s_preferences.dynamiclights.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
// s_preferences.dynamiclights.generic.callback = Preferences_Event;
// s_preferences.dynamiclights.generic.id = ID_DYNAMICLIGHTS;
// s_preferences.dynamiclights.generic.x = PREFERENCES_X_POS;
// s_preferences.dynamiclights.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.identifytarget.generic.type = MTYPE_RADIOBUTTON;
s_preferences.identifytarget.generic.name = "Identify Target:";
@ -408,24 +386,6 @@ static void Preferences_MenuInit( void ) {
s_preferences.identifytarget.generic.x = PREFERENCES_X_POS;
s_preferences.identifytarget.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.highqualitysky.generic.type = MTYPE_RADIOBUTTON;
s_preferences.highqualitysky.generic.name = "High Quality Sky:";
s_preferences.highqualitysky.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.highqualitysky.generic.callback = Preferences_Event;
s_preferences.highqualitysky.generic.id = ID_HIGHQUALITYSKY;
s_preferences.highqualitysky.generic.x = PREFERENCES_X_POS;
s_preferences.highqualitysky.generic.y = y;
// y += BIGCHAR_HEIGHT+2;
// s_preferences.synceveryframe.generic.type = MTYPE_RADIOBUTTON;
// s_preferences.synceveryframe.generic.name = "Sync Every Frame:";
// s_preferences.synceveryframe.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
// s_preferences.synceveryframe.generic.callback = Preferences_Event;
// s_preferences.synceveryframe.generic.id = ID_SYNCEVERYFRAME;
// s_preferences.synceveryframe.generic.x = PREFERENCES_X_POS;
// s_preferences.synceveryframe.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.forcemodel.generic.type = MTYPE_RADIOBUTTON;
s_preferences.forcemodel.generic.name = "Force Player Models:";
@ -446,13 +406,14 @@ static void Preferences_MenuInit( void ) {
s_preferences.drawteamoverlay.itemnames = teamoverlay_names;
y += BIGCHAR_HEIGHT+2;
s_preferences.drawhud.generic.type = MTYPE_RADIOBUTTON;
s_preferences.drawhud.generic.name = "Draw HUD:";
s_preferences.drawhud.generic.type = MTYPE_SPINCONTROL;
s_preferences.drawhud.generic.name = "HUD Mode:";
s_preferences.drawhud.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.drawhud.generic.callback = Preferences_Event;
s_preferences.drawhud.generic.id = ID_DRAWHUD;
s_preferences.drawhud.generic.x = PREFERENCES_X_POS;
s_preferences.drawhud.generic.y = y;
s_preferences.drawhud.itemnames = hud_names;
y += BIGCHAR_HEIGHT+2;
s_preferences.selectorwithhud.generic.type = MTYPE_RADIOBUTTON;
@ -463,14 +424,14 @@ static void Preferences_MenuInit( void ) {
s_preferences.selectorwithhud.generic.x = PREFERENCES_X_POS;
s_preferences.selectorwithhud.generic.y = y;
// y += BIGCHAR_HEIGHT+2;
// s_preferences.allowdownload.generic.type = MTYPE_RADIOBUTTON;
// s_preferences.allowdownload.generic.name = "Automatic Downloading:";
// s_preferences.allowdownload.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
// s_preferences.allowdownload.generic.callback = Preferences_Event;
// s_preferences.allowdownload.generic.id = ID_ALLOWDOWNLOAD;
// s_preferences.allowdownload.generic.x = PREFERENCES_X_POS;
// s_preferences.allowdownload.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.showconsole.generic.type = MTYPE_RADIOBUTTON;
s_preferences.showconsole.generic.name = "Show Console Messages:";
s_preferences.showconsole.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.showconsole.generic.callback = Preferences_Event;
s_preferences.showconsole.generic.id = ID_SHOWCONSOLE;
s_preferences.showconsole.generic.x = PREFERENCES_X_POS;
s_preferences.showconsole.generic.y = y;
y += BIGCHAR_HEIGHT+16;
s_preferences.gore.generic.type = MTYPE_SPINCONTROL;
@ -503,18 +464,15 @@ static void Preferences_MenuInit( void ) {
Menu_AddItem( &s_preferences.menu, &s_preferences.simpleitems );
Menu_AddItem( &s_preferences.menu, &s_preferences.wallmarks );
Menu_AddItem( &s_preferences.menu, &s_preferences.brass );
// Menu_AddItem( &s_preferences.menu, &s_preferences.dynamiclights );
Menu_AddItem( &s_preferences.menu, &s_preferences.identifytarget );
Menu_AddItem( &s_preferences.menu, &s_preferences.highqualitysky );
// Menu_AddItem( &s_preferences.menu, &s_preferences.synceveryframe );
Menu_AddItem( &s_preferences.menu, &s_preferences.forcemodel );
Menu_AddItem( &s_preferences.menu, &s_preferences.drawteamoverlay );
Menu_AddItem( &s_preferences.menu, &s_preferences.drawhud );
Menu_AddItem( &s_preferences.menu, &s_preferences.holster2d );
// Menu_AddItem( &s_preferences.menu, &s_preferences.allowdownload );
Menu_AddItem( &s_preferences.menu, &s_preferences.gore );
Menu_AddItem( &s_preferences.menu, &s_preferences.showinhand );
Menu_AddItem( &s_preferences.menu, &s_preferences.selectorwithhud );
Menu_AddItem( &s_preferences.menu, &s_preferences.showconsole );
Menu_AddItem( &s_preferences.menu, &s_preferences.back );

View file

@ -1243,11 +1243,11 @@ static void ArenaServers_Event( void* ptr, int event ) {
break;
case ID_SCROLL_UP:
ScrollList_Key( &g_arenaservers.list, K_UPARROW );
ScrollList_Key( &g_arenaservers.list, K_PGUP );
break;
case ID_SCROLL_DOWN:
ScrollList_Key( &g_arenaservers.list, K_DOWNARROW );
ScrollList_Key( &g_arenaservers.list, K_PGDN );
break;
case ID_BACK:

View file

@ -44,12 +44,11 @@ SETUP MENU
#define ID_COMFORT 12
#define ID_GAME 13
#define ID_SYSTEMCONFIG 14
#define ID_VR 15
#define ID_CDKEY 16
#define ID_LOAD 17
#define ID_SAVE 18
#define ID_DEFAULTS 19
#define ID_BACK 20
#define ID_CDKEY 15
#define ID_LOAD 16
#define ID_SAVE 17
#define ID_DEFAULTS 18
#define ID_BACK 19
typedef struct {
@ -63,7 +62,6 @@ typedef struct {
menutext_s comfort;
menutext_s game;
menutext_s setupsystem;
// menutext_s vr;
// menutext_s cdkey;
// menutext_s load;
// menutext_s save;
@ -131,10 +129,6 @@ static void UI_SetupMenu_Event( void *ptr, int event ) {
UI_GraphicsOptionsMenu();
break;
// case ID_VR:
// UI_VRMenu();
// break;
// case ID_CDKEY:
// UI_CDKeyMenu();
// break;

View file

@ -317,7 +317,7 @@ static void UI_SoundOptionsMenu_Init( void ) {
soundOptionsInfo.sfxvolume.generic.x = 400;
soundOptionsInfo.sfxvolume.generic.y = y;
soundOptionsInfo.sfxvolume.minvalue = 0;
soundOptionsInfo.sfxvolume.maxvalue = 10;
soundOptionsInfo.sfxvolume.maxvalue = 7;
y += BIGCHAR_HEIGHT+2;
soundOptionsInfo.musicvolume.generic.type = MTYPE_SLIDER;
@ -328,7 +328,7 @@ static void UI_SoundOptionsMenu_Init( void ) {
soundOptionsInfo.musicvolume.generic.x = 400;
soundOptionsInfo.musicvolume.generic.y = y;
soundOptionsInfo.musicvolume.minvalue = 0;
soundOptionsInfo.musicvolume.maxvalue = 10;
soundOptionsInfo.musicvolume.maxvalue = 7;
y += BIGCHAR_HEIGHT+2;
soundOptionsInfo.soundSystem.generic.type = MTYPE_SPINCONTROL;

File diff suppressed because it is too large Load diff

View file

@ -1,605 +0,0 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Quake III Arena source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
VR OPTIONS MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define VR_X_POS 360
#define ID_HUDDEPTH 127
#define ID_RIGHTHANDED 128
#define ID_AUTOSWITCH 129
#define ID_SNAPTURN 130
#define ID_DIRECTIONMODE 131
#define ID_REFRESHRATE 133
#define ID_WEAPONPITCH 134
#define ID_HEIGHTADJUST 135
#define ID_TWOHANDED 136
#define ID_SCOPE 137
#define ID_DRAWHUD 138
#define ID_ROLLHIT 139
#define ID_HUDYOFFSET 140
#define ID_SENDROLL 141
#define ID_LASERSIGHT 142
#define ID_GORE 143
#define ID_HAPTICINTENSITY 144
#define ID_HOLSTER2D 145
#define ID_BODYSCALE 146
#define ID_BACK 147
#define NUM_HUDDEPTH 6
#define NUM_DIRECTIONMODE 2
#define NUM_REFRESHRATE 4
#define NUM_GORE 4
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menuradiobutton_s drawhud;
menulist_s huddepth;
menuradiobutton_s righthanded;
menuradiobutton_s autoswitch;
menulist_s snapturn;
menulist_s directionmode;
menulist_s refreshrate;
menuslider_s weaponpitch;
menuslider_s heightadjust;
menuradiobutton_s twohanded;
menuradiobutton_s scope;
menuradiobutton_s rollhit;
menuslider_s hudyoffset;
menuradiobutton_s sendroll;
menuradiobutton_s lasersight;
menuslider_s hapticintensity;
menuradiobutton_s holster2d;
menuslider_s bodyscale;
menulist_s gore;
menubitmap_s back;
} VR_t;
static VR_t s_VR;
static void VR_SetMenuItems( void ) {
s_VR.drawhud.curvalue = trap_Cvar_VariableValue( "cg_drawStatus" ) != 0;
s_VR.huddepth.curvalue = (int)trap_Cvar_VariableValue( "vr_hudDepth" ) % NUM_HUDDEPTH;
s_VR.righthanded.curvalue = trap_Cvar_VariableValue( "vr_righthanded" ) != 0;
s_VR.autoswitch.curvalue = trap_Cvar_VariableValue( "cg_autoswitch" ) != 0;
s_VR.snapturn.curvalue = (int)trap_Cvar_VariableValue( "vr_snapturn" ) / 45;
s_VR.directionmode.curvalue = (int)trap_Cvar_VariableValue( "vr_directionMode" ) % NUM_DIRECTIONMODE;
int refresh = (int)trap_Cvar_VariableValue( "vr_refreshrate" );
switch (refresh)
{
case 60:
s_VR.refreshrate.curvalue = 0;
break;
case 72:
s_VR.refreshrate.curvalue = 1;
break;
case 80:
s_VR.refreshrate.curvalue = 2;
break;
case 90:
s_VR.refreshrate.curvalue = 3;
break;
}
s_VR.weaponpitch.curvalue = trap_Cvar_VariableValue( "vr_weaponPitch" ) + 25;
s_VR.heightadjust.curvalue = trap_Cvar_VariableValue( "vr_heightAdjust" );
s_VR.twohanded.curvalue = trap_Cvar_VariableValue( "vr_twoHandedWeapons" ) != 0;
s_VR.scope.curvalue = trap_Cvar_VariableValue( "vr_weaponScope" ) != 0;
s_VR.rollhit.curvalue = trap_Cvar_VariableValue( "vr_rollWhenHit" ) != 0;
s_VR.hudyoffset.curvalue = trap_Cvar_VariableValue( "vr_hudYOffset" ) + 200;
s_VR.sendroll.curvalue = trap_Cvar_VariableValue( "vr_sendRollToServer" ) != 0;
s_VR.lasersight.curvalue = trap_Cvar_VariableValue( "vr_lasersight" ) != 0;
s_VR.hapticintensity.curvalue = trap_Cvar_VariableValue( "vr_hapticIntensity" );
s_VR.holster2d.curvalue = trap_Cvar_VariableValue( "cg_weaponSelectorSimple2DIcons" ) != 0;
s_VR.bodyscale.curvalue = trap_Cvar_VariableValue( "cg_firstPersonBodyScale" );
//GORE
{
int level = trap_Cvar_VariableValue( "com_blood" ) +
trap_Cvar_VariableValue( "cg_gibs" ) +
trap_Cvar_VariableValue( "cg_megagibs" );
s_VR.gore.curvalue = level % NUM_GORE;
}
}
static void VR_Event( void* ptr, int notification ) {
if( notification != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_HUDDEPTH:
trap_Cvar_SetValue( "vr_hudDepth", s_VR.huddepth.curvalue );
break;
case ID_RIGHTHANDED:
trap_Cvar_SetValue( "vr_righthanded", s_VR.righthanded.curvalue );
break;
case ID_AUTOSWITCH:
trap_Cvar_SetValue( "cg_autoswitch", s_VR.autoswitch.curvalue );
break;
case ID_SNAPTURN:
trap_Cvar_SetValue( "vr_snapturn", s_VR.snapturn.curvalue * 45 );
break;
case ID_DIRECTIONMODE:
trap_Cvar_SetValue( "vr_directionMode", s_VR.directionmode.curvalue );
break;
case ID_REFRESHRATE: {
int refresh;
switch (s_VR.refreshrate.curvalue) {
case 0:
refresh = 60;
break;
case 1:
refresh = 72;
break;
case 2:
refresh = 80;
break;
case 3:
refresh = 90;
break;
}
trap_Cvar_SetValue("vr_refreshrate", refresh);
}
break;
case ID_WEAPONPITCH:
trap_Cvar_SetValue( "vr_weaponPitch", s_VR.weaponpitch.curvalue - 25 );
break;
case ID_HEIGHTADJUST:
trap_Cvar_SetValue( "vr_heightAdjust", s_VR.heightadjust.curvalue );
break;
case ID_TWOHANDED:
trap_Cvar_SetValue( "vr_twoHandedWeapons", s_VR.twohanded.curvalue );
break;
case ID_SCOPE:
trap_Cvar_SetValue( "vr_weaponScope", s_VR.scope.curvalue );
break;
case ID_DRAWHUD:
trap_Cvar_SetValue( "cg_drawStatus", s_VR.drawhud.curvalue );
break;
case ID_ROLLHIT:
trap_Cvar_SetValue( "vr_rollWhenHit", s_VR.rollhit.curvalue );
break;
case ID_HUDYOFFSET:
trap_Cvar_SetValue( "vr_hudYOffset", s_VR.hudyoffset.curvalue - 200);
break;
case ID_SENDROLL:
trap_Cvar_SetValue( "vr_sendRollToServer", s_VR.sendroll.curvalue);
break;
case ID_LASERSIGHT:
trap_Cvar_SetValue( "vr_lasersight", s_VR.lasersight.curvalue);
break;
case ID_HAPTICINTENSITY:
trap_Cvar_SetValue( "vr_hapticIntensity", s_VR.hapticintensity.curvalue);
break;
case ID_HOLSTER2D:
trap_Cvar_SetValue( "cg_weaponSelectorSimple2DIcons", s_VR.holster2d.curvalue);
break;
case ID_BODYSCALE:
trap_Cvar_SetValue( "cg_firstPersonBodyScale", s_VR.bodyscale.curvalue);
break;
case ID_GORE: {
switch ((int)s_VR.gore.curvalue) {
case 0:
trap_Cvar_SetValue( "com_blood", 0);
trap_Cvar_SetValue( "cg_gibs", 0);
trap_Cvar_SetValue( "cg_megagibs", 0);
break;
case 1:
trap_Cvar_SetValue( "com_blood", 1);
trap_Cvar_SetValue( "cg_gibs", 0);
trap_Cvar_SetValue( "cg_megagibs", 0);
break;
case 2:
trap_Cvar_SetValue( "com_blood", 1);
trap_Cvar_SetValue( "cg_gibs", 1);
trap_Cvar_SetValue( "cg_megagibs", 0);
break;
case 3:
trap_Cvar_SetValue( "com_blood", 1);
trap_Cvar_SetValue( "cg_gibs", 1);
trap_Cvar_SetValue( "cg_megagibs", 1);
break;
}
}
break;
case ID_BACK:
UI_PopMenu();
break;
}
}
static void VR_MenuInit( void ) {
int y;
static const char *s_hud_depths[] =
{
"Very Close",
"Close",
"Middle",
"Further",
"Far",
"Distant",
NULL
};
static const char *s_snapturn[] =
{
"Smooth Turning",
"45 Degrees",
"90 Degrees",
NULL
};
static const char *s_directionmode[] =
{
"HMD (Default)",
"Off-hand Controller",
NULL
};
static const char *s_refreshrate[] =
{
"60",
"72 (Default)",
"80",
"90",
NULL
};
static const char *s_gore[] =
{
"None",
"Blood Only",
"Blood & Gibs (Default)",
"Extra Gore (Performance Hit)",
NULL
};
memset( &s_VR, 0 ,sizeof(VR_t) );
VR_Cache();
s_VR.menu.wrapAround = qtrue;
s_VR.menu.fullscreen = qtrue;
s_VR.banner.generic.type = MTYPE_BTEXT;
s_VR.banner.generic.x = 320;
s_VR.banner.generic.y = 16;
s_VR.banner.string = "GAME OPTIONS";
s_VR.banner.color = color_white;
s_VR.banner.style = UI_CENTER;
s_VR.framel.generic.type = MTYPE_BITMAP;
s_VR.framel.generic.name = ART_FRAMEL;
s_VR.framel.generic.flags = QMF_INACTIVE;
s_VR.framel.generic.x = 0;
s_VR.framel.generic.y = 78;
s_VR.framel.width = 256;
s_VR.framel.height = 329;
s_VR.framer.generic.type = MTYPE_BITMAP;
s_VR.framer.generic.name = ART_FRAMER;
s_VR.framer.generic.flags = QMF_INACTIVE;
s_VR.framer.generic.x = 376;
s_VR.framer.generic.y = 76;
s_VR.framer.width = 256;
s_VR.framer.height = 334;
y = 84;
s_VR.drawhud.generic.type = MTYPE_RADIOBUTTON;
s_VR.drawhud.generic.name = "Draw HUD:";
s_VR.drawhud.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_VR.drawhud.generic.callback = VR_Event;
s_VR.drawhud.generic.id = ID_DRAWHUD;
s_VR.drawhud.generic.x = VR_X_POS;
s_VR.drawhud.generic.y = y;
y += BIGCHAR_HEIGHT;
s_VR.huddepth.generic.type = MTYPE_SPINCONTROL;
s_VR.huddepth.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_VR.huddepth.generic.x = VR_X_POS;
s_VR.huddepth.generic.y = y;
s_VR.huddepth.generic.name = "HUD Depth:";
s_VR.huddepth.generic.callback = VR_Event;
s_VR.huddepth.generic.id = ID_HUDDEPTH;
s_VR.huddepth.itemnames = s_hud_depths;
s_VR.huddepth.numitems = NUM_HUDDEPTH;
y += BIGCHAR_HEIGHT;
s_VR.righthanded.generic.type = MTYPE_RADIOBUTTON;
s_VR.righthanded.generic.name = "Right-Handed:";
s_VR.righthanded.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_VR.righthanded.generic.callback = VR_Event;
s_VR.righthanded.generic.id = ID_RIGHTHANDED;
s_VR.righthanded.generic.x = VR_X_POS;
s_VR.righthanded.generic.y = y;
y += BIGCHAR_HEIGHT;
s_VR.autoswitch.generic.type = MTYPE_RADIOBUTTON;
s_VR.autoswitch.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_VR.autoswitch.generic.name = "Autoswitch Weapons:";
s_VR.autoswitch.generic.id = ID_AUTOSWITCH;
s_VR.autoswitch.generic.callback = VR_Event;
s_VR.autoswitch.generic.x = VR_X_POS;
s_VR.autoswitch.generic.y = y;
y += BIGCHAR_HEIGHT;
s_VR.snapturn.generic.type = MTYPE_SPINCONTROL;
s_VR.snapturn.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_VR.snapturn.generic.x = VR_X_POS;
s_VR.snapturn.generic.y = y;
s_VR.snapturn.generic.name = "Turning Mode:";
s_VR.snapturn.generic.callback = VR_Event;
s_VR.snapturn.generic.id = ID_SNAPTURN;
s_VR.snapturn.itemnames = s_snapturn;
s_VR.snapturn.numitems = 3;
y += BIGCHAR_HEIGHT;
s_VR.directionmode.generic.type = MTYPE_SPINCONTROL;
s_VR.directionmode.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_VR.directionmode.generic.x = VR_X_POS;
s_VR.directionmode.generic.y = y;
s_VR.directionmode.generic.name = "Direction Mode:";
s_VR.directionmode.generic.callback = VR_Event;
s_VR.directionmode.generic.id = ID_DIRECTIONMODE;
s_VR.directionmode.itemnames = s_directionmode;
s_VR.directionmode.numitems = NUM_DIRECTIONMODE;
y += BIGCHAR_HEIGHT;
s_VR.refreshrate.generic.type = MTYPE_SPINCONTROL;
s_VR.refreshrate.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_VR.refreshrate.generic.x = VR_X_POS;
s_VR.refreshrate.generic.y = y;
s_VR.refreshrate.generic.name = "Refresh Rate:";
s_VR.refreshrate.generic.callback = VR_Event;
s_VR.refreshrate.generic.id = ID_REFRESHRATE;
s_VR.refreshrate.itemnames = s_refreshrate;
s_VR.refreshrate.numitems = NUM_REFRESHRATE;
y += BIGCHAR_HEIGHT;
s_VR.weaponpitch.generic.type = MTYPE_SLIDER;
s_VR.weaponpitch.generic.x = VR_X_POS;
s_VR.weaponpitch.generic.y = y;
s_VR.weaponpitch.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_VR.weaponpitch.generic.name = "Weapon Pitch:";
s_VR.weaponpitch.generic.id = ID_WEAPONPITCH;
s_VR.weaponpitch.generic.callback = VR_Event;
s_VR.weaponpitch.minvalue = 0;
s_VR.weaponpitch.maxvalue = 30;
y += BIGCHAR_HEIGHT;
s_VR.heightadjust.generic.type = MTYPE_SLIDER;
s_VR.heightadjust.generic.x = VR_X_POS;
s_VR.heightadjust.generic.y = y;
s_VR.heightadjust.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_VR.heightadjust.generic.name = "Height Adjust:";
s_VR.heightadjust.generic.id = ID_HEIGHTADJUST;
s_VR.heightadjust.generic.callback = VR_Event;
s_VR.heightadjust.minvalue = 0.0f;
s_VR.heightadjust.maxvalue = 1.0f;
y += BIGCHAR_HEIGHT;
s_VR.twohanded.generic.type = MTYPE_RADIOBUTTON;
s_VR.twohanded.generic.name = "Two-Handed Weapons:";
s_VR.twohanded.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_VR.twohanded.generic.callback = VR_Event;
s_VR.twohanded.generic.id = ID_TWOHANDED;
s_VR.twohanded.generic.x = VR_X_POS;
s_VR.twohanded.generic.y = y;
y += BIGCHAR_HEIGHT;
s_VR.scope.generic.type = MTYPE_RADIOBUTTON;
s_VR.scope.generic.name = "Railgun Scope:";
s_VR.scope.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_VR.scope.generic.callback = VR_Event;
s_VR.scope.generic.id = ID_SCOPE;
s_VR.scope.generic.x = VR_X_POS;
s_VR.scope.generic.y = y;
y += BIGCHAR_HEIGHT;
s_VR.rollhit.generic.type = MTYPE_RADIOBUTTON;
s_VR.rollhit.generic.name = "Roll when hit:";
s_VR.rollhit.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_VR.rollhit.generic.callback = VR_Event;
s_VR.rollhit.generic.id = ID_ROLLHIT;
s_VR.rollhit.generic.x = VR_X_POS;
s_VR.rollhit.generic.y = y;
y += BIGCHAR_HEIGHT;
s_VR.hudyoffset.generic.type = MTYPE_SLIDER;
s_VR.hudyoffset.generic.x = VR_X_POS;
s_VR.hudyoffset.generic.y = y;
s_VR.hudyoffset.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_VR.hudyoffset.generic.name = "HUD Y Offset:";
s_VR.hudyoffset.generic.id = ID_HUDYOFFSET;
s_VR.hudyoffset.generic.callback = VR_Event;
s_VR.hudyoffset.minvalue = 0;
s_VR.hudyoffset.maxvalue = 400;
y += BIGCHAR_HEIGHT;
s_VR.sendroll.generic.type = MTYPE_RADIOBUTTON;
s_VR.sendroll.generic.name = "Send Roll Angle to Server:";
s_VR.sendroll.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_VR.sendroll.generic.callback = VR_Event;
s_VR.sendroll.generic.id = ID_SENDROLL;
s_VR.sendroll.generic.x = VR_X_POS;
s_VR.sendroll.generic.y = y;
y += BIGCHAR_HEIGHT;
s_VR.lasersight.generic.type = MTYPE_RADIOBUTTON;
s_VR.lasersight.generic.name = "Laser Sight:";
s_VR.lasersight.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_VR.lasersight.generic.callback = VR_Event;
s_VR.lasersight.generic.id = ID_LASERSIGHT;
s_VR.lasersight.generic.x = VR_X_POS;
s_VR.lasersight.generic.y = y;
y += BIGCHAR_HEIGHT;
s_VR.hapticintensity.generic.type = MTYPE_SLIDER;
s_VR.hapticintensity.generic.x = VR_X_POS;
s_VR.hapticintensity.generic.y = y;
s_VR.hapticintensity.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_VR.hapticintensity.generic.name = "Haptic Intensity:";
s_VR.hapticintensity.generic.id = ID_HAPTICINTENSITY;
s_VR.hapticintensity.generic.callback = VR_Event;
s_VR.hapticintensity.minvalue = 0;
s_VR.hapticintensity.maxvalue = 1.0;
y += BIGCHAR_HEIGHT;
s_VR.holster2d.generic.type = MTYPE_RADIOBUTTON;
s_VR.holster2d.generic.name = "Simple Icons on Weapon Selector:";
s_VR.holster2d.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_VR.holster2d.generic.callback = VR_Event;
s_VR.holster2d.generic.id = ID_HOLSTER2D;
s_VR.holster2d.generic.x = VR_X_POS;
s_VR.holster2d.generic.y = y;
y += BIGCHAR_HEIGHT;
s_VR.bodyscale.generic.type = MTYPE_SLIDER;
s_VR.bodyscale.generic.name = "1st-Person Body Scale:";
s_VR.bodyscale.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_VR.bodyscale.generic.callback = VR_Event;
s_VR.bodyscale.generic.id = ID_BODYSCALE;
s_VR.bodyscale.generic.x = VR_X_POS;
s_VR.bodyscale.generic.y = y;
s_VR.bodyscale.minvalue = 0.0f;
s_VR.bodyscale.maxvalue = 1.0f;
y += BIGCHAR_HEIGHT + 10;
s_VR.gore.generic.type = MTYPE_SPINCONTROL;
s_VR.gore.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_VR.gore.generic.x = VR_X_POS - 120;
s_VR.gore.generic.y = y;
s_VR.gore.generic.name = "Gore:";
s_VR.gore.generic.callback = VR_Event;
s_VR.gore.generic.id = ID_GORE;
s_VR.gore.itemnames = s_gore;
s_VR.gore.numitems = NUM_GORE;
s_VR.back.generic.type = MTYPE_BITMAP;
s_VR.back.generic.name = ART_BACK0;
s_VR.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_VR.back.generic.callback = VR_Event;
s_VR.back.generic.id = ID_BACK;
s_VR.back.generic.x = 0;
s_VR.back.generic.y = 480-64;
s_VR.back.width = 128;
s_VR.back.height = 64;
s_VR.back.focuspic = ART_BACK1;
Menu_AddItem( &s_VR.menu, &s_VR.banner );
Menu_AddItem( &s_VR.menu, &s_VR.framel );
Menu_AddItem( &s_VR.menu, &s_VR.framer );
Menu_AddItem( &s_VR.menu, &s_VR.huddepth );
Menu_AddItem( &s_VR.menu, &s_VR.righthanded );
Menu_AddItem( &s_VR.menu, &s_VR.autoswitch );
Menu_AddItem( &s_VR.menu, &s_VR.snapturn );
Menu_AddItem( &s_VR.menu, &s_VR.directionmode );
Menu_AddItem( &s_VR.menu, &s_VR.refreshrate );
Menu_AddItem( &s_VR.menu, &s_VR.weaponpitch );
Menu_AddItem( &s_VR.menu, &s_VR.heightadjust );
Menu_AddItem( &s_VR.menu, &s_VR.twohanded );
Menu_AddItem( &s_VR.menu, &s_VR.scope );
Menu_AddItem( &s_VR.menu, &s_VR.rollhit );
Menu_AddItem( &s_VR.menu, &s_VR.hudyoffset );
Menu_AddItem( &s_VR.menu, &s_VR.sendroll );
Menu_AddItem( &s_VR.menu, &s_VR.lasersight );
Menu_AddItem( &s_VR.menu, &s_VR.holster2d );
Menu_AddItem( &s_VR.menu, &s_VR.hapticintensity );
Menu_AddItem( &s_VR.menu, &s_VR.bodyscale );
Menu_AddItem( &s_VR.menu, &s_VR.gore );
Menu_AddItem( &s_VR.menu, &s_VR.back );
VR_SetMenuItems();
}
/*
===============
VR_Cache
===============
*/
void VR_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
}
/*
===============
UI_VRMenu
===============
*/
void UI_VRMenu( void ) {
VR_MenuInit();
UI_PushMenu( &s_VR.menu );
}

View file

@ -256,6 +256,11 @@ extern void (APIENTRYP qglUnlockArraysEXT) (void);
GLE(void, FramebufferTexture2D, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) \
GLE(void, FramebufferRenderbuffer, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) \
GLE(void, GenerateMipmap, GLenum target) \
GLE(void*, MapBufferRange, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) \
GLE(void, UnmapBuffer, GLenum target) \
GLE(GLuint, GetUniformBlockIndex, GLuint program, const GLchar *uniformBlockName) \
GLE(void, UniformBlockBinding, GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) \
GLE(void, BindBufferBase, GLenum target, GLuint index, GLuint buffer) \
GLE(void, BlitFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) \
GLE(void, RenderbufferStorageMultisample, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) \

View file

@ -68,6 +68,8 @@ typedef struct {
void (*AddLightToScene)( const vec3_t org, float intensity, float r, float g, float b );
void (*AddAdditiveLightToScene)( const vec3_t org, float intensity, float r, float g, float b );
void (*RenderScene)( const refdef_t *fd );
void (*HUDBufferStart)( qboolean clear );
void (*HUDBufferEnd)( void );
void (*SetColor)( const float *rgba ); // NULL = 1,1,1,1
void (*DrawStretchPic) ( float x, float y, float w, float h,
@ -84,7 +86,8 @@ typedef struct {
#if __ANDROID__
void (*SetVRHeadsetParms)( const float projectionMatrix[4][4],
int renderBufferL, int renderBufferR );
const float nonVRProjectionMatrix[4][4],
int renderBuffer );
#endif
int (*MarkFragments)( int numPoints, const vec3_t *points, const vec3_t projection,

View file

@ -118,6 +118,7 @@ typedef struct {
// extra sprite information
float radius;
float rotation;
qboolean invert;
} refEntity_t;
@ -130,6 +131,8 @@ typedef struct {
vec3_t vieworg;
vec3_t viewaxis[3]; // transformation matrix
qboolean isHUD;
// time in milliseconds for shader effects and other time dependent rendering issues
int time;

View file

@ -1,13 +1,22 @@
attribute vec3 attr_Position;
attribute vec4 attr_TexCoord0;
uniform mat4 u_ModelViewProjectionMatrix;
// Uniforms
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
uniform mat4 u_ModelMatrix;
varying vec2 var_TexCoords;
void main()
{
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
var_TexCoords = attr_TexCoord0.st;
}

View file

@ -1,13 +1,23 @@
attribute vec3 attr_Position;
attribute vec4 attr_TexCoord0;
uniform mat4 u_ModelViewProjectionMatrix;
// Uniforms
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
uniform mat4 u_ModelMatrix;
varying vec2 var_TexCoords;
void main()
{
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
var_TexCoords = attr_TexCoord0.st;
}

View file

@ -11,7 +11,18 @@ uniform float u_Time;
#endif
uniform vec4 u_Color;
uniform mat4 u_ModelViewProjectionMatrix;
uniform mat4 u_ModelMatrix;
// Uniforms
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
varying vec2 var_Tex1;
varying vec4 var_Color;
@ -80,7 +91,7 @@ void main()
position = DeformPosition(position, normal, attr_TexCoord0.st);
#endif
gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
vec3 dist = u_DlightInfo.xyz - position;

View file

@ -1,13 +1,24 @@
attribute vec3 attr_Position;
attribute vec4 attr_TexCoord0;
uniform mat4 u_ModelViewProjectionMatrix;
uniform mat4 u_ModelMatrix;
// Uniforms
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
varying vec2 var_TexCoords;
void main()
{
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
var_TexCoords = attr_TexCoord0.st;
}

View file

@ -15,13 +15,14 @@ uniform vec4 u_FogDistance;
uniform vec4 u_FogDepth;
uniform float u_FogEyeT;
uniform mat4 u_ModelMatrix;
#if defined(USE_DEFORM_VERTEXES)
uniform int u_DeformGen;
uniform float u_DeformParams[5];
#endif
uniform float u_Time;
uniform mat4 u_ModelViewProjectionMatrix;
#if defined(USE_VERTEX_ANIMATION)
uniform float u_VertexLerp;
@ -31,6 +32,16 @@ uniform mat4 u_BoneMatrix[MAX_GLSL_BONES];
uniform vec4 u_Color;
// Uniforms
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
varying float var_Scale;
#if defined(USE_DEFORM_VERTEXES)
@ -125,7 +136,7 @@ void main()
position.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st);
#endif
gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
var_Scale = CalcFog(position) * u_Color.a * u_Color.a;
}

View file

@ -36,13 +36,15 @@ uniform float u_FogEyeT;
uniform vec4 u_FogColorMask;
#endif
uniform mat4 u_ModelMatrix;
#if defined(USE_DEFORM_VERTEXES)
uniform int u_DeformGen;
uniform float u_DeformParams[5];
uniform float u_Time;
#endif
uniform mat4 u_ModelViewProjectionMatrix;
uniform vec4 u_BaseColor;
uniform vec4 u_VertColor;
@ -61,6 +63,16 @@ uniform float u_VertexLerp;
uniform mat4 u_BoneMatrix[MAX_GLSL_BONES];
#endif
// Uniforms
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
varying vec2 var_DiffuseTex;
varying vec4 var_Color;
@ -227,7 +239,7 @@ void main()
position = DeformPosition(position, normal, attr_TexCoord0.st);
#endif
gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
#if defined(USE_TCGEN)
vec2 tex = GenTexCoords(u_TCGen0, position, normal, u_TCGen0Vector0, u_TCGen0Vector1);

View file

@ -41,13 +41,12 @@ uniform vec4 u_DiffuseTexMatrix;
uniform vec4 u_DiffuseTexOffTurb;
#endif
uniform mat4 u_ModelViewProjectionMatrix;
uniform mat4 u_ModelMatrix;
uniform vec4 u_BaseColor;
uniform vec4 u_VertColor;
#if defined(USE_MODELMATRIX)
uniform mat4 u_ModelMatrix;
#endif
#if defined(USE_VERTEX_ANIMATION)
uniform float u_VertexLerp;
@ -67,6 +66,16 @@ uniform vec4 u_PrimaryLightOrigin;
uniform float u_PrimaryLightRadius;
#endif
// Uniforms
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
varying vec4 var_TexCoords;
varying vec4 var_Color;
@ -188,7 +197,7 @@ void main()
var_TexCoords.xy = texCoords;
#endif
gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
#if defined(USE_MODELMATRIX)
position = (u_ModelMatrix * vec4(position, 1.0)).xyz;

View file

@ -1,14 +1,24 @@
attribute vec3 attr_Position;
attribute vec3 attr_Normal;
uniform mat4 u_ModelViewProjectionMatrix;
uniform mat4 u_ModelMatrix;
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
varying vec3 var_Position;
varying vec3 var_Normal;
void main()
{
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
var_Position = attr_Position;
var_Normal = attr_Normal;

View file

@ -10,13 +10,15 @@ attribute vec4 attr_BoneIndexes;
attribute vec4 attr_BoneWeights;
#endif
// Uniforms
//#if defined(USE_DEFORM_VERTEXES)
uniform int u_DeformGen;
uniform float u_DeformParams[5];
//#endif
uniform float u_Time;
uniform mat4 u_ModelViewProjectionMatrix;
uniform mat4 u_ModelMatrix;
@ -26,6 +28,15 @@ uniform float u_VertexLerp;
uniform mat4 u_BoneMatrix[MAX_GLSL_BONES];
#endif
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
varying vec3 var_Position;
vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st)
@ -102,7 +113,7 @@ void main()
position = DeformPosition(position, normal, attr_TexCoord0.st);
gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
var_Position = (u_ModelMatrix * vec4(position, 1.0)).xyz;
}

View file

@ -1,13 +1,25 @@
attribute vec3 attr_Position;
attribute vec4 attr_TexCoord0;
uniform mat4 u_ModelViewProjectionMatrix;
// Uniforms
uniform mat4 u_ModelMatrix;
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
varying vec2 var_Tex1;
void main()
{
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
var_Tex1 = attr_TexCoord0.st;
}

View file

@ -1,9 +1,21 @@
attribute vec3 attr_Position;
attribute vec4 attr_TexCoord0;
uniform mat4 u_ModelViewProjectionMatrix;
// Uniforms
uniform mat4 u_ModelMatrix;
uniform vec3 u_ToneMinAvgMaxLinear;
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
varying vec2 var_TexCoords;
varying float var_InvWhite;
@ -21,7 +33,7 @@ float FilmicTonemap(float x)
void main()
{
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
var_TexCoords = attr_TexCoord0.st;
var_InvWhite = 1.0 / FilmicTonemap(u_ToneMinAvgMaxLinear.z - u_ToneMinAvgMaxLinear.x);
}

View file

@ -243,7 +243,7 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) {
}
// set up lighting
if ( !personalModel || r_shadows->integer > 1 )
if ( !personalModel || r_shadows->integer > 1 || r_playerShadow->integer > 1)
{
R_SetupEntityLighting( &tr.refdef, ent );
}
@ -292,7 +292,7 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) {
}
// projection shadows work fine with personal models
if ( r_shadows->integer == 3
if ( (r_shadows->integer == 3 || r_playerShadow->integer == 3)
&& fogNum == 0
&& (ent->e.renderfx & RF_SHADOW_PLANE )
&& shader->sort == SS_OPAQUE )

View file

@ -26,7 +26,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
backEndData_t *backEndData;
backEndState_t backEnd;
static float s_flipMatrix[16] = {
// convert from our coordinate system (looking down X)
// to OpenGL's coordinate system (looking down -Z)
@ -270,29 +269,11 @@ void GL_State( unsigned long stateBits )
void GL_SetProjectionMatrix(mat4_t matrix)
{
Mat4Copy(matrix, glState.projection);
Mat4Multiply(glState.projection, glState.modelview, glState.modelviewProjection);
}
void GL_SetModelviewMatrix(mat4_t matrix, qboolean applyStereoView)
void GL_SetModelMatrix(mat4_t matrix)
{
/*
if (applyStereoView)
{
if (tr.refdef.stereoFrame == STEREO_LEFT) {
Mat4Multiply(tr.vrParms.viewL, matrix, glState.modelview);
} else if (tr.refdef.stereoFrame == STEREO_RIGHT) {
Mat4Multiply(tr.vrParms.viewR, matrix, glState.modelview);
} else {
Mat4Copy(matrix, glState.modelview);
}
} else
*/
{
Mat4Copy(matrix, glState.modelview);
}
Mat4Multiply(glState.projection, glState.modelview, glState.modelviewProjection);
Mat4Copy(matrix, glState.modelMatrix);
}
@ -427,7 +408,8 @@ void RB_BeginDrawingView (void) {
plane2[2] = DotProduct (backEnd.viewParms.or.axis[2], plane);
plane2[3] = DotProduct (plane, backEnd.viewParms.or.origin) - plane[3];
#endif
GL_SetModelviewMatrix( s_flipMatrix, qtrue );
GL_SetModelMatrix( s_flipMatrix );
}
}
@ -546,7 +528,8 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.or );
}
GL_SetModelviewMatrix( backEnd.or.modelMatrix, qtrue );
GL_SetModelMatrix( backEnd.or.modelMatrix );
GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix );
//
// change depthrange. Also change projection matrix so first person weapon does not look like coming
@ -556,26 +539,6 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
{
if (depthRange)
{
if(backEnd.viewParms.stereoFrame != STEREO_CENTER)
{
if(isCrosshair)
{
if(oldDepthRange)
{
// was not a crosshair but now is, change back proj matrix
GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix );
}
}
else
{
viewParms_t temp = backEnd.viewParms;
R_SetupProjection(&temp, r_znear->value, 0, qfalse);
GL_SetProjectionMatrix( temp.projectionMatrix );
}
}
#ifdef __ANDROID__
if(!oldDepthRange)
glDepthRangef(0.0f, 0.3f);
@ -586,11 +549,6 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
}
else
{
if(!wasCrosshair && backEnd.viewParms.stereoFrame != STEREO_CENTER)
{
GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix );
}
#ifdef __ANDROID__
glDepthRangef(0.0f, 1.0f);
#else
@ -619,9 +577,9 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
if (glRefConfig.framebufferObject)
FBO_Bind(fbo);
// go back to the world modelview matrix
// go back to the world model matrix
GL_SetModelviewMatrix( backEnd.viewParms.world.modelMatrix, qtrue );
GL_SetModelMatrix( backEnd.viewParms.world.modelMatrix );
#ifdef __ANDROID__
glDepthRangef(0, 1);
@ -649,12 +607,6 @@ void RB_SetGL2D (void) {
mat4_t matrix;
int width, height;
if (backEnd.projection2D && backEnd.last2DFBO == glState.currentFBO)
return;
backEnd.projection2D = qtrue;
backEnd.last2DFBO = glState.currentFBO;
if (glState.currentFBO)
{
width = glState.currentFBO->width;
@ -667,13 +619,29 @@ void RB_SetGL2D (void) {
}
// set 2D virtual screen size
if (glState.isDrawingHUD && vr_hudDrawStatus->integer != 2)
{
qglViewport(0, 0, tr.hudImage->width, tr.hudImage->height);
qglScissor(0, 0, tr.hudImage->width, tr.hudImage->height);
}
else
{
qglViewport(0, 0, width, height);
qglScissor(0, 0, width, height);
}
if (backEnd.projection2D && backEnd.last2DFBO == glState.currentFBO)
return;
backEnd.projection2D = qtrue;
backEnd.last2DFBO = glState.currentFBO;
Mat4Ortho(0, width, height, 0, 0, 1, matrix);
GL_SetProjectionMatrix(matrix);
Mat4Identity(matrix);
GL_SetModelviewMatrix(matrix, qfalse);
GL_SetModelMatrix(matrix);
GL_State( GLS_DEPTHTEST_DISABLE |
GLS_SRCBLEND_SRC_ALPHA |
@ -756,7 +724,8 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *
GLSL_BindProgram(&tr.textureColorShader);
GLSL_SetUniformMat4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
GLSL_SetUniformMat4(&tr.textureColorShader, UNIFORM_MODELMATRIX, glState.modelMatrix);
GLSL_BindBuffers(&tr.textureColorShader);
GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, colorWhite);
RB_InstantQuad2(quadVerts, texCoords);
@ -1407,6 +1376,7 @@ const void *RB_SwapBuffers( const void *data ) {
ri.Hunk_FreeTempMemory( stencilReadback );
}
#if 0
if (glRefConfig.framebufferObject)
{
if (!backEnd.framePostProcessed)
@ -1423,14 +1393,16 @@ const void *RB_SwapBuffers( const void *data ) {
}
}
}
#endif
if ( !glState.finishCalled ) {
if ( !glState.finishCalled )
{
qglFinish();
}
GLimp_LogComment( "***************** RB_SwapBuffers *****************\n\n\n" );
//GLimp_LogComment( "***************** RB_SwapBuffers *****************\n\n\n" );
GLimp_EndFrame();
//GLimp_EndFrame();
backEnd.framePostProcessed = qfalse;
backEnd.projection2D = qfalse;
@ -1787,7 +1759,70 @@ const void* RB_SwitchEye( const void* data ) {
glState.currentFBO = tr.renderFbo;
}
tr.refdef.stereoFrame = cmd->stereoFrame;
return (const void*)(cmd + 1);
}
/*
====================
RB_HUDBuffer
====================
*/
const void* RB_HUDBuffer( const void* data ) {
const hudBufferCommand_t *cmd = data;
// finish any 2D drawing if needed
if(tess.numIndexes)
RB_EndSurface();
if (cmd->start && !glState.isDrawingHUD)
{
glState.isDrawingHUD = qtrue;
if (vr_hudDrawStatus->integer != 2)
{
//keep record of current render fbo and switch to the hud buffer
tr.backupFrameBuffer = tr.renderFbo->frameBuffer;
tr.renderFbo->frameBuffer = tr.hudFbo->frameBuffer;
// Render to framebuffer
GL_BindFramebuffer(GL_FRAMEBUFFER, tr.hudFbo->frameBuffer);
qglBindRenderbuffer(GL_RENDERBUFFER, 0);
qglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
tr.hudImage->texnum, 0);
// Attach combined depth+stencil
qglFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER,
tr.hudDepthImage->texnum);
qglFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
tr.hudDepthImage->texnum);
GLenum result = qglCheckFramebufferStatus(GL_FRAMEBUFFER);
if (result != GL_FRAMEBUFFER_COMPLETE)
{
ri.Error("Error binding Framebuffer: %i\n", result);
}
if (cmd->clear)
{
qglClearColor(0.0f, 0.0f, 0.0f, 0.0f);
qglClear(GL_COLOR_BUFFER_BIT);
}
}
}
else if (glState.isDrawingHUD)
{
glState.isDrawingHUD = qfalse;
if (vr_hudDrawStatus->integer != 2)
{
//restore the true render fbo
tr.renderFbo->frameBuffer = tr.backupFrameBuffer;
GL_BindFramebuffer(GL_FRAMEBUFFER, tr.renderFbo->frameBuffer);
}
}
glState.currentFBO = tr.renderFbo;
return (const void*)(cmd + 1);
}
@ -1845,6 +1880,9 @@ void RB_ExecuteRenderCommands( const void *data ) {
case RC_SWITCH_EYE:
data = RB_SwitchEye(data);
break;
case RC_HUD_BUFFER:
data = RB_HUDBuffer(data);
break;
case RC_END_OF_LIST:
default:
// finish any 2D drawing if needed

View file

@ -410,133 +410,26 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) {
ri.Error(ERR_FATAL, "RE_BeginFrame() - glGetError() failed (0x%x)!", err);
}
if (glConfig.stereoEnabled) {
{
if (tr.renderFbo && tr.vrParms.renderBufferOriginal == 0) {
tr.vrParms.renderBufferOriginal = tr.renderFbo->frameBuffer;
}
if ( stereoFrame == STEREO_LEFT ) {
{
if (tr.vrParms.valid == qtrue) {
if (tr.renderFbo) {
switchEyeCommand_t* sec;
if (!(sec = R_GetCommandBuffer(sizeof(*sec))))
return;
sec->commandId = RC_SWITCH_EYE;
sec->eye = tr.vrParms.renderBufferL;
sec->eye = tr.vrParms.renderBuffer;
sec->stereoFrame = stereoFrame;
}
}
} else if ( stereoFrame == STEREO_RIGHT ) {
if (tr.vrParms.valid == qtrue) {
if (tr.renderFbo) {
switchEyeCommand_t* sec;
if (!(sec = R_GetCommandBuffer(sizeof(*sec))))
return;
sec->commandId = RC_SWITCH_EYE;
sec->eye = tr.vrParms.renderBufferR;
sec->stereoFrame = stereoFrame;
}
}
} else {
ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is enabled, but stereoFrame was %i", stereoFrame );
}
}
else
{
if(r_anaglyphMode->integer)
{
if(r_anaglyphMode->modified)
{
// clear both, front and backbuffer.
qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
backEnd.colorMask[0] = GL_FALSE;
backEnd.colorMask[1] = GL_FALSE;
backEnd.colorMask[2] = GL_FALSE;
backEnd.colorMask[3] = GL_FALSE;
if (glRefConfig.framebufferObject)
{
// clear all framebuffers
if (tr.msaaResolveFbo)
{
FBO_Bind(tr.msaaResolveFbo);
qglClear(GL_COLOR_BUFFER_BIT);
}
if (tr.renderFbo)
{
FBO_Bind(tr.renderFbo);
qglClear(GL_COLOR_BUFFER_BIT);
}
FBO_Bind(NULL);
}
qglDrawBuffer(GL_FRONT);
qglClear(GL_COLOR_BUFFER_BIT);
qglDrawBuffer(GL_BACK);
qglClear(GL_COLOR_BUFFER_BIT);
r_anaglyphMode->modified = qfalse;
}
if(stereoFrame == STEREO_LEFT)
{
if( !(cmd = R_GetCommandBuffer(sizeof(*cmd))) )
return;
if( !(colcmd = R_GetCommandBuffer(sizeof(*colcmd))) )
return;
}
else if(stereoFrame == STEREO_RIGHT)
{
clearDepthCommand_t *cldcmd;
if( !(cldcmd = R_GetCommandBuffer(sizeof(*cldcmd))) )
return;
cldcmd->commandId = RC_CLEARDEPTH;
if( !(colcmd = R_GetCommandBuffer(sizeof(*colcmd))) )
return;
}
else
ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is enabled, but stereoFrame was %i", stereoFrame );
R_SetColorMode(colcmd->rgba, stereoFrame, r_anaglyphMode->integer);
colcmd->commandId = RC_COLORMASK;
}
else
{
if(stereoFrame != STEREO_CENTER)
ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is disabled, but stereoFrame was %i", stereoFrame );
if( !(cmd = R_GetCommandBuffer(sizeof(*cmd))) )
return;
}
if(cmd)
{
cmd->commandId = RC_DRAW_BUFFER;
if(r_anaglyphMode->modified)
{
qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
backEnd.colorMask[0] = 0;
backEnd.colorMask[1] = 0;
backEnd.colorMask[2] = 0;
backEnd.colorMask[3] = 0;
r_anaglyphMode->modified = qfalse;
}
if (!Q_stricmp(r_drawBuffer->string, "GL_FRONT"))
cmd->buffer = (int)GL_FRONT;
else
cmd->buffer = (int)GL_BACK;
}
}
tr.refdef.stereoFrame = stereoFrame;
GLSL_PrepareUniformBuffers();
}
@ -579,6 +472,37 @@ void RE_EndFrame( int *frontEndMsec, int *backEndMsec ) {
backEnd.pc.msec = 0;
}
void RE_HUDBufferStart( qboolean clear )
{
hudBufferCommand_t *cmd;
if ( !tr.registered ) {
return;
}
cmd = R_GetCommandBufferReserved( sizeof( *cmd ), 0 );
if ( !cmd ) {
return;
}
cmd->start = qtrue;
cmd->clear = clear;
cmd->commandId = RC_HUD_BUFFER;
}
void RE_HUDBufferEnd( void )
{
hudBufferCommand_t *cmd;
if ( !tr.registered ) {
return;
}
cmd = R_GetCommandBufferReserved( sizeof( *cmd ), 0 );
if ( !cmd ) {
return;
}
cmd->start = qfalse;
cmd->commandId = RC_HUD_BUFFER;
}
//#if __ANDROID__
void R_Mat4Transpose( const float in[4][4], float* out ) {
int i, j;
@ -589,12 +513,11 @@ void R_Mat4Transpose( const float in[4][4], float* out ) {
}
}
void RE_SetVRHeadsetParms( const float projectionMatrix[4][4],
int renderBufferL, int renderBufferR ) {
void RE_SetVRHeadsetParms( const float projectionMatrix[4][4], const float nonVRProjectionMatrix[4][4],
int renderBuffer ) {
R_Mat4Transpose(projectionMatrix, tr.vrParms.projection);
tr.vrParms.renderBufferL = renderBufferL;
tr.vrParms.renderBufferR = renderBufferR;
R_Mat4Transpose(nonVRProjectionMatrix, tr.vrParms.monoVRProjection);
tr.vrParms.renderBuffer = renderBuffer;
tr.vrParms.valid = qtrue;
}
//#endif

View file

@ -306,6 +306,21 @@ void FBO_Init(void)
qglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
}
{
tr.hudFbo = FBO_Create("_hud", tr.hudImage->width, tr.hudImage->height);
FBO_AttachImage(tr.hudFbo, tr.hudImage, GL_COLOR_ATTACHMENT0, 0);
FBO_AttachImage(tr.hudFbo, tr.hudDepthImage, GL_DEPTH_ATTACHMENT, 0);
R_CheckFBO(tr.hudFbo);
// clear render buffer
if (tr.hudFbo)
{
GL_BindFramebuffer(GL_FRAMEBUFFER, tr.hudFbo->frameBuffer);
qglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
}
if (tr.screenScratchImage)
{
tr.screenScratchFbo = FBO_Create("screenScratch", tr.screenScratchImage->width, tr.screenScratchImage->height);
@ -440,14 +455,14 @@ void FBO_Shutdown(void)
for(j = 0; j < glRefConfig.maxColorAttachments; j++)
{
if(fbo->colorBuffers[j])
qglDeleteRenderbuffers(1, &fbo->colorBuffers[j]);
qglDeleteTextures(1, &fbo->colorBuffers[j]);
}
if(fbo->depthBuffer)
qglDeleteRenderbuffers(1, &fbo->depthBuffer);
qglDeleteTextures(1, &fbo->depthBuffer);
if(fbo->stencilBuffer)
qglDeleteRenderbuffers(1, &fbo->stencilBuffer);
qglDeleteTextures(1, &fbo->stencilBuffer);
if(fbo->frameBuffer)
qglDeleteFramebuffers(1, &fbo->frameBuffer);
@ -577,7 +592,8 @@ void FBO_BlitFromTexture(struct image_s *src, vec4_t inSrcTexCorners, vec2_t inS
GLSL_BindProgram(shaderProgram);
GLSL_SetUniformMat4(shaderProgram, UNIFORM_MODELVIEWPROJECTIONMATRIX, projection);
GLSL_SetUniformMat4(shaderProgram, UNIFORM_MODELMATRIX, glState.modelMatrix);
GLSL_BindBuffers(shaderProgram);
GLSL_SetUniformVec4(shaderProgram, UNIFORM_COLOR, color);
GLSL_SetUniformVec2(shaderProgram, UNIFORM_INVTEXRES, invTexRes);
GLSL_SetUniformVec2(shaderProgram, UNIFORM_AUTOEXPOSUREMINMAX, tr.refdef.autoExposureMinMax);

View file

@ -149,7 +149,7 @@ void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t
// if the point is off the screen, don't bother adding it
// calculate screen coordinates and depth
R_TransformModelToClip( point, backEnd.or.modelMatrix,
R_TransformModelToClip( point, backEnd.or.modelView,
backEnd.viewParms.projectionMatrix, eye, clip );
// check to see if the point is completely off screen
@ -472,7 +472,7 @@ void RB_RenderFlares (void) {
flare_t *f;
flare_t **prev;
qboolean draw;
mat4_t oldmodelview, oldprojection, matrix;
mat4_t oldmodelmatrix, oldprojection, matrix;
if ( !r_flares->integer ) {
return;
@ -527,9 +527,9 @@ void RB_RenderFlares (void) {
}
Mat4Copy(glState.projection, oldprojection);
Mat4Copy(glState.modelview, oldmodelview);
Mat4Copy(glState.modelMatrix, oldmodelmatrix);
Mat4Identity(matrix);
GL_SetModelviewMatrix(matrix, qtrue);
GL_SetModelMatrix(matrix);
Mat4Ortho( backEnd.viewParms.viewportX, backEnd.viewParms.viewportX + backEnd.viewParms.viewportWidth,
backEnd.viewParms.viewportY, backEnd.viewParms.viewportY + backEnd.viewParms.viewportHeight,
-99999, 99999, matrix );
@ -544,7 +544,7 @@ void RB_RenderFlares (void) {
}
GL_SetProjectionMatrix(oldprojection);
GL_SetModelviewMatrix(oldmodelview, qtrue);
GL_SetModelMatrix(oldmodelmatrix);
}

View file

@ -23,6 +23,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "tr_local.h"
#include "tr_dsa.h"
#include "../vr/vr_base.h"
#include "../vr/vr_clientinfo.h"
extern const char *fallbackShader_bokeh_vp;
extern const char *fallbackShader_bokeh_fp;
@ -60,6 +63,22 @@ typedef struct uniformInfo_s
}
uniformInfo_t;
typedef enum {
FULLSCREEN_ORTHO_PROJECTION, // Orthographic projection and no stereo view for fullscreen rendering
HUDBUFFER_ORTHO_PROJECTION, // Orthographic projection and no stereo view for the HUD buffer
STEREO_ORTHO_PROJECTION, // Orthographic projection with a slight stereo offset per eye for the static hud
VR_PROJECTION,
MONO_VR_PROJECTION,
PROJECTION_COUNT
} projection_t;
GLuint viewMatricesBuffer[PROJECTION_COUNT];
GLuint projectionMatricesBuffer[PROJECTION_COUNT];
float orthoProjectionMatrix[16];
// These must be in the same order as in uniform_t in tr_local.h.
static uniformInfo_t uniformsInfo[] =
{
@ -122,7 +141,6 @@ static uniformInfo_t uniformsInfo[] =
{ "u_FogColorMask", GLSL_VEC4 },
{ "u_ModelMatrix", GLSL_MAT16 },
{ "u_ModelViewProjectionMatrix", GLSL_MAT16 },
{ "u_Time", GLSL_FLOAT },
{ "u_VertexLerp" , GLSL_FLOAT },
@ -160,6 +178,100 @@ typedef enum
}
glslPrintLog_t;
/*
====================
GLSL_ViewMatricesUniformBuffer
====================
*/
static void GLSL_ViewMatricesUniformBuffer(const float eyeView[32], const float modelView[32]) {
for (int i = 0; i < PROJECTION_COUNT; ++i)
{
// Update the scene matrices for when we are using a normal projection
qglBindBuffer(GL_UNIFORM_BUFFER, viewMatricesBuffer[i]);
float *viewMatrices = (float *) qglMapBufferRange(
GL_UNIFORM_BUFFER,
0,
2 * 16 * sizeof(float),
GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (viewMatrices == NULL)
{
ri.Error(ERR_DROP, "View Matrices Uniform Buffer is NULL");
return;
}
switch (i)
{
case FULLSCREEN_ORTHO_PROJECTION:
case HUDBUFFER_ORTHO_PROJECTION:
{
Mat4Identity( viewMatrices );
Mat4Identity( viewMatrices + 16 );
}
break;
case STEREO_ORTHO_PROJECTION:
{
//This is a bit of a fiddle this calc.. it is just done like this to
//make the HUD depths line up with the weapon wheel depth. I _know_ there
//would be a proper calculation to do this exactly, but this is good enough
//and I've just had enough messing about with this
const auto depthOffset = (5-powf(vr_hudDepth->integer, 0.7f)) * 16;
vec3_t translate;
VectorSet(translate, depthOffset, 0, 0);
Mat4Translation( translate, viewMatrices );
VectorSet(translate, -depthOffset, 0, 0);
Mat4Translation( translate, viewMatrices + 16 );
}
break;
case VR_PROJECTION:
{
Mat4Copy(eyeView, viewMatrices);
Mat4Copy(eyeView+16, viewMatrices+16);
}
break;
case MONO_VR_PROJECTION:
{
Mat4Copy(modelView, viewMatrices);
Mat4Copy(modelView, viewMatrices+16);
}
break;
}
qglUnmapBuffer(GL_UNIFORM_BUFFER);
qglBindBuffer(GL_UNIFORM_BUFFER, 0);
}
}
/*
====================
GLSL_ProjectionMatricesUniformBuffer
====================
*/
static void GLSL_ProjectionMatricesUniformBuffer(GLint projectionMatricesBuffer, const float value[16]) {
// Update the scene matrices.
qglBindBuffer(GL_UNIFORM_BUFFER, projectionMatricesBuffer);
float* projectionMatrix = (float*)qglMapBufferRange(
GL_UNIFORM_BUFFER,
0,
16 * sizeof(float),
GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (projectionMatrix == NULL)
{
ri.Error(ERR_DROP, "Projection Matrices Uniform Buffer is NULL");
return;
}
memcpy((char*)projectionMatrix, value, 16 * sizeof(float));
qglUnmapBuffer(GL_UNIFORM_BUFFER);
qglBindBuffer(GL_UNIFORM_BUFFER, 0);
}
static void GLSL_PrintLog(GLuint programOrShader, glslPrintLog_t type, qboolean developerOnly)
{
char *msg;
@ -243,6 +355,15 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLchar *extra, char *
// HACK: abuse the GLSL preprocessor to turn GLSL 1.20 shaders into 1.30 ones
#ifdef __ANDROID__
Q_strcat(dest, size, "#version 300 es\n");
if(shaderType == GL_VERTEX_SHADER)
{
//Enable multiview
Q_strcat(dest, size, "#define NUM_VIEWS 2\n");
Q_strcat(dest, size, "#extension GL_OVR_multiview2 : enable\n");
Q_strcat(dest, size, "layout(num_views=NUM_VIEWS) in;\n");
}
Q_strcat(dest, size, "precision mediump float;\n");
if(shaderType == GL_VERTEX_SHADER)
@ -656,6 +777,23 @@ void GLSL_InitUniforms(shaderProgram_t *program)
GLint *uniforms = program->uniforms;
//Shader Matrices for the View Matrices
GLuint viewMatricesUniformLocation = qglGetUniformBlockIndex(program->program, "ViewMatrices");
int numBufferBindings = 0;
program->viewMatricesBinding = numBufferBindings++;
qglUniformBlockBinding(
program->program,
viewMatricesUniformLocation,
program->viewMatricesBinding);
//Shader Matrices for the Projection Matrix
GLuint projectionMatrixUniformLocation = qglGetUniformBlockIndex(program->program, "ProjectionMatrix");
program->projectionMatrixBinding = numBufferBindings++;
qglUniformBlockBinding(
program->program,
projectionMatrixUniformLocation,
program->projectionMatrixBinding);
size = 0;
for (i = 0; i < UNIFORM_COUNT; i++)
{
@ -944,6 +1082,28 @@ void GLSL_InitGPUShaders(void)
ri.Printf(PRINT_ALL, "------- GLSL_InitGPUShaders -------\n");
for (int i = 0; i < PROJECTION_COUNT; ++i)
{
//Generate buffer for 2 * view matrices
qglGenBuffers(1, &viewMatricesBuffer[i]);
qglBindBuffer(GL_UNIFORM_BUFFER, viewMatricesBuffer[i]);
qglBufferData(
GL_UNIFORM_BUFFER,
2 * 16 * sizeof(float),
NULL,
GL_STATIC_DRAW);
qglBindBuffer(GL_UNIFORM_BUFFER, 0);
qglGenBuffers(1, &projectionMatricesBuffer[i]);
qglBindBuffer(GL_UNIFORM_BUFFER, projectionMatricesBuffer[i]);
qglBufferData(
GL_UNIFORM_BUFFER,
16 * sizeof(float),
NULL,
GL_STATIC_DRAW);
qglBindBuffer(GL_UNIFORM_BUFFER, 0);
}
R_IssuePendingRenderCommands();
startTime = ri.Milliseconds();
@ -1106,6 +1266,13 @@ void GLSL_InitGPUShaders(void)
if (glRefConfig.swizzleNormalmap)
Q_strcat(extradefines, 1024, "#define SWIZZLE_NORMALMAP\n");
// HACK: use in main menu simple light model (to prevent issue with missing models textures)
if (Cvar_Get("r_uiFullScreen", "1", 0)->integer)
{
Q_strcat(extradefines, 1024, "#define USE_MENU_LIGHT\n");
}
if (lightType)
{
Q_strcat(extradefines, 1024, "#define USE_LIGHT\n");
@ -1510,9 +1677,52 @@ void GLSL_ShutdownGPUShaders(void)
for ( i = 0; i < 4; i++)
GLSL_DeleteGPUShader(&tr.depthBlurShader[i]);
//Clean up buffers
qglDeleteBuffers(PROJECTION_COUNT, viewMatricesBuffer);
qglDeleteBuffers(PROJECTION_COUNT, projectionMatricesBuffer);
}
void GLSL_PrepareUniformBuffers(void)
{
int width, height;
if (glState.currentFBO)
{
width = glState.currentFBO->width;
height = glState.currentFBO->height;
}
else
{
width = glConfig.vidWidth;
height = glConfig.vidHeight;
}
Mat4Ortho(0, width, height, 0, 0, 1, orthoProjectionMatrix);
//ortho projection matrices
GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[FULLSCREEN_ORTHO_PROJECTION],
orthoProjectionMatrix);
GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[STEREO_ORTHO_PROJECTION],
orthoProjectionMatrix);
float hudOrthoProjectionMatrix[16];
Mat4Ortho(0, 640, 480, 0, 0, 1, hudOrthoProjectionMatrix);
GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[HUDBUFFER_ORTHO_PROJECTION],
hudOrthoProjectionMatrix);
//VR projection matrix
GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[VR_PROJECTION],
tr.vrParms.projection);
//Used for drawing models
GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[MONO_VR_PROJECTION],
tr.vrParms.monoVRProjection);
//Set all view matrices
GLSL_ViewMatricesUniformBuffer(tr.viewParms.world.eyeViewMatrix, tr.viewParms.world.modelView);
}
void GLSL_BindProgram(shaderProgram_t * program)
{
GLuint programObject = program ? program->program : 0;
@ -1528,6 +1738,46 @@ void GLSL_BindProgram(shaderProgram_t * program)
backEnd.pc.c_glslShaderBinds++;
}
static GLuint GLSL_CalculateProjection() {
GLuint result = glState.isDrawingHUD ? MONO_VR_PROJECTION : VR_PROJECTION;
if (Mat4Compare(&orthoProjectionMatrix, glState.projection))
{
if (glState.isDrawingHUD)
{
if (vr_hudDrawStatus->integer != 2)
{
result = HUDBUFFER_ORTHO_PROJECTION;
}
else
{
result = STEREO_ORTHO_PROJECTION;
}
}
else
{
result = FULLSCREEN_ORTHO_PROJECTION;
}
}
return result;
}
void GLSL_BindBuffers( shaderProgram_t * program )
{
GLuint projection = GLSL_CalculateProjection();
qglBindBufferBase(
GL_UNIFORM_BUFFER,
program->viewMatricesBinding,
viewMatricesBuffer[projection]);
qglBindBufferBase(
GL_UNIFORM_BUFFER,
program->projectionMatrixBinding,
projectionMatricesBuffer[projection]);
}
shaderProgram_t *GLSL_GetGenericShaderProgram(int stage)
{

View file

@ -2784,6 +2784,9 @@ void R_CreateBuiltinImages( void ) {
tr.renderImage = R_CreateImage("_render", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat);
tr.hudImage = R_CreateImage("hudImage", NULL, 640, 480, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat);
tr.hudDepthImage = R_CreateImage("*hudDepth", NULL, 640, 480, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24);
if (r_shadowBlur->integer)
tr.screenScratchImage = R_CreateImage("screenScratch", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat);

View file

@ -181,6 +181,7 @@ cvar_t *r_lightmap;
cvar_t *r_vertexLight;
cvar_t *r_uiFullScreen;
cvar_t *r_shadows;
cvar_t *r_playerShadow;
cvar_t *r_flares;
cvar_t *r_mode;
cvar_t *r_nobind;
@ -1375,6 +1376,7 @@ void R_Register( void )
r_lockpvs = ri.Cvar_Get ("r_lockpvs", "0", CVAR_CHEAT);
r_noportals = ri.Cvar_Get ("r_noportals", "0", CVAR_CHEAT);
r_shadows = ri.Cvar_Get( "cg_shadows", "1", 0 );
r_playerShadow = ri.Cvar_Get( "cg_playerShadow", "1", 0);
r_marksOnTriangleMeshes = ri.Cvar_Get("r_marksOnTriangleMeshes", "0", CVAR_ARCHIVE);
@ -1650,6 +1652,8 @@ refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp ) {
re.AddLightToScene = RE_AddLightToScene;
re.AddAdditiveLightToScene = RE_AddAdditiveLightToScene;
re.RenderScene = RE_RenderScene;
re.HUDBufferStart = RE_HUDBufferStart;
re.HUDBufferEnd = RE_HUDBufferEnd;
re.SetColor = RE_SetColor;
re.DrawStretchPic = RE_StretchPic;

View file

@ -35,6 +35,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "tr_postprocess.h"
#include "../renderercommon/iqm.h"
#include "../renderercommon/qgl.h"
#include "../vr/vr_clientinfo.h"
extern cvar_t *vr_hudDepth;
extern cvar_t *vr_hudDrawStatus;
extern vr_clientinfo_t vr;
#define GLE(ret, name, ...) extern name##proc * qgl##name;
QGL_1_1_PROCS;
@ -108,7 +113,8 @@ typedef struct {
vec3_t axis[3]; // orientation in world
vec3_t viewOrigin; // viewParms->or.origin in local coordinates
float modelMatrix[16];
float transformMatrix[16];
float modelView[16];
float eyeViewMatrix[2][16];
} orientationr_t;
// Ensure this is >= the ATTR_INDEX_COUNT enum below
@ -671,7 +677,6 @@ typedef enum
UNIFORM_FOGCOLORMASK,
UNIFORM_MODELMATRIX,
UNIFORM_MODELVIEWPROJECTIONMATRIX,
UNIFORM_TIME,
UNIFORM_VERTEXLERP,
@ -714,6 +719,10 @@ typedef struct shaderProgram_s
GLuint fragmentShader;
uint32_t attribs; // vertex array attributes
//New for multiview - The view and projection matrix uniforms
GLuint projectionMatrixBinding;
GLuint viewMatricesBinding;
// uniform parameters
GLint uniforms[UNIFORM_COUNT];
short uniformBufferOffsets[UNIFORM_COUNT]; // max 32767/64=511 uniforms
@ -728,7 +737,7 @@ typedef struct {
vec3_t vieworg;
vec3_t viewaxis[3]; // transformation matrix
stereoFrame_t stereoFrame;
qboolean isHUD;
int time; // time in milliseconds for shader effects and other time dependent rendering issues
int rdflags; // RDF_NOWORLDMODEL, etc
@ -842,8 +851,8 @@ typedef struct {
typedef struct {
qboolean valid;
float projection[16];
int renderBufferL;
int renderBufferR;
float monoVRProjection[16];
int renderBuffer;
int renderBufferOriginal;
} vrParms_t;
@ -1384,9 +1393,10 @@ typedef struct {
uint32_t vertexAttribsEnabled; // global if no VAOs, tess only otherwise
FBO_t *currentFBO;
vao_t *currentVao;
mat4_t modelview;
mat4_t modelMatrix;
mat4_t projection;
mat4_t modelviewProjection;
qboolean isDrawingHUD;
} glstate_t;
typedef enum {
@ -1527,6 +1537,7 @@ typedef struct {
image_t *renderImage;
image_t *sunRaysImage;
image_t *renderDepthImage;
image_t *hudDepthImage;
image_t *pshadowMaps[MAX_DRAWN_PSHADOWS];
image_t *screenScratchImage;
image_t *textureScratchImage[2];
@ -1539,6 +1550,7 @@ typedef struct {
image_t *screenSsaoImage;
image_t *hdrDepthImage;
image_t *renderCubeImage;
image_t *hudImage;
image_t *textureDepthImage;
@ -1557,6 +1569,7 @@ typedef struct {
FBO_t *screenSsaoFbo;
FBO_t *hdrDepthFbo;
FBO_t *renderCubeFbo;
FBO_t *hudFbo;
shader_t *defaultShader;
shader_t *shadowShader;
@ -1566,6 +1579,8 @@ typedef struct {
shader_t *sunShader;
shader_t *sunFlareShader;
shader_t *hudShader;
int numLightmaps;
int lightmapSize;
image_t **lightmaps;
@ -1583,6 +1598,8 @@ typedef struct {
int shiftedEntityNum; // currentEntityNum << QSORT_REFENTITYNUM_SHIFT
model_t *currentModel;
int backupFrameBuffer;
//
// GPU shader programs
//
@ -1748,7 +1765,8 @@ extern cvar_t *r_showsky; // forces sky in front of all surfaces
extern cvar_t *r_shownormals; // draws wireframe normals
extern cvar_t *r_clear; // force screen clear every frame
extern cvar_t *r_shadows; // controls shadows: 0 = none, 1 = blur, 2 = stencil, 3 = black planar projection
extern cvar_t *r_shadows; // controls global shadows: 0 = none, 1 = blur, 2 = stencil, 3 = black planar projection
extern cvar_t *r_playerShadow; // controls player shadow: 0 = none, 1 = blur, 2 = stencil, 3 = black planar projection
extern cvar_t *r_flares; // light flares
extern cvar_t *r_intensity;
@ -1917,7 +1935,7 @@ void GL_CheckErrs( char *file, int line );
#define GL_CheckErrors(...) GL_CheckErrs(__FILE__, __LINE__)
void GL_State( unsigned long stateVector );
void GL_SetProjectionMatrix(mat4_t matrix);
void GL_SetModelviewMatrix(mat4_t matrix, qboolean applyStereoView);
void GL_SetModelMatrix(mat4_t matrix);
void GL_Cull( int cullType );
#define GLS_SRCBLEND_ZERO 0x00000001
@ -2234,9 +2252,11 @@ GLSL
*/
void GLSL_InitGPUShaders(void);
void GLSL_PrepareUniformBuffers(void);
void GLSL_ShutdownGPUShaders(void);
void GLSL_VertexAttribPointers(uint32_t attribBits);
void GLSL_BindProgram(shaderProgram_t * program);
void GLSL_BindBuffers( shaderProgram_t * program );
void GLSL_SetUniformInt(shaderProgram_t *program, int uniformNum, GLint value);
void GLSL_SetUniformFloat(shaderProgram_t *program, int uniformNum, GLfloat value);
@ -2309,7 +2329,7 @@ int R_IQMLerpTag( orientation_t *tag, iqmData_t *data,
=============================================================
=============================================================
*/
void R_TransformModelToClip( const vec3_t src, const float *modelMatrix, const float *projectionMatrix,
void R_TransformModelToClip( const vec3_t src, const float *viewMatrix, const float *projectionMatrix,
vec4_t eye, vec4_t dst );
void R_TransformClipToWindow( const vec4_t clip, const viewParms_t *view, vec4_t normalized, vec4_t window );
@ -2450,6 +2470,12 @@ typedef struct {
stereoFrame_t stereoFrame;
} switchEyeCommand_t;
typedef struct {
int commandId;
qboolean start;
qboolean clear; // Clear the buffer?
} hudBufferCommand_t;
typedef enum {
RC_END_OF_LIST,
RC_SET_COLOR,
@ -2464,7 +2490,8 @@ typedef enum {
RC_CAPSHADOWMAP,
RC_POSTPROCESS,
RC_EXPORT_CUBEMAPS,
RC_SWITCH_EYE
RC_SWITCH_EYE,
RC_HUD_BUFFER
} renderCommand_t;
@ -2507,9 +2534,13 @@ void RE_StretchPic ( float x, float y, float w, float h,
void RE_BeginFrame( stereoFrame_t stereoFrame );
void RE_EndFrame( int *frontEndMsec, int *backEndMsec );
#if __ANDROID__
void RE_SetVRHeadsetParms( const float matrix[4][4],
int renderBufferL, int renderBufferR );
void RE_SetVRHeadsetParms( const float projectionMatrix[4][4],
const float nonVRProjectionMatrix[4][4],
int renderBuffer );
#endif
void RE_HUDBufferStart( qboolean clear );
void RE_HUDBufferEnd( void );
void RE_SaveJPG(char * filename, int quality, int image_width, int image_height,
unsigned char *image_buffer, int padding);
size_t RE_SaveJPGToBuffer(byte *buffer, size_t bufSize, int quality,

View file

@ -25,6 +25,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <string.h> // memcpy
#include "../vr/vr_base.h"
trGlobals_t tr;
static float s_flipMatrix[16] = {
@ -36,6 +38,8 @@ static float s_flipMatrix[16] = {
0, 0, 0, 1
};
extern cvar_t *vr_worldscale;
extern cvar_t *vr_worldscaleScaler;
refimport_t ri;
@ -425,16 +429,16 @@ R_TransformModelToClip
==========================
*/
void R_TransformModelToClip( const vec3_t src, const float *modelMatrix, const float *projectionMatrix,
void R_TransformModelToClip( const vec3_t src, const float *viewMatrix, const float *projectionMatrix,
vec4_t eye, vec4_t dst ) {
int i;
for ( i = 0 ; i < 4 ; i++ ) {
eye[i] =
src[0] * modelMatrix[ i + 0 * 4 ] +
src[1] * modelMatrix[ i + 1 * 4 ] +
src[2] * modelMatrix[ i + 2 * 4 ] +
1 * modelMatrix[ i + 3 * 4 ];
src[0] * viewMatrix[ i + 0 * 4 ] +
src[1] * viewMatrix[ i + 1 * 4 ] +
src[2] * viewMatrix[ i + 2 * 4 ] +
1 * viewMatrix[ i + 3 * 4 ];
}
for ( i = 0 ; i < 4 ; i++ ) {
@ -532,8 +536,8 @@ void R_RotateForEntity( const trRefEntity_t *ent, const viewParms_t *viewParms,
glMatrix[11] = 0;
glMatrix[15] = 1;
Mat4Copy(glMatrix, or->transformMatrix);
myGlMultMatrix( glMatrix, viewParms->world.modelMatrix, or->modelMatrix );
myGlMultMatrix( glMatrix, viewParms->world.modelView, or->modelView );
// calculate the viewer origin in the model's space
// needed for fog, specular, and environment mapping
@ -566,7 +570,6 @@ Sets up the modelview matrix for a given viewParm
void R_RotateForViewer (void)
{
float viewerMatrix[16];
vec3_t origin;
Com_Memset (&tr.or, 0, sizeof(tr.or));
tr.or.axis[0][0] = 1;
@ -574,23 +577,35 @@ void R_RotateForViewer (void)
tr.or.axis[2][2] = 1;
VectorCopy (tr.viewParms.or.origin, tr.or.viewOrigin);
for (int eye = 0; eye <= 2; ++eye)
{
// transform by the camera placement
vec3_t origin;
VectorCopy(tr.viewParms.or.origin, origin);
if ((eye < 2) && !VR_useScreenLayer())
{
float scale = ((r_stereoSeparation->value / 1000.0f) / 2.0f) * vr_worldscale->value * vr_worldscaleScaler->value;
VectorMA(origin, (eye == 0 ? 1.0f : -1.0f) * scale, tr.viewParms.or.axis[1], origin);
}
viewerMatrix[0] = tr.viewParms.or.axis[0][0];
viewerMatrix[4] = tr.viewParms.or.axis[0][1];
viewerMatrix[8] = tr.viewParms.or.axis[0][2];
viewerMatrix[12] = -origin[0] * viewerMatrix[0] + -origin[1] * viewerMatrix[4] + -origin[2] * viewerMatrix[8];
viewerMatrix[12] = -origin[0] * viewerMatrix[0] + -origin[1] * viewerMatrix[4] +
-origin[2] * viewerMatrix[8];
viewerMatrix[1] = tr.viewParms.or.axis[1][0];
viewerMatrix[5] = tr.viewParms.or.axis[1][1];
viewerMatrix[9] = tr.viewParms.or.axis[1][2];
viewerMatrix[13] = -origin[0] * viewerMatrix[1] + -origin[1] * viewerMatrix[5] + -origin[2] * viewerMatrix[9];
viewerMatrix[13] = -origin[0] * viewerMatrix[1] + -origin[1] * viewerMatrix[5] +
-origin[2] * viewerMatrix[9];
viewerMatrix[2] = tr.viewParms.or.axis[2][0];
viewerMatrix[6] = tr.viewParms.or.axis[2][1];
viewerMatrix[10] = tr.viewParms.or.axis[2][2];
viewerMatrix[14] = -origin[0] * viewerMatrix[2] + -origin[1] * viewerMatrix[6] + -origin[2] * viewerMatrix[10];
viewerMatrix[14] = -origin[0] * viewerMatrix[2] + -origin[1] * viewerMatrix[6] +
-origin[2] * viewerMatrix[10];
viewerMatrix[3] = 0;
viewerMatrix[7] = 0;
@ -599,10 +614,27 @@ void R_RotateForViewer (void)
// convert from our coordinate system (looking down X)
// to OpenGL's coordinate system (looking down -Z)
myGlMultMatrix( viewerMatrix, s_flipMatrix, tr.or.modelMatrix );
if (eye < 2)
{
myGlMultMatrix(viewerMatrix, s_flipMatrix, tr.or.eyeViewMatrix[eye]);
}
else
{
//World Model View
Mat4Copy(viewerMatrix, tr.or.modelMatrix);
myGlMultMatrix(viewerMatrix, s_flipMatrix, tr.or.modelView);
}
}
tr.viewParms.world = tr.or;
#if 0
Com_Printf("Origin = %g, %g, %g", tr.or.modelView[12], tr.or.modelView[13], tr.or.modelView[14]);
//Com_Printf("Origin = %g, %g, %g", tr.viewParms.or.origin[0], tr.viewParms.or.origin[1], tr.viewParms.or.origin[2]);
Com_Printf("Axis 0 = %g, %g, %g", tr.viewParms.or.axis[0][0], tr.viewParms.or.axis[0][1], tr.viewParms.or.axis[0][2]);
Com_Printf("Axis 1 = %g, %g, %g", tr.viewParms.or.axis[1][0], tr.viewParms.or.axis[1][1], tr.viewParms.or.axis[1][2]);
Com_Printf("Axis 2 = %g, %g, %g", tr.viewParms.or.axis[2][0], tr.viewParms.or.axis[2][1], tr.viewParms.or.axis[2][2]);
#endif
}
/*
@ -714,61 +746,12 @@ R_SetupProjection
===============
*/
void R_SetupProjection(viewParms_t *dest, float zProj, float zFar, qboolean computeFrustum)
{
float xmin, xmax, ymin, ymax;
float width, height, stereoSep = r_stereoSeparation->value;
ymax = zProj * tan(dest->fovY * M_PI / 360.0f);
ymin = -ymax;
xmax = zProj * tan(dest->fovX * M_PI / 360.0f);
xmin = -xmax;
width = xmax - xmin;
height = ymax - ymin;
if (tr.vrParms.valid) {
/* if (dest->stereoFrame == STEREO_LEFT) {
memcpy(&dest->projectionMatrix, &tr.vrParms.projectionL, sizeof(dest->projectionMatrix));
}
else */
{
memcpy(&dest->projectionMatrix, &tr.vrParms.projection, sizeof(dest->projectionMatrix));
}
} else {
/*
* offset the view origin of the viewer for stereo rendering
* by setting the projection matrix appropriately.
*/
if(stereoSep != 0)
{
if(dest->stereoFrame == STEREO_LEFT)
stereoSep = zProj / stereoSep;
else if(dest->stereoFrame == STEREO_RIGHT)
stereoSep = zProj / -stereoSep;
else
stereoSep = 0;
}
dest->projectionMatrix[0] = 2 * zProj / width;
dest->projectionMatrix[4] = 0;
dest->projectionMatrix[8] = (xmax + xmin + 2 * stereoSep) / width;
dest->projectionMatrix[12] = 2 * zProj * stereoSep / width;
dest->projectionMatrix[1] = 0;
dest->projectionMatrix[5] = 2 * zProj / height;
dest->projectionMatrix[9] = ( ymax + ymin ) / height; // normally 0
dest->projectionMatrix[13] = 0;
dest->projectionMatrix[3] = 0;
dest->projectionMatrix[7] = 0;
dest->projectionMatrix[11] = -1;
dest->projectionMatrix[15] = 0;
}
// Now that we have all the data for the projection matrix we can also setup the view frustum.
if(computeFrustum)
R_SetupFrustum( );//dest, xmin, xmax, ymax, zProj, zFar, stereoSep);
R_SetupFrustum( );
}
/*
@ -1196,7 +1179,7 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128
int j;
unsigned int pointFlags = 0;
R_TransformModelToClip( tess.xyz[i], tr.or.modelMatrix, tr.viewParms.projectionMatrix, eye, clip );
R_TransformModelToClip( tess.xyz[i], tr.or.modelView, tr.viewParms.projectionMatrix, eye, clip );
for ( j = 0; j < 3; j++ )
{
@ -1537,7 +1520,7 @@ static void R_AddEntitySurface (int entityNum)
tr.shiftedEntityNum = tr.currentEntityNum << QSORT_REFENTITYNUM_SHIFT;
//
// the weapon model must be handled special --
// the weapon model (and HUD sprite) must be handled special --
// we don't want the hacked weapon position showing in
// mirrors, because the true body position will already be drawn
//
@ -1734,6 +1717,9 @@ void R_RenderView (viewParms_t *parms) {
// set viewParms.world
R_RotateForViewer ();
//can we get away without this?!
//GLSL_PrepareUniformBuffers();
R_SetupProjection(&tr.viewParms, r_zproj->value, tr.viewParms.zFar, qtrue);
R_GenerateDrawSurfs();
@ -2519,7 +2505,7 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level)
R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf );
}
Mat4Multiply(tr.viewParms.projectionMatrix, tr.viewParms.world.modelMatrix, tr.refdef.sunShadowMvp[level]);
Mat4Multiply(tr.viewParms.projectionMatrix, tr.viewParms.world.modelView, tr.refdef.sunShadowMvp[level]);
}
}

View file

@ -350,7 +350,7 @@ void R_AddMD3Surfaces( trRefEntity_t *ent ) {
//
// set up lighting now that we know we aren't culled
//
if ( !personalModel || r_shadows->integer > 1 ) {
if ( !personalModel || r_shadows->integer > 1 || r_playerShadow->integer > 1) {
R_SetupEntityLighting( &tr.refdef, ent );
}
@ -408,7 +408,7 @@ void R_AddMD3Surfaces( trRefEntity_t *ent ) {
}
// projection shadows work fine with personal models
if ( r_shadows->integer == 3
if ( (r_shadows->integer == 3 || r_playerShadow->integer == 3)
&& fogNum == 0
&& (ent->e.renderfx & RF_SHADOW_PLANE )
&& shader->sort == SS_OPAQUE ) {

View file

@ -1276,7 +1276,7 @@ void R_AddIQMSurfaces( trRefEntity_t *ent ) {
//
// set up lighting now that we know we aren't culled
//
if ( !personalModel || r_shadows->integer > 1 ) {
if ( !personalModel || r_shadows->integer > 1 || r_playerShadow->integer > 1) {
R_SetupEntityLighting( &tr.refdef, ent );
}
@ -1325,7 +1325,7 @@ void R_AddIQMSurfaces( trRefEntity_t *ent ) {
}
// projection shadows work fine with personal models
if ( r_shadows->integer == 3
if ( (r_shadows->integer == 3 || r_playerShadow->integer == 3)
&& fogNum == 0
&& (ent->e.renderfx & RF_SHADOW_PLANE )
&& shader->sort == SS_OPAQUE ) {

View file

@ -318,7 +318,7 @@ void RB_SunRays(FBO_t *srcFbo, ivec4_t srcBox, FBO_t *dstFbo, ivec4_t dstBox)
mat4_t trans, model;
Mat4Translation( backEnd.viewParms.or.origin, trans );
Mat4Multiply( backEnd.viewParms.world.modelMatrix, trans, model );
Mat4Multiply( backEnd.viewParms.world.modelView, trans, model );
Mat4Multiply(backEnd.viewParms.projectionMatrix, model, mvp);
dist = backEnd.viewParms.zFar / 1.75; // div sqrt(3)
@ -327,7 +327,6 @@ void RB_SunRays(FBO_t *srcFbo, ivec4_t srcBox, FBO_t *dstFbo, ivec4_t dstBox)
}
// project sun point
//Mat4Multiply(backEnd.viewParms.projectionMatrix, backEnd.viewParms.world.modelMatrix, mvp);
Mat4Transform(mvp, pos, hpos);
// transform to UV coords

View file

@ -294,6 +294,7 @@ void RE_BeginScene(const refdef_t *fd)
tr.refdef.height = fd->height;
tr.refdef.fov_x = fd->fov_x;
tr.refdef.fov_y = fd->fov_y;
tr.refdef.isHUD = fd->isHUD;
VectorCopy( fd->vieworg, tr.refdef.vieworg );
VectorCopy( fd->viewaxis[0], tr.refdef.viewaxis[0] );
@ -539,16 +540,27 @@ void RE_RenderScene( const refdef_t *fd ) {
// convert to GL's 0-at-the-bottom space
//
Com_Memset( &parms, 0, sizeof( parms ) );
if (vr_hudDrawStatus->integer != 2 && tr.refdef.isHUD)
{
parms.viewportX = tr.refdef.x;
parms.viewportY = tr.hudImage->height - (tr.refdef.y + tr.refdef.height);
parms.viewportWidth = tr.refdef.width;
parms.viewportHeight = tr.refdef.height;
}
else
{
parms.viewportX = tr.refdef.x;
parms.viewportY = glConfig.vidHeight - (tr.refdef.y + tr.refdef.height);
parms.viewportWidth = tr.refdef.width;
parms.viewportHeight = tr.refdef.height;
}
parms.isPortal = qfalse;
parms.fovX = tr.refdef.fov_x;
parms.fovY = tr.refdef.fov_y;
parms.stereoFrame = tr.refdef.stereoFrame;
//parms.stereoFrame = tr.refdef.stereoFrame;
VectorCopy( fd->vieworg, parms.or.origin );
VectorCopy( fd->viewaxis[0], parms.or.axis[0] );

View file

@ -114,7 +114,8 @@ static void DrawTris (shaderCommands_t *input) {
GLSL_BindProgram(sp);
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, glState.modelMatrix);
GLSL_BindBuffers(sp);
VectorSet4(color, 1, 1, 1, 1);
GLSL_SetUniformVec4(sp, UNIFORM_COLOR, color);
GLSL_SetUniformInt(sp, UNIFORM_ALPHATEST, 0);
@ -352,7 +353,8 @@ static void ProjectDlightTexture( void ) {
GLSL_BindProgram(sp);
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, glState.modelMatrix);
GLSL_BindBuffers(sp);
GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation);
@ -581,9 +583,9 @@ static void ComputeFogValues(vec4_t fogDistanceVector, vec4_t fogDepthVector, fl
fog = tr.world->fogs + tess.fogNum;
VectorSubtract( backEnd.or.origin, backEnd.viewParms.or.origin, local );
fogDistanceVector[0] = -backEnd.or.modelMatrix[2];
fogDistanceVector[1] = -backEnd.or.modelMatrix[6];
fogDistanceVector[2] = -backEnd.or.modelMatrix[10];
fogDistanceVector[0] = -backEnd.or.modelView[2];
fogDistanceVector[1] = -backEnd.or.modelView[6];
fogDistanceVector[2] = -backEnd.or.modelView[10];
fogDistanceVector[3] = DotProduct( local, backEnd.viewParms.or.axis[0] );
// scale the fog vectors based on the fog's thickness
@ -691,7 +693,8 @@ static void ForwardDlight( void ) {
GLSL_BindProgram(sp);
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, glState.modelMatrix);
GLSL_BindBuffers(sp);
GLSL_SetUniformVec3(sp, UNIFORM_VIEWORIGIN, backEnd.viewParms.or.origin);
GLSL_SetUniformVec3(sp, UNIFORM_LOCALVIEWORIGIN, backEnd.or.viewOrigin);
@ -753,7 +756,8 @@ static void ForwardDlight( void ) {
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL );
GLSL_SetUniformInt(sp, UNIFORM_ALPHATEST, 0);
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix);
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, glState.modelMatrix);
GLSL_BindBuffers(sp);
if (pStage->bundle[TB_DIFFUSEMAP].image[0])
R_BindAnimatedImageToTMU( &pStage->bundle[TB_DIFFUSEMAP], TB_DIFFUSEMAP);
@ -844,7 +848,8 @@ static void ProjectPshadowVBOGLSL( void ) {
GLSL_BindProgram(sp);
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, glState.modelMatrix);
GLSL_BindBuffers(sp);
VectorCopy(origin, vector);
vector[3] = 1.0f;
@ -920,7 +925,8 @@ static void RB_FogPass( void ) {
fog = tr.world->fogs + tess.fogNum;
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, glState.modelMatrix);
GLSL_BindBuffers(sp);
GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation);
@ -1094,7 +1100,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
GLSL_BindProgram(sp);
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, glState.modelMatrix);
GLSL_BindBuffers(sp);
GLSL_SetUniformVec3(sp, UNIFORM_VIEWORIGIN, backEnd.viewParms.or.origin);
GLSL_SetUniformVec3(sp, UNIFORM_LOCALVIEWORIGIN, backEnd.or.viewOrigin);
@ -1210,7 +1217,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
}
}
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix);
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, glState.modelMatrix);
GLSL_BindBuffers(sp);
GLSL_SetUniformVec4(sp, UNIFORM_NORMALSCALE, pStage->normalScale);
@ -1413,9 +1421,8 @@ static void RB_RenderShadowmap( shaderCommands_t *input )
GLSL_BindProgram(sp);
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix);
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, glState.modelMatrix);
GLSL_BindBuffers(sp);
GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation);

View file

@ -686,9 +686,9 @@ void RB_CalcFogTexCoords( float *st ) {
// all fogging distance is based on world Z units
VectorSubtract( backEnd.or.origin, backEnd.viewParms.or.origin, local );
fogDistanceVector[0] = -backEnd.or.modelMatrix[2];
fogDistanceVector[1] = -backEnd.or.modelMatrix[6];
fogDistanceVector[2] = -backEnd.or.modelMatrix[10];
fogDistanceVector[0] = -backEnd.or.modelView[2];
fogDistanceVector[1] = -backEnd.or.modelView[6];
fogDistanceVector[2] = -backEnd.or.modelView[10];
fogDistanceVector[3] = DotProduct( local, backEnd.viewParms.or.axis[0] );
// scale the fog vectors based on the fog's thickness

View file

@ -3880,6 +3880,11 @@ static void CreateExternalShaders( void ) {
tr.sunFlareShader = FinishShader();
}
//Set some stuff on our HUD shader
{
tr.hudShader = R_FindShader("sprites/vr/hud", LIGHTMAP_2D, qfalse);
tr.hudShader->stages[0]->bundle[0].image[0] = tr.hudImage;
}
}
/*

View file

@ -252,7 +252,7 @@ overlap and double darken.
void RB_ShadowFinish( void ) {
// FIXME: implement this
#if 0
if ( r_shadows->integer != 2 ) {
if ( r_shadows->integer != 2 || r_playerShadow->integer != 2) {
return;
}
if ( glConfig.stencilBits < 4 ) {

View file

@ -417,29 +417,16 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max
// FIXME: A lot of this can probably be removed for speed, and refactored into a more convenient function
RB_UpdateTessVao(ATTR_POSITION | ATTR_TEXCOORD);
/*
{
shaderProgram_t *sp = &tr.textureColorShader;
GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD);
GLSL_BindProgram(sp);
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
color[0] =
color[1] =
color[2] = tr.identityLight;
color[3] = 1.0f;
GLSL_SetUniformVec4(sp, UNIFORM_COLOR, color);
}
*/
{
shaderProgram_t *sp = &tr.lightallShader[0];
vec4_t vector;
GLSL_BindProgram(sp);
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, glState.modelMatrix);
GLSL_BindBuffers(sp);
color[0] =
color[1] =
@ -796,15 +783,13 @@ void RB_DrawSun( float scale, shader_t *shader ) {
return;
}
//qglLoadMatrixf( backEnd.viewParms.world.modelMatrix );
//qglTranslatef (backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1], backEnd.viewParms.or.origin[2]);
{
// FIXME: this could be a lot cleaner
mat4_t translation, modelview;
mat4_t translation, modelmatrix;
Mat4Translation( backEnd.viewParms.or.origin, translation );
Mat4Multiply( backEnd.viewParms.world.modelMatrix, translation, modelview );
GL_SetModelviewMatrix( modelview, qtrue );
Mat4Multiply( backEnd.viewParms.world.modelMatrix, translation, modelmatrix );
GL_SetModelMatrix( modelmatrix );
}
dist = backEnd.viewParms.zFar / 1.75; // div sqrt(3)
@ -881,16 +866,16 @@ void RB_StageIteratorSky( void ) {
// FIXME: this could be a lot cleaner
mat4_t trans, product;
Mat4Copy( glState.modelview, oldmodelview );
Mat4Copy( glState.modelMatrix, oldmodelview );
Mat4Translation( backEnd.viewParms.or.origin, trans );
Mat4Multiply( glState.modelview, trans, product );
GL_SetModelviewMatrix( product, qtrue );
Mat4Multiply( glState.modelMatrix, trans, product );
GL_SetModelMatrix( product );
}
DrawSkyBox( tess.shader );
GL_SetModelviewMatrix( oldmodelview, qtrue );
GL_SetModelMatrix( oldmodelview );
}
// generate the vertexes for all the clouds, which will be drawn

View file

@ -227,7 +227,8 @@ void RB_InstantQuad(vec4_t quadVerts[4])
GLSL_BindProgram(&tr.textureColorShader);
GLSL_SetUniformMat4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
GLSL_SetUniformMat4(&tr.textureColorShader, UNIFORM_MODELMATRIX, glState.modelMatrix);
GLSL_BindBuffers(&tr.textureColorShader);
GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, colorWhite);
RB_InstantQuad2(quadVerts, texCoords);
@ -249,7 +250,7 @@ static void RB_SurfaceSprite( void ) {
radius = ent->e.radius;
if ( ent->e.rotation == 0 ) {
VectorScale( backEnd.viewParms.or.axis[1], radius, left );
VectorScale( backEnd.viewParms.or.axis[2], radius, up );
VectorScale( backEnd.viewParms.or.axis[2], ent->e.invert ? -radius : radius, up );
} else {
float s, c;
float ang;
@ -539,7 +540,8 @@ static void RB_SurfaceBeam( void )
GLSL_BindProgram(sp);
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, glState.modelMatrix);
GLSL_BindBuffers(sp);
GLSL_SetUniformVec4(sp, UNIFORM_COLOR, colorRed);

View file

@ -589,6 +589,7 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder, qbool
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, samples ? 1 : 0 );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, samples );
#if 0
if(r_stereoEnabled->integer)
{
glConfig.stereoEnabled = qtrue;
@ -602,7 +603,7 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder, qbool
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
#if 0 // if multisampling is enabled on X11, this causes create window to fail.
// if multisampling is enabled on X11, this causes create window to fail.
// If not allowing software GL, demand accelerated
if( !r_allowSoftwareGL->integer )
SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 );
@ -615,7 +616,7 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder, qbool
continue;
}
if( fullscreen )
if( qfalse ) //fullscreen )
{
SDL_DisplayMode mode;
@ -638,7 +639,7 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder, qbool
}
}
SDL_SetWindowIcon( SDL_window, icon );
//SDL_SetWindowIcon( SDL_window, icon );
if (!fixedFunction)
{
@ -648,7 +649,7 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder, qbool
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minorVersion);
ri.Printf(PRINT_ALL, "Trying to get an OpenGL 3.2 core context\n");
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
if ((SDL_glContext = SDL_GL_CreateContext(SDL_window)) == NULL)
@ -1105,10 +1106,11 @@ Responsible for doing a swapbuffers
*/
void GLimp_EndFrame( void )
{
#if 0
//swap window is implemented in VR API, no need to do it here
if ( Q_stricmp( r_drawBuffer->string, "GL_FRONT" ) != 0 )
{
//SDL_GL_SwapWindow( SDL_window );
SDL_GL_SwapWindow( SDL_window );
}
if( r_fullscreen->modified )
@ -1143,4 +1145,5 @@ void GLimp_EndFrame( void )
r_fullscreen->modified = qfalse;
}
#endif
}

View file

@ -3102,6 +3102,7 @@ static void UI_Update(const char *name) {
trap_Cvar_SetValue( "r_fastSky", 0 );
trap_Cvar_SetValue( "r_inGameVideo", 1 );
trap_Cvar_SetValue( "cg_shadows", 1 );
trap_Cvar_SetValue( "cg_playerShadow", 1 );
trap_Cvar_SetValue( "cg_brassTime", 2500 );
trap_Cvar_Set( "r_texturemode", "GL_LINEAR_MIPMAP_LINEAR" );
break;
@ -3122,6 +3123,7 @@ static void UI_Update(const char *name) {
trap_Cvar_SetValue( "cg_brassTime", 2500 );
trap_Cvar_Set( "r_texturemode", "GL_LINEAR_MIPMAP_LINEAR" );
trap_Cvar_SetValue( "cg_shadows", 0 );
trap_Cvar_SetValue( "cg_playerShadow", 0 );
break;
case 2: // fast
trap_Cvar_SetValue( "r_fullScreen", 1 );
@ -3136,6 +3138,7 @@ static void UI_Update(const char *name) {
trap_Cvar_Set( "ui_videomode", "640x480" );
trap_Cvar_SetValue( "r_texturebits", 0 );
trap_Cvar_SetValue( "cg_shadows", 0 );
trap_Cvar_SetValue( "cg_playerShadow", 0 );
trap_Cvar_SetValue( "r_fastSky", 1 );
trap_Cvar_SetValue( "r_inGameVideo", 0 );
trap_Cvar_SetValue( "cg_brassTime", 0 );
@ -3154,6 +3157,7 @@ static void UI_Update(const char *name) {
trap_Cvar_SetValue( "r_picmip", 2 );
trap_Cvar_SetValue( "r_texturebits", 16 );
trap_Cvar_SetValue( "cg_shadows", 0 );
trap_Cvar_SetValue( "cg_playerShadow", 0 );
trap_Cvar_SetValue( "cg_brassTime", 0 );
trap_Cvar_SetValue( "r_fastSky", 1 );
trap_Cvar_SetValue( "r_inGameVideo", 0 );
@ -3170,7 +3174,39 @@ static void UI_Update(const char *name) {
qboolean uturn = trap_Cvar_VariableValue( "vr_uturn" ) != 0;
switch (val)
{
case 0: // Default schema
case 0: // Default schema (weapon wheel on grip)
trap_Cvar_Set("vr_button_map_RTHUMBLEFT", "turnleft"); // turn left
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT", "turnright"); // turn right
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD", ""); // unmapped
if (uturn) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "uturn"); // u-turn
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", ""); // unmapped
}
trap_Cvar_Set("vr_button_map_PRIMARYGRIP", "+weapon_select"); // weapon selector
trap_Cvar_Set("vr_button_map_PRIMARYTHUMBSTICK", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBLEFT_ALT", ""); // unmapped
break;
case 1: // Weapon wheel on thumbstick - all directions as weapon select (useful for HMD wheel)
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBLEFT", "+weapon_select");
trap_Cvar_Set("vr_button_map_PRIMARYTHUMBSTICK", "+weapon_select");
trap_Cvar_Set("vr_button_map_PRIMARYGRIP", "+alt"); // switch to alt layout
trap_Cvar_Set("vr_button_map_RTHUMBLEFT_ALT", "turnleft"); // turn left
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT_ALT", "turnright"); // turn right
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD_ALT", "blank");
if (uturn) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "uturn");
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "blank");
}
break;
default: // Weapon wheel disabled - only prev/next weapon switch is active
trap_Cvar_Set("vr_button_map_RTHUMBLEFT", "turnleft"); // turn left
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT", "turnright"); // turn right
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD", "weapnext"); // next weapon
@ -3179,60 +3215,29 @@ static void UI_Update(const char *name) {
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "weapprev"); // previous weapon
}
trap_Cvar_Set("vr_button_map_PRIMARYGRIP", "+weapon_select"); // weapon selector
trap_Cvar_Set("vr_button_map_PRIMARYGRIP", "+alt"); // switch to alt layout
trap_Cvar_Set("vr_button_map_PRIMARYTHUMBSTICK", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDRIGHT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDRIGHT_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACKRIGHT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACKRIGHT_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACKLEFT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACKLEFT_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBLEFT_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT_ALT", ""); // unmapped
break;
default: // Now we have only two schemas
// All directions as weapon select (useful for HMD wheel)
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDRIGHT", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBBACKRIGHT", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBBACKLEFT", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBLEFT", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT", "+weapon_select");
trap_Cvar_Set("vr_button_map_PRIMARYTHUMBSTICK", "+weapon_select");
trap_Cvar_Set("vr_button_map_PRIMARYGRIP", "+alt"); // switch to alt layout
trap_Cvar_Set("vr_button_map_RTHUMBLEFT_ALT", "turnleft"); // turn left
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT_ALT", "turnright"); // turn right
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD_ALT", "weapnext");
if (uturn) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "uturn");
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "weapprev");
}
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDRIGHT_ALT", "blank"); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACKRIGHT_ALT", "blank"); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACKLEFT_ALT", "blank"); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT_ALT", "blank"); // unmapped
break;
}
} else if (Q_stricmp(name, "vr_uturn") == 0) {
int controlSchema = (int)trap_Cvar_VariableValue( "vr_controlSchema" ) % 2;
int controlSchema = (int)trap_Cvar_VariableValue( "vr_controlSchema" ) % 3;
if (val) {
if (controlSchema == 0) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "uturn");
} else {
if (controlSchema == 1) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "uturn");
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "uturn");
}
} else {
if (controlSchema == 0) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "");
if (controlSchema == 1) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "blank");
} else if (controlSchema == 2) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "weapprev");
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "");
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "");
}
}
} else if (Q_stricmp(name, "vr_goreLevel") == 0) {
@ -3258,6 +3263,15 @@ static void UI_Update(const char *name) {
trap_Cvar_SetValue( "cg_megagibs", 1);
break;
}
} else if (Q_stricmp(name, "vr_hudDrawStatus") == 0) {
switch (val) {
case 2:
trap_Cvar_SetValue("cg_draw3dIcons", 0);
break;
default:
trap_Cvar_SetValue("cg_draw3dIcons", 1);
break;
}
}
}

View file

@ -21,6 +21,7 @@ const uint32_t numRequiredExtensions =
sizeof(requiredExtensionNames) / sizeof(requiredExtensionNames[0]);
cvar_t *vr_worldscale = NULL;
cvar_t *vr_worldscaleScaler = NULL;
cvar_t *vr_hudDepth = NULL;
cvar_t *vr_righthanded = NULL;
cvar_t *vr_switchThumbsticks = NULL;
@ -42,6 +43,8 @@ cvar_t *vr_comfortVignette = NULL;
cvar_t *vr_weaponSelectorMode = NULL;
cvar_t *vr_weaponSelectorWithHud = NULL;
cvar_t *vr_goreLevel = NULL;
cvar_t *vr_hudDrawStatus = NULL;
cvar_t *vr_showConsoleMessages = NULL;
engine_t* VR_Init( ovrJava java )
{
@ -133,6 +136,7 @@ void VR_InitCvars( void )
{
Cvar_Get ("skip_ioq3_credits", "0.0", CVAR_ARCHIVE);
vr_worldscale = Cvar_Get ("vr_worldscale", "32.0", CVAR_ARCHIVE);
vr_worldscaleScaler = Cvar_Get ("vr_worldscaleScaler", "1.0", CVAR_ARCHIVE);
vr_hudDepth = Cvar_Get ("vr_hudDepth", "3", CVAR_ARCHIVE);
vr_righthanded = Cvar_Get ("vr_righthanded", "1", CVAR_ARCHIVE);
vr_switchThumbsticks = Cvar_Get ("vr_switchThumbsticks", "0", CVAR_ARCHIVE);
@ -154,6 +158,8 @@ void VR_InitCvars( void )
vr_weaponSelectorMode = Cvar_Get ("vr_weaponSelectorMode", "0", CVAR_ARCHIVE);
vr_weaponSelectorWithHud = Cvar_Get ("vr_weaponSelectorWithHud", "0", CVAR_ARCHIVE);
vr_goreLevel = Cvar_Get ("vr_goreLevel", "2", CVAR_ARCHIVE);
vr_hudDrawStatus = Cvar_Get ("vr_hudDrawStatus", "1", CVAR_ARCHIVE); // 0 - no hud, 1 - in-world hud, 2 - performance (static HUD)
vr_showConsoleMessages = Cvar_Get ("vr_showConsoleMessages", "1", CVAR_ARCHIVE);
// Values are: scale,right,up,forward,pitch,yaw,roll
// VALUES PROVIDED BY SkillFur - Thank-you!
@ -168,16 +174,49 @@ void VR_InitCvars( void )
Cvar_Get ("vr_weapon_adjustment_9", "0.8,-5.5,6,0,0,0,0", CVAR_ARCHIVE);
//Team Arena Weapons
Cvar_Get ("vr_weapon_adjustment_10", "0.8,-5.5,6,0,0,0,0", CVAR_ARCHIVE);
Cvar_Get ("vr_weapon_adjustment_11", "0.8,-5.5,6,0,0,0,0", CVAR_ARCHIVE);
Cvar_Get ("vr_weapon_adjustment_12", "0.8,-5.5,6,0,0,0,0", CVAR_ARCHIVE);
Cvar_Get ("vr_weapon_adjustment_13", "0.8,-5.5,6,0,0,0,0", CVAR_ARCHIVE);
// Control schemas
Cvar_Get ("vr_uturn", "0", CVAR_ARCHIVE);
Cvar_Get ("vr_controlSchema", "0", CVAR_ARCHIVE);
qboolean uturnEnabled = Cvar_VariableValue( "vr_uturn" ) != 0;
int controlSchema = (int)Cvar_VariableValue( "vr_controlSchema" ) % 2;
int controlSchema = (int)Cvar_VariableValue( "vr_controlSchema" ) % 3;
if (controlSchema == 0) {
// Default schema (weapon wheel on grip)
Cvar_Get ("vr_button_map_RTHUMBLEFT", "turnleft", CVAR_ARCHIVE); // turn left
Cvar_Get ("vr_button_map_RTHUMBRIGHT", "turnright", CVAR_ARCHIVE); // turn right
Cvar_Get ("vr_button_map_RTHUMBFORWARD", "", CVAR_ARCHIVE); // unmapped
if (uturnEnabled) {
Cvar_Get ("vr_button_map_RTHUMBBACK", "uturn", CVAR_ARCHIVE); // u-turn
} else {
Cvar_Get ("vr_button_map_RTHUMBBACK", "", CVAR_ARCHIVE); // unmapped
}
Cvar_Get ("vr_button_map_PRIMARYGRIP", "+weapon_select", CVAR_ARCHIVE); // weapon selector
Cvar_Get ("vr_button_map_PRIMARYTHUMBSTICK", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARD_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBRIGHT_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACK_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBLEFT_ALT", "", CVAR_ARCHIVE); // unmapped
} else if (controlSchema == 1) {
// Weapon wheel on thumbstick - all directions as weapon select (useful for HMD wheel)
Cvar_Get ("vr_button_map_RTHUMBFORWARD", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_RTHUMBRIGHT", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_RTHUMBBACK", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_RTHUMBLEFT", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_PRIMARYTHUMBSTICK", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_PRIMARYGRIP", "+alt", CVAR_ARCHIVE); // switch to alt layout
Cvar_Get ("vr_button_map_RTHUMBLEFT_ALT", "turnleft", CVAR_ARCHIVE); // turn left
Cvar_Get ("vr_button_map_RTHUMBRIGHT_ALT", "turnright", CVAR_ARCHIVE); // turn right
Cvar_Get ("vr_button_map_RTHUMBFORWARD_ALT", "blank", CVAR_ARCHIVE);
if (uturnEnabled) {
Cvar_Get ("vr_button_map_RTHUMBBACK_ALT", "uturn", CVAR_ARCHIVE);
} else {
Cvar_Get ("vr_button_map_RTHUMBBACK_ALT", "blank", CVAR_ARCHIVE);
}
} else {
// Weapon wheel disabled - only prev/next weapon switch is active
Cvar_Get ("vr_button_map_RTHUMBLEFT", "turnleft", CVAR_ARCHIVE); // turn left
Cvar_Get ("vr_button_map_RTHUMBRIGHT", "turnright", CVAR_ARCHIVE); // turn right
Cvar_Get ("vr_button_map_RTHUMBFORWARD", "weapnext", CVAR_ARCHIVE); // next weapon
@ -186,44 +225,12 @@ void VR_InitCvars( void )
} else {
Cvar_Get ("vr_button_map_RTHUMBBACK", "weapprev", CVAR_ARCHIVE); // previous weapon
}
Cvar_Get ("vr_button_map_PRIMARYGRIP", "+weapon_select", CVAR_ARCHIVE); // weapon selector
Cvar_Get ("vr_button_map_PRIMARYGRIP", "+alt", CVAR_ARCHIVE); // switch to alt layout
Cvar_Get ("vr_button_map_PRIMARYTHUMBSTICK", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARD_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARDRIGHT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARDRIGHT_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBRIGHT_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACKRIGHT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACKRIGHT_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACK_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACKLEFT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACKLEFT_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBLEFT_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARDLEFT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARDLEFT_ALT", "", CVAR_ARCHIVE); // unmapped
} else {
// All directions as weapon select (useful for HMD wheel)
Cvar_Get ("vr_button_map_RTHUMBFORWARD", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_RTHUMBFORWARDRIGHT", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_RTHUMBRIGHT", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_RTHUMBBACKRIGHT", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_RTHUMBBACK", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_RTHUMBBACKLEFT", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_RTHUMBLEFT", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_RTHUMBFORWARDLEFT", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_PRIMARYTHUMBSTICK", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_PRIMARYGRIP", "+alt", CVAR_ARCHIVE); // switch to alt layout
Cvar_Get ("vr_button_map_RTHUMBLEFT_ALT", "turnleft", CVAR_ARCHIVE); // turn left
Cvar_Get ("vr_button_map_RTHUMBRIGHT_ALT", "turnright", CVAR_ARCHIVE); // turn right
Cvar_Get ("vr_button_map_RTHUMBFORWARD_ALT", "weapnext", CVAR_ARCHIVE);
if (uturnEnabled) {
Cvar_Get ("vr_button_map_RTHUMBBACK_ALT", "uturn", CVAR_ARCHIVE);
} else {
Cvar_Get ("vr_button_map_RTHUMBBACK_ALT", "weapprev", CVAR_ARCHIVE);
}
Cvar_Get ("vr_button_map_RTHUMBFORWARDRIGHT_ALT", "blank", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACKRIGHT_ALT", "blank", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACKLEFT_ALT", "blank", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARDLEFT_ALT", "blank", CVAR_ARCHIVE); // unmapped
}
//Remaining button mapping (buttons not affected by schemas)

View file

@ -14,14 +14,16 @@ typedef struct {
qboolean weapon_stabilised;
qboolean weapon_zoomed;
qboolean show_console;
float weapon_zoomLevel;
qboolean right_handed;
qboolean virtual_screen;
qboolean local_server; // used in bg_pmove.c
qboolean local_server;
qboolean single_player;
qboolean use_fake_6dof;
vrFollowMode_t follow_mode;
qboolean weapon_select;
qboolean weapon_select_autoclose;
qboolean weapon_select_using_thumbstick;
qboolean no_crosshair;
int realign; // used to realign the fake 6DoF playspace in a multiplayer game

File diff suppressed because it is too large Load diff

View file

@ -165,12 +165,24 @@ void VR_GetResolution(engine_t* engine, int *pWidth, int *pHeight)
}
}
typedef void(GL_APIENTRY* PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC)(
GLenum target,
GLenum attachment,
GLuint texture,
GLint level,
GLint baseViewIndex,
GLsizei numViews);
void VR_InitRenderer( engine_t* engine ) {
#if ENABLE_GL_DEBUG
glEnable(GL_DEBUG_OUTPUT);
glDebugMessageCallback(VR_GLDebugLog, 0);
#endif
PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC glFramebufferTextureMultiviewOVR =
(PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC)eglGetProcAddress(
"glFramebufferTextureMultiviewOVR");
int eyeW, eyeH;
VR_GetResolution(engine, &eyeW, &eyeH);
@ -342,8 +354,8 @@ ovrLayerCylinder2 BuildCylinderLayer(engine_t* engine, const int textureWidth, c
{
ovrMatrix4f modelViewMatrix = ovrMatrix4f_Multiply( &tracking->Eye[eye].ViewMatrix, &cylinderTransform );
layer.Textures[eye].TexCoordsFromTanAngles = ovrMatrix4f_Inverse( &modelViewMatrix );
layer.Textures[eye].ColorSwapChain = engine->framebuffers[eye].colorTexture;
layer.Textures[eye].SwapChainIndex = engine->framebuffers[eye].swapchainIndex;
layer.Textures[eye].ColorSwapChain = engine->framebuffers.colorTexture;
layer.Textures[eye].SwapChainIndex = engine->framebuffers.swapchainIndex;
// Texcoord scale and bias is just a representation of the aspect ratio. The positioning
// of the cylinder is handled entirely by the TexCoordsFromTanAngles matrix.
@ -382,11 +394,13 @@ void VR_DrawFrame( engine_t* engine ) {
vr.weapon_zoomLevel = 1.0f;
}
//Projection used for drawing HUD models etc
const ovrMatrix4f monoVRMatrix = ovrMatrix4f_CreateProjectionFov(
30.0f, 30.0f, 0.0f, 0.0f, 1.0f, 0.0f );
const ovrMatrix4f projectionMatrix = ovrMatrix4f_CreateProjectionFov(
fov_x / vr.weapon_zoomLevel, fov_y / vr.weapon_zoomLevel, 0.0f, 0.0f, 1.0f, 0.0f );
re.SetVRHeadsetParms(projectionMatrix.M,
engine->appState.Renderer.FrameBuffer[0].FrameBuffers[engine->appState.Renderer.FrameBuffer[0].TextureSwapChainIndex],
engine->appState.Renderer.FrameBuffer[1].FrameBuffers[engine->appState.Renderer.FrameBuffer[1].TextureSwapChainIndex]);
re.SetVRHeadsetParms(projectionMatrix.M, monoVRMatrix.M,
engine->appState.Renderer.FrameBuffer[0].FrameBuffers[engine->appState.Renderer.FrameBuffer[0].TextureSwapChainIndex]);
GLboolean stageBoundsDirty = GL_TRUE;
ovrApp_HandleXrEvents(&engine->appState);
@ -589,6 +603,10 @@ void VR_DrawFrame( engine_t* engine ) {
const ovrMatrix4f projectionMatrix = ovrMatrix4f_CreateProjectionFov(
fov_x / vr.weapon_zoomLevel, fov_y / vr.weapon_zoomLevel, 0.0f, 0.0f, 1.0f, 0.0f );
//Projection used for drawing HUD models etc
const ovrMatrix4f monoVRMatrix = ovrMatrix4f_CreateProjectionFov(
30.0f, 30.0f, 0.0f, 0.0f, 1.0f, 0.0f );
int eyeW, eyeH;
VR_GetResolution(engine, &eyeW, &eyeH);
@ -615,18 +633,13 @@ void VR_DrawFrame( engine_t* engine ) {
frameDesc.LayerCount = 1;
frameDesc.Layers = layers;
const framebuffer_t* framebuffers = engine->framebuffers;
re.SetVRHeadsetParms(projectionMatrix->M,
framebuffers[0].framebuffers[framebuffers[0].swapchainIndex],
framebuffers[1].framebuffers[framebuffers[1].swapchainIndex]);
re.SetVRHeadsetParms(&projectionMatrix->M, monoVRMatrix->M,
engine->framebuffers.framebuffers[engine->framebuffers.swapchainIndex]);
Com_Frame();
for (int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; ++eye) {
engine->framebuffers[eye].swapchainIndex = (engine->framebuffers[eye].swapchainIndex + 1) %
engine->framebuffers[eye].swapchainLength;
}
engine->framebuffers.swapchainIndex = (engine->framebuffers.swapchainIndex + 1) %
engine->framebuffers.swapchainLength;
// Hand over the eye images to the time warp.
vrapi_SubmitFrame2(engine->ovr, &frameDesc);
@ -643,27 +656,21 @@ void VR_DrawFrame( engine_t* engine ) {
for (int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; ++eye) {
layer.Textures[eye].ColorSwapChain = engine->framebuffers[eye].colorTexture;
layer.Textures[eye].SwapChainIndex = engine->framebuffers[eye].swapchainIndex;
layer.Textures[eye].ColorSwapChain = engine->framebuffers.colorTexture;
layer.Textures[eye].SwapChainIndex = engine->framebuffers.swapchainIndex;
layer.Textures[eye].TexCoordsFromTanAngles = ovrMatrix4f_TanAngleMatrixFromProjection(&defaultProjection);
}
layer.Header.Flags |= VRAPI_FRAME_LAYER_FLAG_CHROMATIC_ABERRATION_CORRECTION;
VR_ClearFrameBuffer(engine->framebuffers.framebuffers[engine->framebuffers.swapchainIndex], eyeW, eyeH);
const framebuffer_t* framebuffers = engine->framebuffers;
VR_ClearFrameBuffer(framebuffers[0].framebuffers[framebuffers[0].swapchainIndex], eyeW, eyeH);
VR_ClearFrameBuffer(framebuffers[1].framebuffers[framebuffers[1].swapchainIndex], eyeW, eyeH);
re.SetVRHeadsetParms(projectionMatrix->M,
framebuffers[0].framebuffers[framebuffers[0].swapchainIndex],
framebuffers[1].framebuffers[framebuffers[1].swapchainIndex]);
re.SetVRHeadsetParms(&projectionMatrix->M, monoVRMatrix->M,
engine->framebuffers.framebuffers[engine->framebuffers.swapchainIndex]);
Com_Frame();
for (int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; ++eye) {
engine->framebuffers[eye].swapchainIndex = (engine->framebuffers[eye].swapchainIndex + 1) %
engine->framebuffers[eye].swapchainLength;
}
engine->framebuffers.swapchainIndex = (engine->framebuffers.swapchainIndex + 1) %
engine->framebuffers.swapchainLength;
const ovrLayerHeader2* layers[] = {
&layer.Header

View file

@ -4,9 +4,6 @@
#include <android/log.h>
#include <string>
extern "C" {
#include <client/keycodes.h>
#include <qcommon/q_shared.h>
#include <qcommon/qcommon.h>
@ -17,7 +14,7 @@ extern "C" {
#include <SDL.h>
extern void CON_LogcatFn( void (*LogcatFn)( const char* message ) );
}
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "Quake3", __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "Quake3", __VA_ARGS__))
@ -27,14 +24,11 @@ extern "C" {
static JNIEnv* g_Env = NULL;
static JavaVM* g_JavaVM = NULL;
static jobject g_ActivityObject = NULL;
static bool g_HasFocus = true;
static qboolean g_HasFocus = qtrue;
extern "C"
{
JNIEXPORT void JNICALL Java_com_drbeef_ioq3quest_MainActivity_nativeCreate(JNIEnv* env, jclass cls, jobject thisObject)
{
g_ActivityObject = env->NewGlobalRef(thisObject);
g_ActivityObject = (*env)->NewGlobalRef(env, thisObject);
}
JNIEXPORT void JNICALL Java_com_drbeef_ioq3quest_MainActivity_nativeFocusChanged(JNIEnv *env, jclass clazz, jboolean focus)
@ -45,13 +39,12 @@ extern "C"
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
{
g_JavaVM = vm;
if (g_JavaVM->GetEnv((void**) &g_Env, JNI_VERSION_1_4) != JNI_OK) {
if ((*g_JavaVM)->GetEnv(g_JavaVM, (void**) &g_Env, JNI_VERSION_1_4) != JNI_OK) {
return -1;
}
return JNI_VERSION_1_4;
}
}
static void ioq3_logfn(const char* msg)
{
@ -62,13 +55,13 @@ static ovrJava engine_get_ovrJava() {
ovrJava java;
java.Vm = g_JavaVM;
java.ActivityObject = g_ActivityObject;
java.Vm->AttachCurrentThread(&java.Env, NULL);
(*java.Vm)->AttachCurrentThread(java.Vm, &java.Env, NULL);
return java;
}
int main(int argc, char* argv[]) {
ovrJava java = engine_get_ovrJava();
engine_t* engine = nullptr;
engine_t* engine = NULL;
engine = VR_Init(java);
//sleep(30);
@ -87,19 +80,19 @@ int main(int argc, char* argv[]) {
VR_EnterVR(engine, java);
VR_InitRenderer(engine);
bool hasFocus = true;
bool paused = false;
qboolean hasFocus = qtrue;
qboolean paused = qfalse;
while (1) {
if (hasFocus != g_HasFocus) {
hasFocus = g_HasFocus;
if (!hasFocus && !Cvar_VariableValue ("cl_paused")) {
Com_QueueEvent( Sys_Milliseconds(), SE_KEY, K_ESCAPE, qtrue, 0, NULL );
//Com_QueueEvent( Sys_Milliseconds(), SE_KEY, K_CONSOLE, qtrue, 0, NULL );
paused = true;
paused = qtrue;
} else if (hasFocus && paused) {
//Com_QueueEvent( Sys_Milliseconds(), SE_KEY, K_CONSOLE, qtrue, 0, NULL );
Com_QueueEvent( Sys_Milliseconds(), SE_KEY, K_ESCAPE, qtrue, 0, NULL );
paused = false;
paused = qfalse;
}
}

View file

@ -100,13 +100,16 @@ public class MainActivity extends SDLActivity // implements KeyEvent.Callback
//copy demo
copy_asset("/sdcard/ioquake3Quest/baseq3", "pak0.pk3", false);
//our special pak file
//our special pak files
copy_asset("/sdcard/ioquake3Quest/baseq3", "pakQ3Q.pk3", true);
copy_asset("/sdcard/ioquake3Quest/missionpack", "pakQ3Q.pk3", true);
//Copy omarlego's background image pak
copy_asset("/sdcard/ioquake3Quest/baseq3", "pak66.pk3", false);
//If open arena is installed then copy necessary stuff
if (new File("/sdcard/ioquake3Quest/baseoa").exists()) {
copy_asset("/sdcard/ioquake3Quest/baseoa", "autoexec.cfg", false);
copy_asset("/sdcard/ioquake3Quest/baseoa", "autoexec_oa.cfg", "autoexec.cfg", false);
copy_asset("/sdcard/ioquake3Quest/baseoa", "pakQ3Q.pk3", true);
}
@ -136,6 +139,7 @@ public class MainActivity extends SDLActivity // implements KeyEvent.Callback
Log.d(TAG, "setting env");
try {
//commandLineParams += " +map q3dm7";
setenv("commandline", commandLineParams, true);
} catch (Exception e) {
}
@ -151,14 +155,18 @@ public class MainActivity extends SDLActivity // implements KeyEvent.Callback
}
public void copy_asset(String path, String name, boolean force) {
File f = new File(path + "/" + name);
copy_asset(path, name, name, force);
}
public void copy_asset(String path, String name, String newName, boolean force) {
File f = new File(path + "/" + newName);
if (!f.exists() || force) {
//Ensure we have an appropriate folder
String fullname = path + "/" + name;
String directory = fullname.substring(0, fullname.lastIndexOf("/"));
new File(directory).mkdirs();
_copy_asset(name, path + "/" + name);
_copy_asset(name, path + "/" + newName);
}
}

View file

@ -0,0 +1,6 @@
cd assets
del pakQ3Q.pk3
cd ..
powershell Compress-Archive pakQ3Q/* pakQ3Q.zip
rename pakQ3Q.zip pakQ3Q.pk3
move pakQ3Q.pk3 assets/

View file

@ -1,13 +1,22 @@
attribute vec3 attr_Position;
attribute vec4 attr_TexCoord0;
uniform mat4 u_ModelViewProjectionMatrix;
// Uniforms
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
uniform mat4 u_ModelMatrix;
varying vec2 var_TexCoords;
void main()
{
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
var_TexCoords = attr_TexCoord0.st;
}

View file

@ -1,13 +1,23 @@
attribute vec3 attr_Position;
attribute vec4 attr_TexCoord0;
uniform mat4 u_ModelViewProjectionMatrix;
// Uniforms
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
uniform mat4 u_ModelMatrix;
varying vec2 var_TexCoords;
void main()
{
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
var_TexCoords = attr_TexCoord0.st;
}

View file

@ -11,7 +11,18 @@ uniform float u_Time;
#endif
uniform vec4 u_Color;
uniform mat4 u_ModelViewProjectionMatrix;
uniform mat4 u_ModelMatrix;
// Uniforms
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
varying vec2 var_Tex1;
varying vec4 var_Color;
@ -80,7 +91,7 @@ void main()
position = DeformPosition(position, normal, attr_TexCoord0.st);
#endif
gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
vec3 dist = u_DlightInfo.xyz - position;

View file

@ -1,13 +1,24 @@
attribute vec3 attr_Position;
attribute vec4 attr_TexCoord0;
uniform mat4 u_ModelViewProjectionMatrix;
uniform mat4 u_ModelMatrix;
// Uniforms
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
varying vec2 var_TexCoords;
void main()
{
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
var_TexCoords = attr_TexCoord0.st;
}

View file

@ -15,13 +15,14 @@ uniform vec4 u_FogDistance;
uniform vec4 u_FogDepth;
uniform float u_FogEyeT;
uniform mat4 u_ModelMatrix;
#if defined(USE_DEFORM_VERTEXES)
uniform int u_DeformGen;
uniform float u_DeformParams[5];
#endif
uniform float u_Time;
uniform mat4 u_ModelViewProjectionMatrix;
#if defined(USE_VERTEX_ANIMATION)
uniform float u_VertexLerp;
@ -31,6 +32,16 @@ uniform mat4 u_BoneMatrix[MAX_GLSL_BONES];
uniform vec4 u_Color;
// Uniforms
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
varying float var_Scale;
#if defined(USE_DEFORM_VERTEXES)
@ -125,7 +136,7 @@ void main()
position.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st);
#endif
gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
var_Scale = CalcFog(position) * u_Color.a * u_Color.a;
}

View file

@ -36,13 +36,15 @@ uniform float u_FogEyeT;
uniform vec4 u_FogColorMask;
#endif
uniform mat4 u_ModelMatrix;
#if defined(USE_DEFORM_VERTEXES)
uniform int u_DeformGen;
uniform float u_DeformParams[5];
uniform float u_Time;
#endif
uniform mat4 u_ModelViewProjectionMatrix;
uniform vec4 u_BaseColor;
uniform vec4 u_VertColor;
@ -61,6 +63,16 @@ uniform float u_VertexLerp;
uniform mat4 u_BoneMatrix[MAX_GLSL_BONES];
#endif
// Uniforms
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
varying vec2 var_DiffuseTex;
varying vec4 var_Color;
@ -227,7 +239,7 @@ void main()
position = DeformPosition(position, normal, attr_TexCoord0.st);
#endif
gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
#if defined(USE_TCGEN)
vec2 tex = GenTexCoords(u_TCGen0, position, normal, u_TCGen0Vector0, u_TCGen0Vector1);

View file

@ -515,5 +515,10 @@ void main()
#endif
// HACK: use in main menu simple light model (to prevent issue with missing models textures)
#if defined(USE_MENU_LIGHT)
gl_FragColor.rgb = diffuse.rgb * lightColor;
#endif
gl_FragColor.a = alpha;
}

View file

@ -41,13 +41,12 @@ uniform vec4 u_DiffuseTexMatrix;
uniform vec4 u_DiffuseTexOffTurb;
#endif
uniform mat4 u_ModelViewProjectionMatrix;
uniform mat4 u_ModelMatrix;
uniform vec4 u_BaseColor;
uniform vec4 u_VertColor;
#if defined(USE_MODELMATRIX)
uniform mat4 u_ModelMatrix;
#endif
#if defined(USE_VERTEX_ANIMATION)
uniform float u_VertexLerp;
@ -67,6 +66,16 @@ uniform vec4 u_PrimaryLightOrigin;
uniform float u_PrimaryLightRadius;
#endif
// Uniforms
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
varying vec4 var_TexCoords;
varying vec4 var_Color;
@ -188,7 +197,7 @@ void main()
var_TexCoords.xy = texCoords;
#endif
gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
#if defined(USE_MODELMATRIX)
position = (u_ModelMatrix * vec4(position, 1.0)).xyz;

View file

@ -1,14 +1,24 @@
attribute vec3 attr_Position;
attribute vec3 attr_Normal;
uniform mat4 u_ModelViewProjectionMatrix;
uniform mat4 u_ModelMatrix;
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
varying vec3 var_Position;
varying vec3 var_Normal;
void main()
{
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
var_Position = attr_Position;
var_Normal = attr_Normal;

View file

@ -10,13 +10,15 @@ attribute vec4 attr_BoneIndexes;
attribute vec4 attr_BoneWeights;
#endif
// Uniforms
//#if defined(USE_DEFORM_VERTEXES)
uniform int u_DeformGen;
uniform float u_DeformParams[5];
//#endif
uniform float u_Time;
uniform mat4 u_ModelViewProjectionMatrix;
uniform mat4 u_ModelMatrix;
@ -26,6 +28,15 @@ uniform float u_VertexLerp;
uniform mat4 u_BoneMatrix[MAX_GLSL_BONES];
#endif
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
varying vec3 var_Position;
vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st)
@ -102,7 +113,7 @@ void main()
position = DeformPosition(position, normal, attr_TexCoord0.st);
gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
var_Position = (u_ModelMatrix * vec4(position, 1.0)).xyz;
}

View file

@ -1,13 +1,25 @@
attribute vec3 attr_Position;
attribute vec4 attr_TexCoord0;
uniform mat4 u_ModelViewProjectionMatrix;
// Uniforms
uniform mat4 u_ModelMatrix;
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
varying vec2 var_Tex1;
void main()
{
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
var_Tex1 = attr_TexCoord0.st;
}

View file

@ -1,9 +1,21 @@
attribute vec3 attr_Position;
attribute vec4 attr_TexCoord0;
uniform mat4 u_ModelViewProjectionMatrix;
// Uniforms
uniform mat4 u_ModelMatrix;
uniform vec3 u_ToneMinAvgMaxLinear;
layout(shared) uniform ViewMatrices
{
uniform mat4 u_ViewMatrices[NUM_VIEWS];
};
layout(shared) uniform ProjectionMatrix
{
uniform mat4 u_ProjectionMatrix;
};
varying vec2 var_TexCoords;
varying float var_InvWhite;
@ -21,7 +33,7 @@ float FilmicTonemap(float x)
void main()
{
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
var_TexCoords = attr_TexCoord0.st;
var_InvWhite = 1.0 / FilmicTonemap(u_ToneMinAvgMaxLinear.z - u_ToneMinAvgMaxLinear.x);
}

View file

@ -0,0 +1,13 @@
//
// VR Hud Shader Sprite - the image is just a placeholder and is replaced in code
//
sprites/vr/hud
{
cull disable
{
clampmap sprites/plasmaa.tga
blendfunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
}
}

View file

@ -99,10 +99,9 @@ itemDef {
itemDef {
name comfort
group grpComfort
type ITEM_TYPE_MULTI
type ITEM_TYPE_SLIDER
text "HUD Depth:"
cvar "vr_hudDepth"
cvarFloatList { "Very Close" 0 "Close" 1 "Middle" 2 "Further" 3 "Far" 4 "Distant" 5 }
cvarfloat "vr_hudDepth" 1 0 5
rect 99 250 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
@ -116,7 +115,7 @@ itemDef {
name comfort
group grpComfort
type ITEM_TYPE_SLIDER
text "HUD Y Offset:"
text "HUD Vertical Position:"
cvarfloat "vr_hudYOffset" 20 -200 200
rect 99 275 256 20
textalign ITEM_ALIGN_RIGHT

View file

@ -180,7 +180,7 @@ itemDef {
type ITEM_TYPE_MULTI
text "Weapon Wheel Mode:"
cvar "vr_weaponSelectorMode"
cvarFloatList { "Controller Based" 0 "HMD/Thumbstick Based" 1 }
cvarFloatList { "VR Style / Pointing" 0 "Classic / Thumbstick" 1 }
rect 99 300 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
@ -196,7 +196,7 @@ itemDef {
type ITEM_TYPE_MULTI
text "Control Schema:"
cvar "vr_controlSchema"
cvarFloatList { "Weapon Wheel on Grip" 0 "Weapon Wheel on Thumbstick" 1 }
cvarFloatList { "Weapon Wheel on Grip" 0 "Weapon Wheel on Thumbstick" 1 "Weapon Wheel Disabled" 2 }
rect 99 325 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 100

View file

@ -302,7 +302,7 @@ itemDef {
type ITEM_TYPE_MULTI
text "Weapon Wheel Mode:"
cvar "vr_weaponSelectorMode"
cvarFloatList { "Controller Based" 0 "HMD/Thumbstick Based" 1 }
cvarFloatList { "VR Style / Pointing" 0 "Classic / Thumbstick" 1 }
rect 30 182 200 20
textalign ITEM_ALIGN_RIGHT
textalignx 143
@ -318,7 +318,7 @@ itemDef {
type ITEM_TYPE_MULTI
text "Control Schema:"
cvar "vr_controlSchema"
cvarFloatList { "Weapon Wheel on Grip" 0 "Weapon Wheel on Thumbstick" 1 }
cvarFloatList { "Weapon Wheel on Grip" 0 "Weapon Wheel on Thumbstick" 1 "Weapon Wheel Disabled" 2 }
rect 30 200 200 20
textalign ITEM_ALIGN_RIGHT
textalignx 143
@ -402,10 +402,9 @@ itemDef {
itemDef {
name controls
group grpControls
type ITEM_TYPE_MULTI
type ITEM_TYPE_SLIDER
text "HUD Depth:"
cvar "vr_hudDepth"
cvarFloatList { "Very Close" 0 "Close" 1 "Middle" 2 "Further" 3 "Far" 4 "Distant" 5 }
cvarfloat "vr_hudDepth" 1 0 5
rect 30 331 200 20
textalign ITEM_ALIGN_RIGHT
textalignx 143
@ -418,7 +417,7 @@ itemDef {
name controls
group grpControls
type ITEM_TYPE_SLIDER
text "HUD Y Offset:"
text "HUD Vertical Position:"
cvarfloat "vr_hudYOffset" 20 -200 200
rect 30 351 200 20
textalign ITEM_ALIGN_RIGHT

Some files were not shown because too many files have changed in this diff Show more