While testing my curve functions I innially could not get why my curves drawed normally some times, but not others. I found out that a draw_circle was to blame, which I used to mark the points. When I start drawing a spline with draw_spline_begin() it just does:
And when I draw a circle or any other shape in between it will get points on that circle, and thus mess up my curve. This is exactly the same problem with the already implemented draw_primitive functions. Try something like this and see for yourself:
In GM it does allow things like this. The way it does this is that the _end function is the one that draws it. So I guess this is how I need to do it too? I already save points in an array, so I guess its not a problem, but still. There is some DEPTHBUFFER code already done in primitive functions and in thous it does save points as well. So drawing it in _end would be the best bet I guess.
Also, if I have to save points + colors + alphas in an array, then should I use something like this:http://www.fredosaurus.com/notes-cpp/newdelete/50dynamalloc.html
MAXPOINTS could be changed, or just be a large number by default.
I don't want to do that dynamic deleting and allocation because I would need to do this for every point... Or I could alloc, for example, 64 points at a time, and when I run out I alloc another 64. This wouldn't waste much memory and should be faster, but then again its another if cycle.
Also, I guess I should post these as tickets in the tracker, but I might as well put it here:
draw_merge doesn't work. I wasted about 40min trying to figure out why I can't blend my curve smoothly, and it ends up that the function doesn't return the right values. For example, merge_color(c_red,c_white,1), will return c_red even thou it needs to return c_white. Either way, this is how I fixed it:
int merge_color(int c1,int c2,double amount)
amount = amount > 1 ? 1 : (amount < 0 ? 0 : amount);
| (unsigned char)(fabs(__GETG(c1)+(__GETG(c2)-__GETG(c1))*amount))<<8
| (unsigned char)(fabs(__GETB(c1)+(__GETB(c2)-__GETB(c1))*amount))<<16;
I think fabs can be removed somehow.
Also, draw_get_color() (or anything draw_get for that matter) returns nan all the time.. I have this code:
pr_point_ar[i] = (pr_curve_color1 == -1 ? draw_get_color() : merge_color(pr_curve_color1,pr_curve_color2,1/(pr_spline_points+1)))
And it will return nan if pr_curve_color1 is -1 (so its calling merge_color). I just tested std::cout << merge_color(col1,col2,1) and got the same result. Couldn't find the reason thou... I looked in GScolors.cpp and everything seems fine.
edit: Anyway, as you can see this post started as a question, but by the second paragraph I realized how to fix this myself (by drawing in _end), so the first part can be ignored I guess.