PDA

View Full Version : Triangle



peter
23-07-2009, 18:34
Hi,

that is a test. it's no OpenGl.
how many seconds get you ?
i get six seconds.

Peter

Petr Schreiber
23-07-2009, 19:49
Hi Peter,

2 seconds on my PC.
I see it is not OpenGL, but why did you chose to use TBGL window ;)?

Friendly advice - Microsoft does not like combining GDI and OpenGL, I would recommend to not try these 2 together.
TBGL inits OpenGL after creation of window, so it is possible, mainly in next Windows releases, you would get into trouble.


Petr

peter
23-07-2009, 20:28
thank you Petr.
(Tbgl_ window) works well with my experiment.
i think , i will try it with OpenGL once.
i am surely not a big fan of OpenGl, more DirectX .
This experiment should be for Software rendering.
But 2 seconds with a modern computer are really to
slowly! i have to rethink !!

Peter

Petr Schreiber
23-07-2009, 21:27
Hi Peter,

I think the result is quite good - my PC is older architecture (just one core, how can I survive :)), and you also redraw immediately.

With double buffer, you can get nice speed even with software render:


uses "UI"

dim hWin as dword = Canvas_Window("Triangle test", 1, 1, 640, 480 )
Canvas_Attach(hWin, 0, %TRUE) ' <- double buffer

dim t1, t2 as quad
hiresTimer_Init
t1 = hiresTimer_Get
Canvas_Clear(%BLACK)
dim i as long
dim x, y as long
for i = 1 to 12000

x = rnd(1, 640)
y = rnd(1, 480)
RandomTriangle(x, y)

next

Canvas_redraw
t2 = hiresTimer_Get

msgbox hWin, "Time taken:"+FORMAT$((t2-t1)/1000000, "#.000")+" second", %MB_APPLMODAL

Canvas_Window end


SUB RandomTriangle( x as long, y as long )
' -- Random color
Canvas_Color( rgb(rnd(128, 255), rnd(128, 255), rnd(128, 255)))

Canvas_Line( (x-40, y), (x+40, y) )
Canvas_Line( (x-40, y), (x, y-40) )
Canvas_Line( (x+40, y), (x, y-40) )
END SUB



Petr

Lionheart008
23-07-2009, 21:37
hi peter,
hi petr :)

@peter: I have got for your 1200 triangles examples with my very old laptop in 5 seconds

@petr: the canvas example needs 0.562 seconds with my very old laptop

best regards, Lionheart

Petr Schreiber
23-07-2009, 21:39
Hi Frank,

do you think you could try to show LionGFX version?

Lionheart008
23-07-2009, 22:04
:D

yes, of course ! I have time and push it here.. I am using your canvas script, haven't done a complete new example, so you can better compare the results.. test it please with your machine again.. my notebook can't give serious results ;)



uses "liongfx","console"

liongfx_screen 16,32

liongfx_windowtitle "liongfx lines speed test one, 'no screenlock' :-) "

dim t1, t2 as quad
hiresTimer_Init
t1 = hiresTimer_Get

dim i as long
dim x, y as long

liongfx_screensync
'liongfx_screenlock

for i = 1 to 12000

x = rnd(1, 640)
y = rnd(1, 480)

RandomTriangle(x, y)
next

t2 = hiresTimer_Get


SUB RandomTriangle( x as long, y as long )

liongfx_Color liongfx_rgb,rnd(128, 255), rnd(128, 255), rnd(128, 255)

liongfx_Line x-40, y, x+40, y, 255,100,0, 12, 1
liongfx_Line x-40, y, x, y-40, 55,100,260, 8, 1
liongfx_Line x+40, y, x, y-40, 155,128,160, 24, 1
'liongfx_Circle x-10, y-10, 24,liongfx_RGB, 100, rnd(255)

END SUB
'liongfx_screenunlock

liongfx_getkey

msgbox 0, "liongfx time taken:"+FORMAT$((t2-t1)/1000000, "#.000")+" second"


I have further pushed some circles for the test... and my advice "push a key" after building the scene so you can get the result by message box ;) it's faster than peter's triangle script but not as fast as petr canvas script, so I am thinking...

! updated the zip file at 22:51 pm, best regards, good evening, Lionheart
ps: this exercise makes fun ! :dog24:

Petr Schreiber
23-07-2009, 22:21
Hi Frank,

it seems your code does draw squares (BF = box filled?) instead of rectangles.

Is there any way to make liongfx_Line command draw a line from x1,y1 to x2,y2 ?


Thanks

peter
23-07-2009, 22:47
Hi,

both scripts are very fast !
i have again hope !

Peter

Lionheart008
23-07-2009, 22:53
hi peter, hi petr...

I have modified my script :)

a) one script with "screenlock" - it's faster !
b) the other one without "screenlock" - it's not bad ;)


Is there any way to make liongfx_Line command draw a line from x1,y1 to x2,y2 ?

@petr: yes, I can do build simple lines, I have three ways to create lines as rectangles or rectangle filled (BF) or simple lines with or without colour you can see in next example. I have used for the speed example normal rectangles (does it mean: with no filling) ;)
btw: liongfx_line and liongfx_lines support me with these power !


uses "liongfx"

DIM t AS DOUBLE
dim bf as long


liongfx_SCREEN 14, 1
liongfx_print "hello simple lines"

liongfx_LINES 20, 20, 300, 180, 4

liongfx_LINE 140, 80, 180, 120, 255,100, 12, 8

liongfx_LINE 160, 10, 280, 80, 55,150, 100,6

liongfx_LINE 60, 60, 320, 200, 255,150, 24,11

liongfx_sleep 5000
liongfx_getkey

add the update file into my last post !

cheerio, lionheart