]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Add _DrawQ_ProcessDrawFlag to clean-up the glblend setup code.
authorblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 27 Apr 2006 20:23:42 +0000 (20:23 +0000)
committerblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 27 Apr 2006 20:23:42 +0000 (20:23 +0000)
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
cl_video.h
gl_draw.c
keys.c

index bc226e46e8bcfb2b48861f482ee2cca82fab518a..8ea468b3475ed546b02eb6ac8a8307bd4770b776 100644 (file)
@@ -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;
index 878d24941babc5296b1e570504beaa588de22477..cc38798f0c435413ebc7c089ce5bea351ef88b49 100644 (file)
@@ -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
index bebaee3078b79fd497a3b3ae227381b6f428997d..7a263f9656113c88b3e72385e1ade9aa2c95cadf 100644 (file)
--- 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 8bdc4e1de06e8b2a3c910d63a9136ff74aea1215..9db315f565821428dbeea8a380b8ef02acb5dc98 100644 (file)
--- 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)
        {