+ if (width == 0)
+ width = pic->width;
+ if (height == 0)
+ height = pic->height;
+ m.tex[0] = R_GetTexture(pic->tex);
+ m.pointer_texcoord[0] = floats + 12;
+ floats[12] = s1;floats[13] = t1;
+ floats[14] = s2;floats[15] = t2;
+ floats[16] = s4;floats[17] = t4;
+ floats[18] = s3;floats[19] = t3;
+ }
+ R_Mesh_State(&m);
+
+ floats[2] = floats[5] = floats[8] = floats[11] = 0;
+ floats[0] = floats[9] = x;
+ floats[1] = floats[4] = y;
+ floats[3] = floats[6] = x + width;
+ floats[7] = floats[10] = y + height;
+ floats[20] = r1;floats[21] = g1;floats[22] = b1;floats[23] = a1;
+ floats[24] = r2;floats[25] = g2;floats[26] = b2;floats[27] = a2;
+ floats[28] = r4;floats[29] = g4;floats[30] = b4;floats[31] = a4;
+ floats[32] = r3;floats[33] = g3;floats[34] = b3;floats[35] = a3;
+
+ R_Mesh_Draw(0, 4, 2, polygonelements);
+}
+
+void DrawQ_Mesh (drawqueuemesh_t *mesh, int flags)
+{
+ rmeshstate_t m;
+
+ if (!r_refdef.draw2dstage)
+ {
+ Con_Printf("DrawQ_Mesh: not in 2d rendering stage!\n");
+ return;
+ }
+
+ 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);
+
+ memset(&m, 0, sizeof(m));
+ m.pointer_vertex = mesh->data_vertex3f;
+ m.pointer_color = mesh->data_color4f;
+ m.tex[0] = R_GetTexture(mesh->texture);
+ if (m.tex[0])
+ m.pointer_texcoord[0] = mesh->data_texcoord2f;
+ R_Mesh_State(&m);
+
+ GL_LockArrays(0, mesh->num_vertices);
+ R_Mesh_Draw(0, mesh->num_vertices, mesh->num_triangles, mesh->data_element3i);
+ GL_LockArrays(0, 0);
+}
+
+void DrawQ_LineLoop (drawqueuemesh_t *mesh, int flags)
+{
+ int num;
+
+ if (!r_refdef.draw2dstage)
+ {
+ Con_Printf("DrawQ_LineLoop: not in 2d rendering stage!\n");
+ return;
+ }
+
+ 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);
+
+ GL_Color(1,1,1,1);
+ qglBegin(GL_LINE_LOOP);
+ for (num = 0;num < mesh->num_vertices;num++)
+ {
+ if (mesh->data_color4f)
+ GL_Color(mesh->data_color4f[num*4+0], mesh->data_color4f[num*4+1], mesh->data_color4f[num*4+2], mesh->data_color4f[num*4+3]);
+ qglVertex2f(mesh->data_vertex3f[num*3+0], mesh->data_vertex3f[num*3+1]);
+ }
+ qglEnd();
+}
+
+//LordHavoc: FIXME: this is nasty!
+void DrawQ_LineWidth (float width)
+{
+ if (!r_refdef.draw2dstage)
+ {
+ Con_Printf("DrawQ_LineWidth: not in 2d rendering stage!\n");
+ return;
+ }
+ qglLineWidth(width);
+}
+
+//[515]: this is old, delete
+void DrawQ_Line (float width, float x1, float y1, float x2, float y2, float r, float g, float b, float alpha, int flags)
+{
+ if (!r_refdef.draw2dstage)
+ {
+ Con_Printf("DrawQ_Line: not in 2d rendering stage!\n");
+ return;
+ }
+
+ if (!r_render.integer)
+ return;
+
+ 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);
+
+ GL_Color(r,g,b,alpha);
+ qglBegin(GL_LINES);
+ qglVertex2f(x1, y1);
+ qglVertex2f(x2, y2);
+ qglEnd();
+}
+
+void DrawQ_SetClipArea(float x, float y, float width, float height)
+{
+ if (!r_refdef.draw2dstage)
+ {
+ Con_Printf("DrawQ_SetClipArea: not in 2d rendering stage!\n");
+ return;
+ }
+
+ // We have to convert the con coords into real coords
+ // OGL uses top to bottom
+ GL_Scissor((int)(x * ((float)vid.width / vid_conwidth.integer)), (int)(y * ((float) vid.height / vid_conheight.integer)), (int)(width * ((float)vid.width / vid_conwidth.integer)), (int)(height * ((float)vid.height / vid_conheight.integer)));
+
+ GL_ScissorTest(true);
+}
+
+void DrawQ_ResetClipArea(void)
+{
+ if (!r_refdef.draw2dstage)
+ {
+ Con_Printf("DrawQ_ResetClipArea: not in 2d rendering stage!\n");
+ return;
+ }
+ GL_ScissorTest(false);
+}
+
+void DrawQ_Finish(void)
+{
+ if (!r_refdef.draw2dstage)
+ {
+ Con_Printf("R_DrawQueue: not in 2d rendering stage!\n");
+ return;
+ }
+
+ r_refdef.draw2dstage = false;
+}
+
+static float blendvertex3f[9] = {-5000, -5000, 10, 10000, -5000, 10, -5000, 10000, 10};
+void R_DrawGamma(void)
+{
+ rmeshstate_t m;
+ float c[4];
+ if (!vid_usinghwgamma)
+ {
+ // all the blends ignore depth
+ memset(&m, 0, sizeof(m));
+ m.pointer_vertex = blendvertex3f;
+ R_Mesh_State(&m);
+ GL_DepthMask(true);
+ GL_DepthTest(false);
+ if (v_color_enable.integer)