]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - r_crosshairs.c
added GL_AlphaTest function to enable/disable GL_ALPHA_TEST
[xonotic/darkplaces.git] / r_crosshairs.c
index 4ec42f3b8366942734d0745faa90947f82ee7e53..e0fd5b2af61b65bf08af9d3da4ffa09e355b7be0 100644 (file)
@@ -9,9 +9,6 @@ cvar_t crosshair_flashrange = {CVAR_SAVE, "crosshair_flashrange", "0.1", "how mu
 cvar_t crosshair_size = {CVAR_SAVE, "crosshair_size", "1", "adjusts size of the crosshair on the screen"};
 cvar_t crosshair_static = {CVAR_SAVE, "crosshair_static", "1", "if 1 the crosshair is a 2D overlay, if 0 it is a sprite in the world indicating where your weapon will hit in standard quake mods (if the mod has the weapon somewhere else this won't be accurate)"};
 
-// must match NUMCROSSHAIRS in gl_draw.c
-#define NUMCROSSHAIRS 6
-
 void R_Crosshairs_Init(void)
 {
        Cvar_RegisterVariable(&crosshair_brightness);
@@ -70,22 +67,22 @@ void R_DrawWorldCrosshair(void)
        num = crosshair.integer;
        if (num < 1 || num > NUMCROSSHAIRS || cl.intermission)
                return;
-       if (!cl.viewentity || !cl_entities[cl.viewentity].state_current.active)
+       if (!cl.viewentity || !cl.entities[cl.viewentity].state_current.active)
                return;
-       pic = Draw_CachePic(va("gfx/crosshair%i", num), true);
+       pic = r_crosshairs[num];
        if (!pic)
                return;
        R_GetCrosshairColor(color);
 
        // trace the shot path up to a certain distance
-       Matrix4x4_OriginFromMatrix(&cl_entities[cl.viewentity].render.matrix, v1);
+       Matrix4x4_OriginFromMatrix(&cl.entities[cl.viewentity].render.matrix, v1);
        v1[2] += 16; // HACK: this depends on the QC
 
        // get the forward vector for the gun (not the view)
        AngleVectors(cl.viewangles, v2, NULL, NULL);
        //VectorCopy(r_vieworigin, v1);
        VectorMA(v1, 8192, v2, v2);
-       trace = CL_TraceBox(v1, vec3_origin, vec3_origin, v2, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_SKY, false);
+       trace = CL_TraceBox(v1, vec3_origin, vec3_origin, v2, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY | SUPERCONTENTS_SKY, false);
        spritescale = trace.fraction * (8192.0f / 40.0f) * crosshair_size.value;
        VectorCopy(trace.endpos, spriteorigin);
 
@@ -105,13 +102,13 @@ void R_Draw2DCrosshair(void)
        num = crosshair.integer;
        if (num < 1 || num > NUMCROSSHAIRS || cl.intermission)
                return;
-       if (!cl.viewentity || !cl_entities[cl.viewentity].state_current.active)
+       if (!cl.viewentity || !cl.entities[cl.viewentity].state_current.active)
                return;
-       pic = Draw_CachePic(va("gfx/crosshair%i", num), true);
+       pic = r_crosshairs[num];
        if (pic)
        {
                R_GetCrosshairColor(color);
-               DrawQ_Pic((vid_conwidth.integer - pic->width * crosshair_size.value) * 0.5f, (vid_conheight.integer - pic->height * crosshair_size.value) * 0.5f, pic->name, pic->width * crosshair_size.value, pic->height * crosshair_size.value, color[0], color[1], color[2], color[3], 0);
+               DrawQ_Pic((vid_conwidth.integer - pic->width * crosshair_size.value) * 0.5f, (vid_conheight.integer - pic->height * crosshair_size.value) * 0.5f, pic, pic->width * crosshair_size.value, pic->height * crosshair_size.value, color[0], color[1], color[2], color[3], 0);
        }
 }