Page 1 of 1

R_BeginPolygon stuff in darkplaces

Posted: Mon Feb 18, 2013 4:28 pm
by Nahuel
I've been experimenting with this extension in Darkplaces and it's great. My goal is to create a radar map in the HUD (like xonotic) but simplified, and with the zoom in option.Now, I have a couple of questions:

in "void(vector org, vector texcoords, vector rgb, float alpha) R_PolygonVertex"
What means exactly "org" and "textcoords"? under what parameters are based these vectors ? how could I draw a picture and increase a zoom value without this pucture increase in scale?.

in "void(string texturename, float flag, ...) R_BeginPolygon"

What means "float flag, ..." What parameters can be added to a picture with this function?

if someone could explain how these functions work exactly would be great :)

Re: R_BeginPolygon stuff in darkplaces

Posted: Mon Feb 18, 2013 6:31 pm
by Spike
org = 3d (world) coord.
texcoords = texture coordinates... positions on the texture to interpolate between? Should generally be between 0 and 1, but other values work too as it will wrap over the edges of the image.

the flag is mostly used for some nasty hack due to dp's inability to use shaders to exactly describe the blend modes etc.
I say mostly though. If you pass the value 4 for flags, then the 'org' is interpreted in screen space rather than world space (ie: scaled between 0 and the width/height parameters of your CSQC_UpdateView function), thus matching all the drawpic/drawstring/etc functions.


So:
BeginPolygon("texturename", 4);
PolygonVertex('0 0 0', '0 0', '1 1 1', 1);
PolygonVertex('1 0 0'*screenwidth, '1 0', '1 1 1', 1);
PolygonVertex(('1 0 0'*screenwidth) + ('0 1 0'*screenheight), '1 1', '1 1 1', 1);
PolygonVertex('0 1 0'*screenheight, '0 1', '1 1 1', 1);
EndPolygon();


sidenote: recent fteqcc builds support this syntax:
PolygonVertex([screenwidth, screenheight, 0], '1 1', '1 1 1', 1);
which you might find easier to use to specify vectors as it allows variables/function calls/formulas/etc for each component. Personally I find it quite handy for 2d stuff, but that might just be me.