Pages: 1 [2]
  Print  
Author Topic: Custom: Curve drawing functions (Bezier and Spline)  (Read 3273 times)
Offline (Unknown gender) TheExDeus
Reply #15 Posted on: December 04, 2010, 02:53:33 PM

Developer
Joined: Apr 2008
Posts: 1914

View Profile
As far as I know* vectors are better for inserting at the end and iterating trough.** Lists are better for inserting and deleting in the middle (or anywhere). So in my case I think vectors could be better.

*And I know little, as 2 days ago I didn't know that in C++ vectors were arrays.
** http://www.gamedev.net/community/forums/topic.asp?topic_id=211458
Logged
Offline (Unknown gender) luiscubal
Reply #16 Posted on: December 04, 2010, 03:23:49 PM
Member
Joined: Jun 2009
Posts: 452

View Profile Email
I was addressing Josh's concern of O(N) push complexity.
Logged
Offline (Unknown gender) TheExDeus
Reply #17 Posted on: December 04, 2010, 04:26:43 PM

Developer
Joined: Apr 2008
Posts: 1914

View Profile
Ou, ok. Thought that suggestion was pointed at me.

I released the current source. Added new functions and changed the _begin() spline functions to use stacks and vectors. The speed seems identical, but the memory usage could be down. Also now it allows nesting.
I added anti-aliasing function, which makes the splines look a lot better. Thou I have a decision on how to implement it. What I did for now is make curves totally independent from the rest of the system. So you can change color, alpha, aa, drawing mode etc. totally independent from other functions. And I am not sure if that is the best idea. For example, I could have aa code like this:
Code: (C) [Select]
void draw_set_antialiasing(bool enable, int qual)
{
    if (enable==1){
        glEnable(GL_LINE_SMOOTH);
        glHint(GL_LINE_SMOOTH_HINT, qual);
    }else{
        glDisable(GL_LINE_SMOOTH);
    }
}
But that will enable aa for every primitive (circles etc.). I ended up doing this:
Code: (C) [Select]
pr_curve_aa = enable;
pr_curve_aa_qual = qual;
With having this in every drawing function (which of course can slow down the function):
Code: (C) [Select]
    if (pr_curve_aa==1){
        glEnable(GL_LINE_SMOOTH);
        glHint(GL_LINE_SMOOTH_HINT, pr_curve_aa_qual);
    }else{
        glDisable(GL_LINE_SMOOTH);
    }
Of course it is needed only once per function call, and compared to all the trig going on just to draw thous splines and curves, I think this doesn't impact the speed at all. It just seems wrong..
And testing speed is extremely hard because FPS jumps like crazy. I think that number is updated several times too much. Maybe it should be updated once per second or once per half a second. Maybe its normal like this, but I never seen it jump like that in GM.
Logged
Offline (Male) RetroX
Reply #18 Posted on: December 04, 2010, 08:36:18 PM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
Why not let the GPU handle it and use transformation matrices?  Or do they not work that way?  I haven't gone too much into GL, so, I don't know how it's done.
« Last Edit: December 04, 2010, 08:38:12 PM by RetroX » Logged
My Box: Phenom II 3.4GHz X4 | ASUS ATI RadeonHD 5770, 1GB GDDR5 RAM | 1x4GB DDR3 SRAM | Arch Linux, x86_64 (Cube) / Windows 7 x64 (Blob)
Quote from: Fede-lasse
Why do all the pro-Microsoft people have troll avatars? :(
Offline (Male) Josh @ Dreamland
Reply #19 Posted on: December 04, 2010, 09:18:06 PM

Prince of all Goldfish
Developer
Location: Ohio, United States
Joined: Feb 2008
Posts: 2946

View Profile Email
HaRRi, I think if you're going to offer an AA function, it may as well be for all primitives. Let the user make the call to it before and after spline drawing, if they like.

Luis, using a list would increase RAM. It would save push_back for the duration of one frame, then one subtract each frame, but at the cost of another add-dereference from there on. It doesn't really seem worth it...
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) luiscubal
Reply #20 Posted on: December 04, 2010, 10:03:17 PM
Member
Joined: Jun 2009
Posts: 452

View Profile Email
There's also the option of using bezier_reserve() to set vector capacity if the extra performance is that much needed.
That said, it's probably not worth it.
Logged
Pages: 1 [2]
  Print