]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
add menu QC drawsubpic() to draw just part of an image; revert change to DrawQ_SuperPic
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 27 Oct 2007 12:40:28 +0000 (12:40 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 27 Oct 2007 12:40:28 +0000 (12:40 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7655 d7cf8633-e32d-0410-b094-e92efae38249

clvm_cmds.c
gl_draw.c
mvm_cmds.c
prvm_cmds.c
prvm_cmds.h

index 68b8ecc20ed0f8aabc138a0e527478e44f92ca3e..5547057df3f3a5e42246291ae02c928728cfdb87 100644 (file)
@@ -3077,7 +3077,7 @@ VM_drawsetcliparea,                               // #324 void(float x, float y, float width, float height)
 VM_drawresetcliparea,                  // #325 void(void) drawresetcliparea
 VM_drawcolorcodedstring,               // #326 float drawcolorcodedstring(vector position, string text, vector scale, vector rgb, float alpha, float flag) (EXT_CSQC)
 NULL,                                                  // #327 // FIXME add stringwidth() here?
-NULL,                                                  // #328
+NULL,                                                  // #328 // FIXME add drawsubpic() here?
 NULL,                                                  // #329
 VM_CL_getstatf,                                        // #330 float(float stnum) getstatf (EXT_CSQC)
 VM_CL_getstati,                                        // #331 float(float stnum) getstati (EXT_CSQC)
index 6eb9378fab042c45f1be0fe5c0f0bda3e7c71c92..2f01464dbeeb48f7bcca3f0d76cabafad61a7db6 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -852,17 +852,10 @@ void DrawQ_SuperPic(float x, float y, cachepic_t *pic, float width, float height
                        height = pic->height;
                R_Mesh_TexBind(0, R_GetTexture(pic->tex));
                R_Mesh_TexCoordPointer(0, 2, floats + 12, 0, 0);
-
-      // AK07: lets be texel correct on the corners
-      {
-         float horz_offset = 0.5f / pic->width;
-         float vert_offset = 0.5f / pic->height;
-
-         floats[12] = s1 + horz_offset;floats[13] = t1 + vert_offset;
-         floats[14] = s2 - horz_offset;floats[15] = t2 + vert_offset;
-         floats[16] = s4 - horz_offset;floats[17] = t4 - vert_offset;
-         floats[18] = s3 + horz_offset;floats[19] = t3 - vert_offset;
-      }
+               floats[12] = s1;floats[13] = t1;
+               floats[14] = s2;floats[15] = t2;
+               floats[16] = s4;floats[17] = t4;
+               floats[18] = s3;floats[19] = t3;
        }
 
        floats[2] = floats[5] = floats[8] = floats[11] = 0;
index dddf5a184663940c1b10a8e8086655013d5d28a8..0c68542fb0e87eec680fbc76acf8d0e5ea38ae37 100644 (file)
@@ -1229,7 +1229,7 @@ VM_cin_restart,                   // #465
 VM_drawline,                           // #466
 VM_drawcolorcodedstring,       // #467
 VM_stringwidth,                                // #468
-NULL,                                          // #469
+VM_drawsubpic,                 // #469
 NULL,                                          // #470
 VM_asin,                                       // #471 float(float s) VM_asin (DP_QC_ASINACOSATANATAN2TAN)
 VM_acos,                                       // #472 float(float c) VM_acos (DP_QC_ASINACOSATANATAN2TAN)
index 1c7f42330487338afd692bd696363af5b07d9011..57f192b39212fbefd1994a514b815cbf80c4b104 100644 (file)
@@ -2789,6 +2789,60 @@ void VM_drawpic(void)
        DrawQ_Pic(pos[0], pos[1], Draw_CachePic(picname, true), size[0], size[1], rgb[0], rgb[1], rgb[2], PRVM_G_FLOAT(OFS_PARM4), flag);
        PRVM_G_FLOAT(OFS_RETURN) = 1;
 }
+/*
+=========
+VM_drawsubpic
+
+float  drawsubpic(vector position, vector size, string pic, vector srcPos, vector srcSize, vector rgb, float alpha, float flag)
+
+=========
+*/
+void VM_drawsubpic(void)
+{
+       const char *picname;
+       float *size, *pos, *rgb, *srcPos, *srcSize, alpha;
+       int flag;
+
+       VM_SAFEPARMCOUNT(8,VM_drawsubpic);
+
+       picname = PRVM_G_STRING(OFS_PARM2);
+       VM_CheckEmptyString (picname);
+
+       // is pic cached ? no function yet for that
+       if(!1)
+       {
+               PRVM_G_FLOAT(OFS_RETURN) = -4;
+               VM_Warning("VM_drawsubpic: %s: %s not cached !\n", PRVM_NAME, picname);
+               return;
+       }
+
+       pos = PRVM_G_VECTOR(OFS_PARM0);
+       size = PRVM_G_VECTOR(OFS_PARM1);
+       srcPos = PRVM_G_VECTOR(OFS_PARM3);
+       srcSize = PRVM_G_VECTOR(OFS_PARM4);
+       rgb = PRVM_G_VECTOR(OFS_PARM5);
+       alpha = PRVM_G_FLOAT(OFS_PARM6);
+       flag = (int) PRVM_G_FLOAT(OFS_PARM7);
+
+       if(flag < DRAWFLAG_NORMAL || flag >=DRAWFLAG_NUMFLAGS)
+       {
+               PRVM_G_FLOAT(OFS_RETURN) = -2;
+               VM_Warning("VM_drawsubpic: %s: wrong DRAWFLAG %i !\n",PRVM_NAME,flag);
+               return;
+       }
+
+       if(pos[2] || size[2])
+               Con_Printf("VM_drawsubpic: z value%s from %s discarded\n",(pos[2] && size[2]) ? "s" : " ",((pos[2] && size[2]) ? "pos and size" : (pos[2] ? "pos" : "size")));
+
+       DrawQ_SuperPic(pos[0], pos[1], Draw_CachePic(picname, true),
+               size[0], size[1],
+               srcPos[0],              srcPos[1],              rgb[0], rgb[1], rgb[2], alpha,
+               srcPos[0] + srcSize[0], srcPos[1],              rgb[0], rgb[1], rgb[2], alpha,
+               srcPos[0],              srcPos[1] + srcSize[1], rgb[0], rgb[1], rgb[2], alpha,
+               srcPos[0] + srcSize[0], srcPos[1] + srcSize[1], rgb[0], rgb[1], rgb[2], alpha,
+               flag);
+       PRVM_G_FLOAT(OFS_RETURN) = 1;
+}
 
 /*
 =========
index fb4837379c712f0cfb303977a48f3b7555026e57..8be51b6b47cf5807020ab5ba169041d9eb44e4e0 100644 (file)
@@ -137,6 +137,7 @@ float       drawstring(vector position, string text, vector scale, vector rgb, float a
 float  drawcolorcodedstring(vector position, string text, vector scale, float alpha, float flag)
 float  stringwidth(string text, float handleColors)
 float  drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag)
+float  drawsubpic(vector position, vector size, string pic, vector srcPos, vector srcSize, vector rgb, float alpha, float flag)
 float  drawfill(vector position, vector size, vector rgb, float alpha, float flag)
                drawsetcliparea(float x, float y, float width, float height)
                drawresetcliparea()
@@ -328,6 +329,7 @@ void VM_drawstring(void);
 void VM_drawcolorcodedstring(void);
 void VM_stringwidth(void);
 void VM_drawpic(void);
+void VM_drawsubpic(void);
 void VM_drawfill(void);
 void VM_drawsetcliparea(void);
 void VM_drawresetcliparea(void);