From 57975fbf6b9ae66a76430e1551cf74ded4ed7d44 Mon Sep 17 00:00:00 2001 From: black Date: Thu, 27 Apr 2006 20:23:42 +0000 Subject: [PATCH] Add _DrawQ_ProcessDrawFlag to clean-up the glblend setup code. Add CL_Video_KeyEvent and support for it to Key_Event, now the the fullscreen video is closed automatically when you hit enter, space or escape and the video system catches all input (no more accidentially nagivating around in the menu). (Please test this and report bugs to black@icculus.org if you find any) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6339 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_video.c | 10 +++++++++ cl_video.h | 4 ++++ gl_draw.c | 59 +++++++++++++++++------------------------------------- keys.c | 9 ++++++++- 4 files changed, 40 insertions(+), 42 deletions(-) diff --git a/cl_video.c b/cl_video.c index bc226e46..8ea468b3 100644 --- a/cl_video.c +++ b/cl_video.c @@ -276,6 +276,16 @@ void CL_VideoStart(char *filename) CL_RestartVideo( cl_videos ); } +void CL_Video_KeyEvent( int key, int ascii, qboolean down ) +{ + // only react to up events, to allow the user to delay the abortion point if it suddenly becomes interesting.. + if( !down ) { + if( key == K_ESCAPE || key == K_ENTER || key == K_SPACE ) { + CL_VideoStop(); + } + } +} + void CL_VideoStop(void) { cl_videoplaying = false; diff --git a/cl_video.h b/cl_video.h index 878d2494..cc38798f 100644 --- a/cl_video.h +++ b/cl_video.h @@ -64,4 +64,8 @@ void CL_DrawVideo( void ); void CL_VideoStart( char *filename ); void CL_VideoStop( void ); +// new function used for fullscreen videos +// TODO: Andreas Kirsch: move this subsystem somewhere else (preferably host) since the cl_video system shouldnt do such work like managing key events.. +void CL_Video_KeyEvent( int key, int ascii, qboolean down ); + #endif diff --git a/gl_draw.c b/gl_draw.c index bebaee30..7a263f96 100644 --- a/gl_draw.c +++ b/gl_draw.c @@ -515,6 +515,19 @@ void DrawQ_Begin(void) r_refdef.draw2dstage = true; } +static void _DrawQ_ProcessDrawFlag(int flags) +{ + CHECKGLERROR + if(flags == DRAWFLAG_ADDITIVE) + GL_BlendFunc(GL_SRC_ALPHA, GL_ONE); + else if(flags == DRAWFLAG_MODULATE) + GL_BlendFunc(GL_DST_COLOR, GL_ZERO); + else if(flags == DRAWFLAG_2XMODULATE) + GL_BlendFunc(GL_DST_COLOR,GL_SRC_COLOR); + else + GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +} + void DrawQ_Pic(float x, float y, cachepic_t *pic, float width, float height, float red, float green, float blue, float alpha, int flags) { if (!r_refdef.draw2dstage) @@ -545,14 +558,7 @@ void DrawQ_String_Real(float x, float y, const char *string, int maxlen, float w if (alpha < (1.0f / 255.0f)) return; - if(flags == DRAWFLAG_ADDITIVE) - GL_BlendFunc(GL_SRC_ALPHA, GL_ONE); - else if(flags == DRAWFLAG_MODULATE) - GL_BlendFunc(GL_DST_COLOR, GL_ZERO); - else if(flags == DRAWFLAG_2XMODULATE) - GL_BlendFunc(GL_DST_COLOR,GL_SRC_COLOR); - else - GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + _DrawQ_ProcessDrawFlag(flags); GL_Color(red, green, blue, alpha); @@ -746,14 +752,7 @@ void DrawQ_SuperPic(float x, float y, cachepic_t *pic, float width, float height if (!r_render.integer) return; - if(flags == DRAWFLAG_ADDITIVE) - GL_BlendFunc(GL_SRC_ALPHA, GL_ONE); - else if(flags == DRAWFLAG_MODULATE) - GL_BlendFunc(GL_DST_COLOR, GL_ZERO); - else if(flags == DRAWFLAG_2XMODULATE) - GL_BlendFunc(GL_DST_COLOR,GL_SRC_COLOR); - else - GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + _DrawQ_ProcessDrawFlag(flags); R_Mesh_VertexPointer(floats); R_Mesh_ColorPointer(floats + 20); @@ -796,14 +795,7 @@ void DrawQ_Mesh (drawqueuemesh_t *mesh, int flags) if (!r_render.integer) return; - if(flags == DRAWFLAG_ADDITIVE) - GL_BlendFunc(GL_SRC_ALPHA, GL_ONE); - else if(flags == DRAWFLAG_MODULATE) - GL_BlendFunc(GL_DST_COLOR, GL_ZERO); - else if(flags == DRAWFLAG_2XMODULATE) - GL_BlendFunc(GL_DST_COLOR,GL_SRC_COLOR); - else - GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + _DrawQ_ProcessDrawFlag(flags); R_Mesh_VertexPointer(mesh->data_vertex3f); R_Mesh_ColorPointer(mesh->data_color4f); @@ -829,15 +821,7 @@ void DrawQ_LineLoop (drawqueuemesh_t *mesh, int flags) if (!r_render.integer) return; - CHECKGLERROR - if(flags == DRAWFLAG_ADDITIVE) - GL_BlendFunc(GL_SRC_ALPHA, GL_ONE); - else if(flags == DRAWFLAG_MODULATE) - GL_BlendFunc(GL_DST_COLOR, GL_ZERO); - else if(flags == DRAWFLAG_2XMODULATE) - GL_BlendFunc(GL_DST_COLOR,GL_SRC_COLOR); - else - GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + _DrawQ_ProcessDrawFlag(flags); GL_Color(1,1,1,1); CHECKGLERROR @@ -880,14 +864,7 @@ void DrawQ_Line (float width, float x1, float y1, float x2, float y2, float r, f if(width > 0) DrawQ_LineWidth(width); - if(flags == DRAWFLAG_ADDITIVE) - GL_BlendFunc(GL_SRC_ALPHA, GL_ONE); - else if(flags == DRAWFLAG_MODULATE) - GL_BlendFunc(GL_DST_COLOR, GL_ZERO); - else if(flags == DRAWFLAG_2XMODULATE) - GL_BlendFunc(GL_DST_COLOR,GL_SRC_COLOR); - else - GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + _DrawQ_ProcessDrawFlag(flags); GL_Color(r,g,b,alpha); CHECKGLERROR diff --git a/keys.c b/keys.c index 8bdc4e1d..9db315f5 100644 --- a/keys.c +++ b/keys.c @@ -21,7 +21,7 @@ */ #include "quakedef.h" - +#include "cl_video.h" /* key up events are sent even if in console mode @@ -959,6 +959,13 @@ Key_Event (int key, char ascii, qboolean down) return; } + // ignore binds while a video is played, let the video system handle the key event + if (cl_videoplaying) + { + CL_Video_KeyEvent (key, ascii, keydown[key] != 0); + return; + } + // anything else is a key press into the game, chat line, or menu switch (key_dest) { -- 2.39.2