Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 730 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
draw_line vs. draw_quad for drawing filled quads #382963
09/14/11 15:29
09/14/11 15:29
Joined: Sep 2003
Posts: 303
Germany
Clemens Offline OP
Senior Member
Clemens  Offline OP
Senior Member

Joined: Sep 2003
Posts: 303
Germany
Just a short question with rather low priority:

It's easy to develope a function for drawing filled quads with draw_line (-> drawing many lines in a row).
Is there any good reason if this way is more useful for the programer (bmaps are not needed) not to go this way, but using instead draw_quad?

Last edited by Clemens; 09/14/11 15:30.
Re: draw_line vs. draw_quad for drawing filled quads [Re: Clemens] #382967
09/14/11 16:40
09/14/11 16:40
Joined: Feb 2011
Posts: 135
Myrkling Offline
Member
Myrkling  Offline
Member

Joined: Feb 2011
Posts: 135
Drawing quads with draw_quad is probably quite a bit faster than using draw_line for the same purpose.
draw_quad also makes rotating and scaling quads easier.

Re: draw_line vs. draw_quad for drawing filled quads [Re: Myrkling] #382984
09/14/11 20:03
09/14/11 20:03
Joined: Sep 2003
Posts: 303
Germany
Clemens Offline OP
Senior Member
Clemens  Offline OP
Senior Member

Joined: Sep 2003
Posts: 303
Germany
You think it's faster?

However, I had to realize that it's even simpler and more user friendly to write this function with draw_quad... wink

But if you would like continue to philosophize (like: what's faster?), feel free... I'm in 8)

Re: draw_line vs. draw_quad for drawing filled quads [Re: Clemens] #382985
09/14/11 20:13
09/14/11 20:13
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Why should it be faster to draw multiple lines instead of one single quad of the same size?!


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: draw_line vs. draw_quad for drawing filled quads [Re: Superku] #383006
09/14/11 22:38
09/14/11 22:38
Joined: Feb 2011
Posts: 135
Myrkling Offline
Member
Myrkling  Offline
Member

Joined: Feb 2011
Posts: 135
I can't tell you why exactly, for I don't know the implementation details of these functions.

However, you can run this little test to see the speed difference (it's pretty obvious in this case):
Code:
#include <acknex.h>

void main()
{
    wait(1);
        
    while (1)
    {
        int i;
        var draw_line_time, draw_quad_time;
        
        timer();
        
        draw_line(NULLVECTOR, NULL, 100);
    
        for (i = 0; i < screen_size.y; i++)
        {
            draw_line(vector(0, i, 0), COLOR_WHITE, 100);
            draw_line(vector(screen_size.x, i, 0), COLOR_WHITE, 100);
        }
        
        draw_line_time = timer();
        
        draw_quad(NULL, NULLVECTOR, NULL, screen_size, NULL, COLOR_WHITE, 100, 0);
        
        draw_quad_time = timer();
        
        DEBUG_VAR(draw_line_time, 10);
        DEBUG_VAR(draw_quad_time, 30);
        
        wait (1);
    }
}



Re: draw_line vs. draw_quad for drawing filled quads [Re: Myrkling] #383060
09/15/11 15:16
09/15/11 15:16
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
trying
Code:
#include <acknex.h>


void main()
{
	wait(1);
	
	int i;
	var draw_line_time1, draw_line_time2, draw_quad_time1, draw_quad_time2;
	while (1)
	{
		
		timer();
		
		//test1
		draw_line(NULLVECTOR, NULL, 100);
		
		for (i = 0; i < screen_size.y; i++)
		{
			draw_line(vector(0, i, 0), COLOR_WHITE, 100);
			draw_line(vector(screen_size.x, i, 0), COLOR_WHITE, 100);
		}
		
		draw_line_time1 = timer();
		
		//test2
		draw_quad(NULL, NULLVECTOR, NULL, screen_size, NULL, COLOR_WHITE, 100, 0);
		
		draw_quad_time1 = timer();
		
		//test3
		draw_quad(NULL, NULLVECTOR, NULL, screen_size, NULL, COLOR_WHITE, 100, 0);
		
		draw_quad_time2 = timer();
		
		//test4
		draw_line(NULLVECTOR, NULL, 100);
		
		for (i = 0; i < screen_size.y; i++)
		{
			draw_line(vector(0, i, 0), COLOR_WHITE, 100);
			draw_line(vector(screen_size.x, i, 0), COLOR_WHITE, 100);
		}
		
		draw_line_time2 = timer();
		
		DEBUG_VAR(draw_line_time1, 10);
		DEBUG_VAR(draw_quad_time1, 30);
		DEBUG_VAR(draw_line_time2, 50);
		DEBUG_VAR(draw_quad_time2, 70);
		
		wait (1);
	}
}

will give you an unexplainable result. changing the order you draw shows draw_line as being quicker

Re: draw_line vs. draw_quad for drawing filled quads [Re: MrGuest] #383098
09/15/11 20:41
09/15/11 20:41
Joined: Feb 2011
Posts: 135
Myrkling Offline
Member
Myrkling  Offline
Member

Joined: Feb 2011
Posts: 135
I can't confirm this.

For me draw_line is slower in both cases (measured time: approx. 7300µs each).
Noticeable is though, that the second draw_quad is faster than the first (first: ~20µs, second: ~10µs).

Maybe you've mistaken draw_line_time2 for draw_quad_time2?

Re: draw_line vs. draw_quad for drawing filled quads [Re: Myrkling] #383120
09/15/11 23:52
09/15/11 23:52
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
sorry, probably wasn't clear enough (or at all really), draw_quad is always quicker

performing a draw_line then draw_quad for some reason is quicker than draw_quad then draw_line (obviously there's no reason to just draw the same thing twice).

drawing 2 quad's the second is usually 1/10 of the speed of the first call

drawing 2 draw_lines the first is 100+ times SLOWER than draw_quad, the second call is then 10 times the speed of the first

Re: draw_line vs. draw_quad for drawing filled quads [Re: MrGuest] #383244
09/17/11 18:22
09/17/11 18:22
Joined: Feb 2011
Posts: 135
Myrkling Offline
Member
Myrkling  Offline
Member

Joined: Feb 2011
Posts: 135
Ahh, I see. I misunderstood you on that one.

Maybe there needs something to be initialized or reset when draw_line/draw_quad is called for the first time in a frame. This could explain why subsequent calls of these functions are faster.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1