DrawTriangle function
Monkey Forums/Monkey Programming/DrawTriangle function
| ||
Hi everyone I am aware of DrawPoly function which accepts a float[] but I would like to avoid creating a float[] instance each time the function is called. My primary target is the Xbox at the moment so I really have to avoid creating garbage. As Floats and Ints are managed, it is not a problem to use them. With this in mind, I would like to use a function as follows.. [monkeycode]Function DrawTriangle:Void(X1#,Y1#,X2#,Y2#,X3#,Y3#) ' Basically the same as the draw poly code, but using floats not an array of floats End[/monkeycode] I'm not so sure how to implement such a thing though... I've found the XNA version of the DrawPoly function and edited a copy to create my DrawTriangle function... public virtual int DrawTriangle( float x1, float y1, float x2, float y2, float x3, float y3 ){ int n = 3; Flush(); primType=5; primSurf=null; float px; float py; px=x1; py=y1; if( tformed ){ float ppx=px; px=ppx * ix + py * jx + tx; py=ppx * iy + py * jy + ty; } vertices[0].Position.X=px;vertices[0].Position.Y=py; vertices[0].Color=color; px=x2; py=y2; if( tformed ){ float ppx=px; px=ppx * ix + py * jx + tx; py=ppx * iy + py * jy + ty; } vertices[1].Position.X=px;vertices[1].Position.Y=py; vertices[1].Color=color; px=x3; py=y3; if( tformed ){ float ppx=px; px=ppx * ix + py * jx + tx; py=ppx * iy + py * jy + ty; } vertices[2].Position.X=px;vertices[2].Position.Y=py; vertices[2].Color=color; primCount=n; Flush(); return 0; } But I am unsure as to how to make use of this function from within Monkey.. ? Is it easy to explain? Ta :) |
| ||
I did some digging and was surprised with how easy it was. I guess that's a testament to the way Monkey does things :) |