]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_video.c
BuildTriangleNeighbors now detects edges shared by three triangles, fixes weird shado...
[xonotic/darkplaces.git] / cl_video.c
index fd4c7071e8028cf3e5ff5e09f8b9fbf18f678a29..4778c8189c4b57aed1c80c513ba8d7396185f03e 100644 (file)
@@ -56,10 +56,10 @@ void CL_VideoFrame(void)
        }
        if (cl_videosoundrate && (samples = S_RawSamples_QueueWantsMore()))
        {
-               Con_Printf("%i = S_RawSamples_QueueWantsMore()\n", samples);
+               Con_DPrintf("%i = S_RawSamples_QueueWantsMore()\n", samples);
 
                // calculate how much source data we need to fill the output...
-               s = samples * cl_videosoundrate / shm->speed;
+               s = samples * cl_videosoundrate / S_RawSamples_SampleRate();
 
                // reallocate processing buffer if needed
                if (cl_videosoundresamplelength < samples)
@@ -91,9 +91,9 @@ void CL_DrawVideo(void)
        {
                drawqueuemesh_t mesh;
                int indices[6];
-               float vertices[12];
+               float vertices[16];
                float texcoords[8];
-               qbyte colorsb[16];
+               float colorsf[16];
                float s1, t1, s2, t2, x1, y1, x2, y2;
                indices[0] = 0;
                indices[1] = 1;
@@ -105,50 +105,23 @@ void CL_DrawVideo(void)
                y1 = 0;
                x2 = vid.conwidth;
                y2 = vid.conheight;
-               vertices[0] = y1;
-               vertices[1] = y1;
-               vertices[2] = 0;
-               vertices[3] = x2;
-               vertices[4] = y1;
-               vertices[5] = 0;
-               vertices[6] = x2;
-               vertices[7] = y2;
-               vertices[8] = 0;
-               vertices[9] = x1;
-               vertices[10] = y2;
-               vertices[11] = 0;
                R_FragmentLocation(cl_videotexture, NULL, NULL, &s1, &t1, &s2, &t2);
-               texcoords[0] = s1;
-               texcoords[1] = t1;
-               texcoords[2] = s2;
-               texcoords[3] = t1;
-               texcoords[4] = s2;
-               texcoords[5] = t2;
-               texcoords[6] = s1;
-               texcoords[7] = t2;
-               colorsb[0] = 255 >> v_overbrightbits.integer;
-               colorsb[1] = 255 >> v_overbrightbits.integer;
-               colorsb[2] = 255 >> v_overbrightbits.integer;
-               colorsb[3] = 255;
-               colorsb[4] = 255 >> v_overbrightbits.integer;
-               colorsb[5] = 255 >> v_overbrightbits.integer;
-               colorsb[6] = 255 >> v_overbrightbits.integer;
-               colorsb[7] = 255;
-               colorsb[8] = 255 >> v_overbrightbits.integer;
-               colorsb[9] = 255 >> v_overbrightbits.integer;
-               colorsb[10] = 255 >> v_overbrightbits.integer;
-               colorsb[11] = 255;
-               colorsb[12] = 255 >> v_overbrightbits.integer;
-               colorsb[13] = 255 >> v_overbrightbits.integer;
-               colorsb[14] = 255 >> v_overbrightbits.integer;
-               colorsb[15] = 255;
+               texcoords[0] = s1;texcoords[1] = t1;
+               texcoords[2] = s2;texcoords[3] = t1;
+               texcoords[4] = s2;texcoords[5] = t2;
+               texcoords[6] = s1;texcoords[7] = t2;
+               R_FillColors(colorsf, 4, r_colorscale, r_colorscale, r_colorscale, 1);
+               vertices[ 0] = x1;vertices[ 1] = y1;vertices[ 2] = 0;vertices[ 3] = 0;
+               vertices[ 4] = x2;vertices[ 5] = y1;vertices[ 6] = 0;vertices[ 7] = 0;
+               vertices[ 8] = x2;vertices[ 9] = y2;vertices[10] = 0;vertices[11] = 0;
+               vertices[12] = x1;vertices[13] = y2;vertices[14] = 0;vertices[15] = 0;
                mesh.texture = cl_videotexture;
-               mesh.numindices = 6;
+               mesh.numtriangles = 2;
                mesh.numvertices = 4;
                mesh.indices = indices;
                mesh.vertices = vertices;
                mesh.texcoords = texcoords;
-               mesh.colors = colorsb;
+               mesh.colors = colorsf;
                DrawQ_Mesh(&mesh, 0);
                //DrawQ_Pic(0, 0, "engine_videoframe", vid.conwidth, vid.conheight, 1, 1, 1, 1, 0);
        }
@@ -186,13 +159,15 @@ void CL_VideoStart(char *filename)
        cl_videosoundresampledata = NULL;
 
        cl_videotexturepool = R_AllocTexturePool();
-       cl_videotexture = R_LoadTexture(cl_videotexturepool, "videotexture", cl_videoimagewidth, cl_videoimageheight, NULL, TEXTYPE_RGBA, 0);
+       cl_videotexture = R_LoadTexture2D(cl_videotexturepool, "videotexture", cl_videoimagewidth, cl_videoimageheight, NULL, TEXTYPE_RGBA, TEXF_FRAGMENT, NULL);
 }
 
 void CL_VideoStop(void)
 {
        cl_videoplaying = false;
 
+       S_RawSamples_ClearQueue();
+
        if (cl_videostream)
                dpvsimpledecode_close(cl_videostream);
        cl_videostream = NULL;