mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2025-03-14 14:10:56 +00:00
Use much smaller buffer for HUD
only issue now is that the models on the HUD are screwed up position wise and I have no idea how to fix them! :-(
This commit is contained in:
parent
a05e054784
commit
357a87f7e7
15 changed files with 100 additions and 59 deletions
|
@ -2912,12 +2912,12 @@ void CG_DrawActive( void ) {
|
|||
static float hmd_yaw_y = 1.0f;
|
||||
static float prevPitch = 0.0f;
|
||||
{
|
||||
hmd_yaw_x = 0.98f * hmd_yaw_x + 0.02f * cosf(DEG2RAD(vr->hmdorientation[YAW]));
|
||||
hmd_yaw_y = 0.98f * hmd_yaw_y + 0.02f * sinf(DEG2RAD(vr->hmdorientation[YAW]));
|
||||
hmd_yaw_x = 0.97f * hmd_yaw_x + 0.03f * cosf(DEG2RAD(vr->hmdorientation[YAW]));
|
||||
hmd_yaw_y = 0.97f * hmd_yaw_y + 0.03f * sinf(DEG2RAD(vr->hmdorientation[YAW]));
|
||||
}
|
||||
|
||||
angles[YAW] = viewYaw + RAD2DEG(atan2(hmd_yaw_y, hmd_yaw_x));
|
||||
angles[PITCH] = 0.98f * prevPitch + 0.02f * vr->hmdorientation[PITCH];
|
||||
angles[PITCH] = 0.97f * prevPitch + 0.03f * vr->hmdorientation[PITCH];
|
||||
prevPitch = angles[PITCH];
|
||||
angles[ROLL] = 0;
|
||||
AngleVectors(angles, forward, right, up);
|
||||
|
@ -2953,7 +2953,7 @@ void CG_DrawActive( void ) {
|
|||
cg.drawingHUD = qtrue;
|
||||
|
||||
//Tell renderer we want to draw to the HUD buffer
|
||||
trap_R_HUDBufferStart();
|
||||
trap_R_HUDBufferStart(qtrue);
|
||||
|
||||
// draw status bar and other floating elements
|
||||
CG_DrawHUD2D();
|
||||
|
|
|
@ -46,24 +46,24 @@ Adjusted for resolution and screen aspect ratio
|
|||
*/
|
||||
void CG_AdjustFrom640( float *x, float *y, float *w, float *h )
|
||||
{
|
||||
if ( trap_Cvar_VariableValue("vr_hudDrawStatus") != 2.0f ||
|
||||
//If using floating HUD and we are drawing it, then no need to scale as the HUD
|
||||
//buffer is 640x480
|
||||
float screenXScale = cgs.screenXScale;
|
||||
float screenYScale = cgs.screenYScale;
|
||||
if ( trap_Cvar_VariableValue("vr_hudDrawStatus") == 1.0f &&
|
||||
cg.drawingHUD)
|
||||
{
|
||||
screenXScale = 1.0f;
|
||||
screenYScale = 1.0f;
|
||||
}
|
||||
|
||||
if ( trap_Cvar_VariableValue("vr_hudDrawStatus") != 2.0f ||
|
||||
!cg.drawingHUD)
|
||||
{
|
||||
// scale for screen sizes
|
||||
*x *= cgs.screenXScale;
|
||||
*y *= cgs.screenYScale;
|
||||
if (hudflags & HUD_FLAGS_DRAWMODEL)
|
||||
{
|
||||
*w *= (cgs.screenXScale * 4.0f);
|
||||
*x -= (*w / 3);
|
||||
*h *= (cgs.screenYScale * 4.0f);
|
||||
*y -= (*h / 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
*w *= cgs.screenXScale;
|
||||
*h *= cgs.screenYScale;
|
||||
}
|
||||
*x *= screenXScale;
|
||||
*y *= screenYScale;
|
||||
*w *= screenXScale;
|
||||
*h *= screenYScale;
|
||||
}
|
||||
else // scale to clearly visible portion of VR screen
|
||||
{
|
||||
|
@ -74,9 +74,9 @@ void CG_AdjustFrom640( float *x, float *y, float *w, float *h )
|
|||
*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
|
||||
|
|
|
@ -1662,7 +1662,7 @@ 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( void );
|
||||
void trap_R_HUDBufferStart( qboolean clear );
|
||||
void trap_R_HUDBufferEnd( void );
|
||||
|
||||
// The glconfig_t will not change during the life of a cgame.
|
||||
|
|
|
@ -288,8 +288,8 @@ void trap_R_RenderScene( const refdef_t *fd ) {
|
|||
syscall( CG_R_RENDERSCENE, fd );
|
||||
}
|
||||
|
||||
void trap_R_HUDBufferStart( void ) {
|
||||
syscall( CG_R_HUDBUFFER_START );
|
||||
void trap_R_HUDBufferStart( qboolean clear ) {
|
||||
syscall( CG_R_HUDBUFFER_START, clear );
|
||||
}
|
||||
|
||||
void trap_R_HUDBufferEnd( void ) {
|
||||
|
|
|
@ -698,7 +698,7 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) {
|
|||
VR_HapticEvent( VMA(1), args[2], args[3], args[4], VMF(5), VMF(6) );
|
||||
return 0;
|
||||
case CG_R_HUDBUFFER_START:
|
||||
re.HUDBufferStart();
|
||||
re.HUDBufferStart(args[1]);
|
||||
return 0;
|
||||
case CG_R_HUDBUFFER_END:
|
||||
re.HUDBufferEnd();
|
||||
|
|
|
@ -580,6 +580,8 @@ void Con_DrawNotify (void)
|
|||
currentColor = 7;
|
||||
re.SetColor( g_color_table[currentColor] );
|
||||
|
||||
re.HUDBufferStart(qfalse);
|
||||
|
||||
v = 0;
|
||||
for (i= con.current-NUM_CON_TIMES+1 ; i<=con.current ; i++)
|
||||
{
|
||||
|
@ -613,6 +615,8 @@ void Con_DrawNotify (void)
|
|||
|
||||
re.SetColor( NULL );
|
||||
|
||||
re.HUDBufferEnd();
|
||||
|
||||
if (Key_GetCatcher( ) & (KEYCATCH_UI | KEYCATCH_CGAME) ) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -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 == 1) {
|
||||
if (x) {
|
||||
*x *= xscale;
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ 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)( void );
|
||||
void (*HUDBufferStart)( qboolean clear );
|
||||
void (*HUDBufferEnd)( void );
|
||||
|
||||
void (*SetColor)( const float *rgba ); // NULL = 1,1,1,1
|
||||
|
|
|
@ -305,11 +305,19 @@ static void RB_Hyperspace( void ) {
|
|||
static void SetViewportAndScissor( void ) {
|
||||
GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix );
|
||||
|
||||
// set the window clipping
|
||||
qglViewport( backEnd.viewParms.viewportX, backEnd.viewParms.viewportY,
|
||||
backEnd.viewParms.viewportWidth, backEnd.viewParms.viewportHeight );
|
||||
qglScissor( backEnd.viewParms.viewportX, backEnd.viewParms.viewportY,
|
||||
backEnd.viewParms.viewportWidth, backEnd.viewParms.viewportHeight );
|
||||
if (glState.isDrawingHUD && vr_hudDrawStatus->integer == 1)
|
||||
{
|
||||
qglViewport(0, 0, tr.hudImage->width, tr.hudImage->height);
|
||||
qglScissor(0, 0, tr.hudImage->width, tr.hudImage->height);
|
||||
}
|
||||
else
|
||||
{
|
||||
// set the window clipping
|
||||
qglViewport(backEnd.viewParms.viewportX, backEnd.viewParms.viewportY,
|
||||
backEnd.viewParms.viewportWidth, backEnd.viewParms.viewportHeight);
|
||||
qglScissor(backEnd.viewParms.viewportX, backEnd.viewParms.viewportY,
|
||||
backEnd.viewParms.viewportWidth, backEnd.viewParms.viewportHeight);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -628,8 +636,16 @@ void RB_SetGL2D (void) {
|
|||
}
|
||||
|
||||
// set 2D virtual screen size
|
||||
qglViewport( 0, 0, width, height );
|
||||
qglScissor( 0, 0, width, height );
|
||||
if (glState.isDrawingHUD && vr_hudDrawStatus->integer == 1)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
Mat4Ortho(0, width, height, 0, 0, 1, matrix);
|
||||
GL_SetProjectionMatrix(matrix);
|
||||
|
@ -1770,7 +1786,7 @@ const void* RB_HUDBuffer( const void* data ) {
|
|||
if(tess.numIndexes)
|
||||
RB_EndSurface();
|
||||
|
||||
if (cmd->start && tr.renderFbo->frameBuffer != tr.hudFbo->frameBuffer)
|
||||
if (cmd->start && !glState.isDrawingHUD)
|
||||
{
|
||||
glState.isDrawingHUD = qtrue;
|
||||
|
||||
|
@ -1800,8 +1816,11 @@ const void* RB_HUDBuffer( const void* data ) {
|
|||
ri.Error("Error binding Framebuffer: %i\n", result);
|
||||
}
|
||||
|
||||
qglClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
qglClear(GL_COLOR_BUFFER_BIT);
|
||||
if (cmd->clear)
|
||||
{
|
||||
qglClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
qglClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (glState.isDrawingHUD)
|
||||
|
|
|
@ -474,7 +474,7 @@ void RE_EndFrame( int *frontEndMsec, int *backEndMsec ) {
|
|||
backEnd.pc.msec = 0;
|
||||
}
|
||||
|
||||
void RE_HUDBufferStart( void )
|
||||
void RE_HUDBufferStart( qboolean clear )
|
||||
{
|
||||
hudBufferCommand_t *cmd;
|
||||
|
||||
|
@ -486,6 +486,7 @@ void RE_HUDBufferStart( void )
|
|||
return;
|
||||
}
|
||||
cmd->start = qtrue;
|
||||
cmd->clear = clear;
|
||||
cmd->commandId = RC_HUD_BUFFER;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,8 +68,9 @@ typedef struct uniformInfo_s
|
|||
uniformInfo_t;
|
||||
|
||||
typedef enum {
|
||||
HUD_ORTHO_PROJECTION, // Orthographic projection and no stereo view
|
||||
STEREO_ORTHO_PROJECTION, // Orthographic projection with a slight stereo offset per eye
|
||||
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,
|
||||
|
||||
|
@ -207,7 +208,8 @@ static void GLSL_ViewMatricesUniformBuffer(const float eyeView[32], const float
|
|||
|
||||
switch (i)
|
||||
{
|
||||
case HUD_ORTHO_PROJECTION:
|
||||
case FULLSCREEN_ORTHO_PROJECTION:
|
||||
case HUDBUFFER_ORTHO_PROJECTION:
|
||||
{
|
||||
Mat4Identity( viewMatrices );
|
||||
Mat4Identity( viewMatrices + 16 );
|
||||
|
@ -1670,6 +1672,7 @@ void GLSL_ShutdownGPUShaders(void)
|
|||
GLSL_DeleteGPUShader(&tr.depthBlurShader[i]);
|
||||
}
|
||||
|
||||
|
||||
void GLSL_PrepareUniformBuffers(void)
|
||||
{
|
||||
int width, height;
|
||||
|
@ -1687,16 +1690,22 @@ void GLSL_PrepareUniformBuffers(void)
|
|||
Mat4Ortho(0, width, height, 0, 0, 1, orthoProjectionMatrix);
|
||||
|
||||
//ortho projection matrices
|
||||
GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[HUD_ORTHO_PROJECTION],
|
||||
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);
|
||||
|
||||
GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[MONO_VR_PROJECTION],
|
||||
tr.vrParms.projection);
|
||||
tr.vrParms.projection);
|
||||
|
||||
//Set all view matrices
|
||||
GLSL_ViewMatricesUniformBuffer(tr.viewParms.world.eyeViewMatrix, tr.viewParms.world.modelView);
|
||||
|
@ -1720,18 +1729,23 @@ void GLSL_BindProgram(shaderProgram_t * program)
|
|||
static GLuint GLSL_CalculateProjection() {
|
||||
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))
|
||||
{
|
||||
if (glState.isDrawingHUD && vr_hudDrawStatus->integer == 2)
|
||||
{
|
||||
result = STEREO_ORTHO_PROJECTION;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = HUD_ORTHO_PROJECTION;
|
||||
}
|
||||
if (glState.isDrawingHUD)
|
||||
{
|
||||
if (vr_hudDrawStatus->integer == 1)
|
||||
{
|
||||
result = HUDBUFFER_ORTHO_PROJECTION;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = STEREO_ORTHO_PROJECTION;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = FULLSCREEN_ORTHO_PROJECTION;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -2784,8 +2784,8 @@ 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, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat);
|
||||
tr.hudDepthImage = R_CreateImage("*hudDepth", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24);
|
||||
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);
|
||||
|
|
|
@ -2467,6 +2467,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
int commandId;
|
||||
qboolean start;
|
||||
qboolean clear; // Clear the buffer?
|
||||
} hudBufferCommand_t;
|
||||
|
||||
typedef enum {
|
||||
|
@ -2530,7 +2531,7 @@ void RE_EndFrame( int *frontEndMsec, int *backEndMsec );
|
|||
void RE_SetVRHeadsetParms( const ovrMatrix4f *projectionMatrix,
|
||||
int renderBuffer );
|
||||
#endif
|
||||
void RE_HUDBufferStart( void );
|
||||
void RE_HUDBufferStart( qboolean clear );
|
||||
void RE_HUDBufferEnd( void );
|
||||
|
||||
void RE_SaveJPG(char * filename, int quality, int image_width, int image_height,
|
||||
|
|
|
@ -1717,7 +1717,8 @@ void R_RenderView (viewParms_t *parms) {
|
|||
// set viewParms.world
|
||||
R_RotateForViewer ();
|
||||
|
||||
GLSL_PrepareUniformBuffers();
|
||||
//can we get away without this?!
|
||||
//GLSL_PrepareUniformBuffers();
|
||||
|
||||
R_SetupProjection(&tr.viewParms, r_zproj->value, tr.viewParms.zFar, qtrue);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
setlocal
|
||||
|
||||
set BUILD_TYPE=release
|
||||
set BUILD_TYPE=debug
|
||||
set VERSION=0.29.3-multiview
|
||||
|
||||
@REM Define the following environment variables to sign a release build
|
||||
|
|
Loading…
Reference in a new issue