]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_screen.c
no time to explain, more changes on the path to q3bsp support
[xonotic/darkplaces.git] / cl_screen.c
index ceffda767f343cc228ec50f75c9828e5e93fbd25..19e72e96a7b57fdd55c3cacc1ec657ef9fd6ab85 100644 (file)
@@ -2,10 +2,13 @@
 #include "quakedef.h"
 #include "cl_video.h"
 #include "jpeg.h"
+#include "cl_collision.h"
 
 cvar_t scr_viewsize = {CVAR_SAVE, "viewsize","100"};
 cvar_t scr_fov = {CVAR_SAVE, "fov","90"};      // 10 - 170
 cvar_t scr_conspeed = {CVAR_SAVE, "scr_conspeed","900"}; // LordHavoc: quake used 300
+cvar_t scr_conalpha = {CVAR_SAVE, "scr_conalpha", "1"};
+cvar_t scr_conbrightness = {CVAR_SAVE, "scr_conbrightness", "0.2"};
 cvar_t scr_centertime = {0, "scr_centertime","2"};
 cvar_t scr_showram = {CVAR_SAVE, "showram","1"};
 cvar_t scr_showturtle = {CVAR_SAVE, "showturtle","0"};
@@ -168,7 +171,7 @@ void SCR_DrawTurtle (void)
        if (count < 3)
                return;
 
-       DrawQ_Pic (0, 0, "turtle", 0, 0, 1, 1, 1, 1, 0);
+       DrawQ_Pic (0, 0, "gfx/turtle.lmp", 0, 0, 1, 1, 1, 1, 0);
 }
 
 /*
@@ -185,7 +188,7 @@ void SCR_DrawNet (void)
        if (cls.demoplayback)
                return;
 
-       DrawQ_Pic (64, 0, "net", 0, 0, 1, 1, 1, 1, 0);
+       DrawQ_Pic (64, 0, "gfx/net.lmp", 0, 0, 1, 1, 1, 1, 0);
 }
 
 /*
@@ -458,6 +461,8 @@ void CL_Screen_Init(void)
        Cvar_RegisterVariable (&scr_fov);
        Cvar_RegisterVariable (&scr_viewsize);
        Cvar_RegisterVariable (&scr_conspeed);
+       Cvar_RegisterVariable (&scr_conalpha);
+       Cvar_RegisterVariable (&scr_conbrightness);
        Cvar_RegisterVariable (&scr_showram);
        Cvar_RegisterVariable (&scr_showturtle);
        Cvar_RegisterVariable (&scr_showpause);
@@ -496,62 +501,7 @@ void DrawQ_Clear(void)
 static int picelements[6] = {0, 1, 2, 0, 2, 3};
 void DrawQ_Pic(float x, float y, char *picname, float width, float height, float red, float green, float blue, float alpha, int flags)
 {
-#if 1
        DrawQ_SuperPic(x,y,picname,width,height,0,0,red,green,blue,alpha,1,0,red,green,blue,alpha,0,1,red,green,blue,alpha,1,1,red,green,blue,alpha,flags);
-#elif 1
-       float floats[48];
-       cachepic_t *pic;
-       drawqueuemesh_t mesh;
-       if (alpha < (1.0f / 255.0f) || !picname || !picname[0])
-               return;
-       pic = Draw_CachePic(picname);
-       if (width == 0)
-               width = pic->width;
-       if (height == 0)
-               height = pic->height;
-       mesh.texture = pic->tex;
-       mesh.numtriangles = 2;
-       mesh.numvertices = 4;
-       mesh.indices = picelements;
-       mesh.vertex3f = floats;
-       mesh.texcoord2f = floats + 16;
-       mesh.color4f = floats + 32;
-       memset(floats, 0, sizeof(floats));
-       mesh.vertex3f[0] = mesh.vertex3f[12] = x;
-       mesh.vertex3f[1] = mesh.vertex3f[5] = y;
-       mesh.vertex3f[4] = mesh.vertex3f[8] = x + width;
-       mesh.vertex3f[9] = mesh.vertex3f[13] = y + height;
-       mesh.texcoord2f[4] = mesh.texcoord2f[8] = mesh.texcoord2f[9] = mesh.texcoord2f[13] = 1;
-       mesh.color4f[0] = mesh.color4f[4] = mesh.color4f[8] = mesh.color4f[12] = red;
-       mesh.color4f[1] = mesh.color4f[5] = mesh.color4f[9] = mesh.color4f[13] = green;
-       mesh.color4f[2] = mesh.color4f[6] = mesh.color4f[10] = mesh.color4f[14] = blue;
-       mesh.color4f[3] = mesh.color4f[7] = mesh.color4f[11] = mesh.color4f[15] = alpha;
-       DrawQ_Mesh (&mesh, flags);
-#else
-       int size;
-       drawqueue_t *dq;
-       if (alpha < (1.0f / 255.0f) || !picname || !picname[0])
-               return;
-       size = sizeof(*dq) + ((strlen(picname) + 1 + 3) & ~3);
-       if (r_refdef.drawqueuesize + size > r_refdef.maxdrawqueuesize)
-               return;
-       red = bound(0, red, 1);
-       green = bound(0, green, 1);
-       blue = bound(0, blue, 1);
-       alpha = bound(0, alpha, 1);
-       dq = (void *)(r_refdef.drawqueue + r_refdef.drawqueuesize);
-       dq->size = size;
-       dq->command = DRAWQUEUE_PIC;
-       dq->flags = flags;
-       dq->color = ((unsigned int) (red * 255.0f) << 24) | ((unsigned int) (green * 255.0f) << 16) | ((unsigned int) (blue * 255.0f) << 8) | ((unsigned int) (alpha * 255.0f));
-       dq->x = x;
-       dq->y = y;
-       // if these are not zero, they override the pic's size
-       dq->scalex = width;
-       dq->scaley = height;
-       strcpy((char *)(dq + 1), picname);
-       r_refdef.drawqueuesize += dq->size;
-#endif
 }
 
 void DrawQ_String(float x, float y, const char *string, int maxlen, float scalex, float scaley, float red, float green, float blue, float alpha, int flags)
@@ -595,55 +545,7 @@ void DrawQ_String(float x, float y, const char *string, int maxlen, float scalex
 
 void DrawQ_Fill (float x, float y, float w, float h, float red, float green, float blue, float alpha, int flags)
 {
-#if 1
        DrawQ_SuperPic(x,y,NULL,w,h,0,0,red,green,blue,alpha,1,0,red,green,blue,alpha,0,1,red,green,blue,alpha,1,1,red,green,blue,alpha,flags);
-#elif 1
-       float floats[48];
-       drawqueuemesh_t mesh;
-       if (alpha < (1.0f / 255.0f))
-               return;
-       mesh.texture = NULL;
-       mesh.numtriangles = 2;
-       mesh.numvertices = 4;
-       mesh.indices = picelements;
-       mesh.vertex3f = floats;
-       mesh.texcoord2f = floats + 16;
-       mesh.color4f = floats + 32;
-       memset(floats, 0, sizeof(floats));
-       mesh.vertex3f[0] = mesh.vertex3f[12] = x;
-       mesh.vertex3f[1] = mesh.vertex3f[5] = y;
-       mesh.vertex3f[4] = mesh.vertex3f[8] = x + w;
-       mesh.vertex3f[9] = mesh.vertex3f[13] = y + h;
-       mesh.color4f[0] = mesh.color4f[4] = mesh.color4f[8] = mesh.color4f[12] = red;
-       mesh.color4f[1] = mesh.color4f[5] = mesh.color4f[9] = mesh.color4f[13] = green;
-       mesh.color4f[2] = mesh.color4f[6] = mesh.color4f[10] = mesh.color4f[14] = blue;
-       mesh.color4f[3] = mesh.color4f[7] = mesh.color4f[11] = mesh.color4f[15] = alpha;
-       DrawQ_Mesh (&mesh, flags);
-#else
-       int size;
-       drawqueue_t *dq;
-       if (alpha < (1.0f / 255.0f))
-               return;
-       size = sizeof(*dq) + 4;
-       if (r_refdef.drawqueuesize + size > r_refdef.maxdrawqueuesize)
-               return;
-       red = bound(0, red, 1);
-       green = bound(0, green, 1);
-       blue = bound(0, blue, 1);
-       alpha = bound(0, alpha, 1);
-       dq = (void *)(r_refdef.drawqueue + r_refdef.drawqueuesize);
-       dq->size = size;
-       dq->command = DRAWQUEUE_PIC;
-       dq->flags = flags;
-       dq->color = ((unsigned int) (red * 255.0f) << 24) | ((unsigned int) (green * 255.0f) << 16) | ((unsigned int) (blue * 255.0f) << 8) | ((unsigned int) (alpha * 255.0f));
-       dq->x = x;
-       dq->y = y;
-       dq->scalex = w;
-       dq->scaley = h;
-       // empty pic name
-       *((char *)(dq + 1)) = 0;
-       r_refdef.drawqueuesize += dq->size;
-#endif
 }
 
 void DrawQ_SuperPic(float x, float y, char *picname, float width, float height, float s1, float t1, float r1, float g1, float b1, float a1, float s2, float t2, float r2, float g2, float b2, float a2, float s3, float t3, float r3, float g3, float b3, float a3, float s4, float t4, float r4, float g4, float b4, float a4, int flags)
@@ -796,7 +698,7 @@ static void SCR_CalcRefdef (void)
        if (cl.worldmodel)
        {
                Mod_CheckLoaded(cl.worldmodel);
-               contents = Mod_PointContents(r_refdef.vieworg, cl.worldmodel);
+               contents = CL_PointContents(r_refdef.vieworg);
                if (contents != CONTENTS_EMPTY && contents != CONTENTS_SOLID)
                {
                        r_refdef.fov_x *= (sin(cl.time * 4.7) * 0.015 + 0.985);
@@ -848,8 +750,14 @@ static int cl_avidemo_frame = 0;
 void SCR_CaptureAVIDemo(void)
 {
        char filename[32];
-       sprintf(filename, "dpavi%06d.tga", cl_avidemo_frame);
-       if (SCR_ScreenShot(filename, vid.realx, vid.realy, vid.realwidth, vid.realheight, false))
+       qboolean jpeg = (scr_screenshot_jpeg.integer != 0);
+
+       if (jpeg)
+               sprintf(filename, "dpavi%06d.jpg", cl_avidemo_frame);
+       else
+               sprintf(filename, "dpavi%06d.tga", cl_avidemo_frame);
+
+       if (SCR_ScreenShot(filename, vid.realx, vid.realy, vid.realwidth, vid.realheight, jpeg))
                cl_avidemo_frame++;
        else
        {
@@ -1064,9 +972,6 @@ void CL_UpdateScreen(void)
 
        DrawQ_Clear();
 
-       V_UpdateBlends();
-       V_CalcRefdef ();
-
        if (cls.signon == SIGNONS)
                R_TimeReport("setup");