+
+ // determine if vertex alpha is being used so we can provide that hint to GetTexture...
+ hascolor = false;
+ hasalpha = false;
+ for (i = 0; i < prog->polygonbegin_numvertices; i++)
+ {
+ o = prog->polygonbegin_vertexdata + 10 * i;
+ if (o[6] != 1.0f || o[7] != 1.0f || o[8] != 1.0f)
+ hascolor = true;
+ if (o[9] != 1.0f)
+ hasalpha = true;
+ }
+
+ // create the surface, looking up the best matching texture/shader
+ materialflags = MATERIALFLAG_WALL;
+ if (csqc_polygons_defaultmaterial_nocullface.integer)
+ materialflags |= MATERIALFLAG_NOCULLFACE;
+ if (hascolor)
+ materialflags |= MATERIALFLAG_VERTEXCOLOR;
+ if (hasalpha)
+ materialflags |= MATERIALFLAG_ALPHAGEN_VERTEX | MATERIALFLAG_ALPHA | MATERIALFLAG_BLENDED | MATERIALFLAG_NOSHADOW;
+ tex = Mod_Mesh_GetTexture(mod, prog->polygonbegin_texname, prog->polygonbegin_drawflags, TEXF_ALPHA, materialflags);
+ surf = Mod_Mesh_AddSurface(mod, tex, false);
+ // create triangle fan
+ for (i = 0; i < prog->polygonbegin_numvertices; i++)
+ {
+ o = prog->polygonbegin_vertexdata + 10 * i;
+ e2 = Mod_Mesh_IndexForVertex(mod, surf, o[0], o[1], o[2], 0, 0, 0, o[3], o[4], 0, 0, o[6], o[7], o[8], o[9]);
+ if (i >= 2)
+ Mod_Mesh_AddTriangle(mod, surf, e0, e1, e2);
+ else if (i == 0)
+ e0 = e2;
+ e1 = e2;
+ }
+ // build normals (since they are not provided)