diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index c6065f7f..28184fdb 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="41" + android:versionName="0.29.2"> diff --git a/android/app/src/main/assets/pakQ3Q.pk3 b/android/app/src/main/assets/pakQ3Q.pk3 index 80a46d4d..13b61676 100644 Binary files a/android/app/src/main/assets/pakQ3Q.pk3 and b/android/app/src/main/assets/pakQ3Q.pk3 differ diff --git a/android/app/src/main/cpp/code/cgame/cg_draw.c b/android/app/src/main/cpp/code/cgame/cg_draw.c index 68d4f325..e3fe06a7 100644 --- a/android/app/src/main/cpp/code/cgame/cg_draw.c +++ b/android/app/src/main/cpp/code/cgame/cg_draw.c @@ -2647,10 +2647,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) { @@ -2671,24 +2671,14 @@ static void CG_Draw2D() 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; @@ -2709,10 +2699,6 @@ static void CG_Draw2D() CG_DrawProxWarning(); #endif - if(vr->weapon_zoomed) { - CG_DrawWeapReticle(); - } - CG_DrawCrosshairNames(); CG_DrawWeaponSelect(); @@ -2760,6 +2746,37 @@ 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_draw2D.integer == 0 ) { + 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 @@ -2897,7 +2914,7 @@ void CG_DrawActive( void ) { memset(&ent, 0, sizeof(ent)); ent.reType = RT_SPRITE; - ent.renderfx = RF_DEPTHHACK; + ent.renderfx = RF_DEPTHHACK | RF_FIRST_PERSON; VectorCopy(endpos, ent.origin); @@ -2918,9 +2935,12 @@ void CG_DrawActive( void ) { trap_R_HUDBufferStart(); // draw status bar and other floating elements - CG_Draw2D(); + CG_DrawHUD2D(); trap_R_HUDBufferEnd(); + + //Now draw the screen 2D stuff + CG_DrawScreen2D(); } CG_EmptySceneHackHackHack(); diff --git a/android/app/src/main/cpp/code/cgame/cg_drawtools.c b/android/app/src/main/cpp/code/cgame/cg_drawtools.c index e3e55229..1d8aa2ea 100644 --- a/android/app/src/main/cpp/code/cgame/cg_drawtools.c +++ b/android/app/src/main/cpp/code/cgame/cg_drawtools.c @@ -54,9 +54,9 @@ void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) *y *= cgs.screenYScale; if (hudflags & HUD_FLAGS_DRAWMODEL) { - *w *= (cgs.screenXScale * 2.0f); + *w *= (cgs.screenXScale * 4.0f); *x -= (*w / 3); - *h *= (cgs.screenYScale * 2.0f); + *h *= (cgs.screenYScale * 4.0f); *y -= (*h / 3); } else diff --git a/android/app/src/main/cpp/code/renderergles3/tr_backend.c b/android/app/src/main/cpp/code/renderergles3/tr_backend.c index 79c44e0f..152363cb 100644 --- a/android/app/src/main/cpp/code/renderergles3/tr_backend.c +++ b/android/app/src/main/cpp/code/renderergles3/tr_backend.c @@ -1771,6 +1771,7 @@ const void* RB_HUDBuffer( const void* data ) { if (cmd->start && tr.renderFbo->frameBuffer != tr.hudFbo->frameBuffer) { + glState.isDrawingHUD = qtrue; //keep record of current render fbo and switch to the hud buffer tr.backupFrameBuffer = tr.renderFbo->frameBuffer; tr.renderFbo->frameBuffer = tr.hudFbo->frameBuffer; @@ -1790,11 +1791,12 @@ const void* RB_HUDBuffer( const void* data ) { ri.Error( "Error binding Framebuffer: %i\n", result ); } - qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); + qglClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); qglClear( GL_COLOR_BUFFER_BIT ); } else if (tr.renderFbo->frameBuffer == tr.hudFbo->frameBuffer) { + glState.isDrawingHUD = qfalse; //restore the true render fbo tr.renderFbo->frameBuffer = tr.backupFrameBuffer; GL_BindFramebuffer(GL_FRAMEBUFFER, tr.renderFbo->frameBuffer); diff --git a/android/app/src/main/cpp/code/renderergles3/tr_glsl.c b/android/app/src/main/cpp/code/renderergles3/tr_glsl.c index 061ad4f1..f56141b0 100644 --- a/android/app/src/main/cpp/code/renderergles3/tr_glsl.c +++ b/android/app/src/main/cpp/code/renderergles3/tr_glsl.c @@ -67,9 +67,9 @@ typedef struct uniformInfo_s uniformInfo_t; typedef enum { -// STEREO_ORTHO_PROJECTION, // An orthographic projection with slight stereo view matrix HUD_ORTHO_PROJECTION, // Orthographic projection and no stereo view VR_PROJECTION, + MONO_VR_PROJECTION, PROJECTION_COUNT } projection_t; @@ -185,7 +185,7 @@ glslPrintLog_t; GLSL_ViewMatricesUniformBuffer ==================== */ -static void GLSL_ViewMatricesUniformBuffer(const float value[32]) { +static void GLSL_ViewMatricesUniformBuffer(const float eyeView[32], const float modelView[32]) { for (int i = 0; i < PROJECTION_COUNT; ++i) { @@ -211,9 +211,16 @@ static void GLSL_ViewMatricesUniformBuffer(const float value[32]) { Mat4Identity( viewMatrices + 16 ); } break; - default: + case VR_PROJECTION: { - memcpy((char *) viewMatrices, value, 32 * sizeof(float)); + Mat4Copy(eyeView, viewMatrices); + Mat4Copy(eyeView+16, viewMatrices+16); + } + break; + case MONO_VR_PROJECTION: + { + Mat4Copy(modelView, viewMatrices); + Mat4Copy(modelView, viewMatrices+16); } break; } @@ -1667,18 +1674,17 @@ void GLSL_PrepareUniformBuffers(void) Mat4Ortho(0, width, height, 0, 0, 1, orthoProjectionMatrix); //ortho projection matrix -/* GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[STEREO_ORTHO_PROJECTION], - orthoProjectionMatrix); -*/ GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[HUD_ORTHO_PROJECTION], orthoProjectionMatrix); //VR projection matrix GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[VR_PROJECTION], tr.vrParms.projection); + GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[MONO_VR_PROJECTION], + tr.vrParms.projection); - //Set up the buffers that won't change this frame - GLSL_ViewMatricesUniformBuffer(tr.viewParms.world.eyeViewMatrix); + //Set all view matrices + GLSL_ViewMatricesUniformBuffer(tr.viewParms.world.eyeViewMatrix, tr.viewParms.world.modelView); } void GLSL_BindProgram(shaderProgram_t * program) @@ -1697,8 +1703,10 @@ void GLSL_BindProgram(shaderProgram_t * program) } static GLuint GLSL_CalculateProjection() { - GLuint result = VR_PROJECTION; + GLuint result = glState.isDrawingHUD ? MONO_VR_PROJECTION : VR_PROJECTION; + //If we are using an orthographic projection, then we don't need the mono VR projection + //as we aren't drawing models to the HUD if (Mat4Compare(&orthoProjectionMatrix, glState.projection)) { result = HUD_ORTHO_PROJECTION; diff --git a/android/app/src/main/cpp/code/renderergles3/tr_local.h b/android/app/src/main/cpp/code/renderergles3/tr_local.h index 9150e636..6464736f 100644 --- a/android/app/src/main/cpp/code/renderergles3/tr_local.h +++ b/android/app/src/main/cpp/code/renderergles3/tr_local.h @@ -1390,6 +1390,7 @@ typedef struct { mat4_t modelMatrix; mat4_t projection; + qboolean isDrawingHUD; } glstate_t; typedef enum { diff --git a/android/app/src/main/cpp/code/renderergles3/tr_main.c b/android/app/src/main/cpp/code/renderergles3/tr_main.c index 17fdb0f4..6d0af253 100644 --- a/android/app/src/main/cpp/code/renderergles3/tr_main.c +++ b/android/app/src/main/cpp/code/renderergles3/tr_main.c @@ -1520,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 // diff --git a/android/app/src/main/pakQ3Q/scripts/vr.shader b/android/app/src/main/pakQ3Q/scripts/vr.shader index ea75133c..8abbc4ec 100644 --- a/android/app/src/main/pakQ3Q/scripts/vr.shader +++ b/android/app/src/main/pakQ3Q/scripts/vr.shader @@ -8,6 +8,6 @@ sprites/vr/hud cull disable { clampmap sprites/plasmaa.tga - blendfunc GL_ONE GL_ONE + blendfunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA } } \ No newline at end of file diff --git a/android/run.bat b/android/run.bat index 5024be1d..2fcf8017 100644 --- a/android/run.bat +++ b/android/run.bat @@ -2,8 +2,8 @@ setlocal -set BUILD_TYPE=release -set VERSION=0.29.1-multiview +set BUILD_TYPE=debug +set VERSION=0.29.2-multiview @REM Define the following environment variables to sign a release build @REM set KEYSTORE=