]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
use skinframes for R_BeginPolygon; helps with csqc 3D polygon rendering (e.g. mipmapp...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 4 Oct 2008 14:01:05 +0000 (14:01 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 4 Oct 2008 14:01:05 +0000 (14:01 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8520 d7cf8633-e32d-0410-b094-e92efae38249

clvm_cmds.c
draw.h

index d9fc74bfedbada16f086765b12bd1b3a4cde327d..d3da4299bbd788b2705db84ab8d2685e7efae2d7 100644 (file)
@@ -2574,7 +2574,13 @@ void VM_CL_AddPolygonsToMeshQueue (void)
 void VM_CL_R_PolygonBegin (void)
 {
        const char              *picname;
+       skinframe_t     *sf;
        vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
+       int tf;
+
+       // TODO instead of using skinframes here (which provides the benefit of
+       // better management of flags, and is more suited for 3D rendering), what
+       // about supporting Q3 shaders?
 
        VM_SAFEPARMCOUNT(2, VM_CL_R_PolygonBegin);
 
@@ -2586,8 +2592,29 @@ void VM_CL_R_PolygonBegin (void)
                return;
        }
        picname = PRVM_G_STRING(OFS_PARM0);
-       polys->begin_texture = picname[0] ? Draw_CachePic_Flags (picname, CACHEPICFLAG_NOCLAMP)->tex : r_texture_white;
-       polys->begin_drawflag = (int)PRVM_G_FLOAT(OFS_PARM1);
+
+       sf = NULL;
+       if(*picname)
+       {
+               tf = TEXF_ALPHA;
+               if((int)PRVM_G_FLOAT(OFS_PARM1) & DRAWFLAG_MIPMAP)
+                       tf |= TEXF_MIPMAP;
+
+               do
+               {
+                       sf = R_SkinFrame_FindNextByName(sf, picname);
+               }
+               while(sf && sf->textureflags != tf);
+
+               if(!sf || !sf->base)
+                       sf = R_SkinFrame_LoadExternal(picname, tf, true);
+
+               if(sf)
+                       R_SkinFrame_MarkUsed(sf);
+       }
+
+       polys->begin_texture = (sf && sf->base) ? sf->base : r_texture_white;
+       polys->begin_drawflag = (int)PRVM_G_FLOAT(OFS_PARM1) & DRAWFLAG_MASK;
        polys->begin_vertices = 0;
        polys->begin_active = true;
 }
diff --git a/draw.h b/draw.h
index 8646c6a30155cbad56350c70aca8e4354a5df1cc..c9c8b745b949d7369b3933a70cff34c0a6e17cd8 100644 (file)
--- a/draw.h
+++ b/draw.h
@@ -76,7 +76,9 @@ DRAWFLAG_NORMAL,
 DRAWFLAG_ADDITIVE,
 DRAWFLAG_MODULATE,
 DRAWFLAG_2XMODULATE,
-DRAWFLAG_NUMFLAGS
+DRAWFLAG_NUMFLAGS,
+DRAWFLAG_MASK = 0xFF,   // ONLY R_BeginPolygon()
+DRAWFLAG_MIPMAP = 0x100 // ONLY R_BeginPolygon()
 };
 
 typedef struct dp_font_s