Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Line drawing algorithm slow.

Author
Message
Hatsu
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location:
Posted: 31st Dec 2005 18:53
I want to draw roughly 5000 lines on the screen per frame maximum. Each line is 10p long. So maximum 50000p have to be calculated. This shouldn't be that much right comapred to a full screen in 3d game, right? However my framrate falls down to 4fps per second. Is there something I'm missing here?
Cash Curtis II
20
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 31st Dec 2005 19:46
Why are you doing that? Maybe there's a better way to accomplish what you're trying to do.

Lost in Thought
21
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 31st Dec 2005 19:57
Yeah there has to be a better way than drawing 5000 lines each loop. You may want to check into memblocks.

Grog Grueslayer
Valued Member
20
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 1st Jan 2006 00:31
Only "sync" when you're done drawing all the lines.


David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 1st Jan 2006 02:16
Are you using lock pixels before the drawing and unlock pixels after? Otherwise they're locked each time you call which takes a while...

Hatsu
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location:
Posted: 1st Jan 2006 05:19
Only "sync" when you're done drawing all the lines.

Yes, I am doing this.

Are you using lock pixels before the drawing and unlock pixels after? Otherwise they're locked each time you call which takes a while...

I've not heard of this. I will have a look into it.

Yeah there has to be a better way than drawing 5000 lines each loop. You may want to check into memblocks.

I have a grid of 80 by 60 points. Each one is connected to adjacent points by a lne. These points are then affected by forces applied at points on the screen and repelled. I wanted to create a similar dynamic background to that of "Evolved" (arcade game) on the 360. I have done this, but with the slow framerate.
Me!
19
Years of Service
User Offline
Joined: 26th Jul 2005
Location:
Posted: 1st Jan 2006 10:48
I tried using the lines commands and even with lockpixels and sync rate 0 I get a stunning 3fps , I don`t know that memblocks will help much, you would have to draw the line pixel by pixel, so although you get faster drawing you have to do lots more calculations.



Windows: 32 bit extension/graphical shell for a 16bit patch to an 8bit OS originally coded for a 4bit CPU, written by a 2bit company that can't stand 1bit of competition, now available in 64bits.
MonoCoder
19
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 1st Jan 2006 23:40
Locking pixels



We're only Human.
Hatsu
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location:
Posted: 2nd Jan 2006 16:37
Cheers for the lockpixel code.

However it didn't improve the frame rate one bit.
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 2nd Jan 2006 17:47
Yeah, line commands have been slow in DBP for a loooong time. I know there was a thread in one of these forums a while back. Try searching Newcomers / DBC for 'Line' and youll probably find it...dunno why its so slow though :s


Join Our Forums and get game updates faster!
Me!
19
Years of Service
User Offline
Joined: 26th Jul 2005
Location:
Posted: 2nd Jan 2006 17:52 Edited at: 2nd Jan 2006 17:53
ummm! I said that though that is kinda strange, normaly lockpixels makes a noticable difference to the 2d drawspeed, in my test code it was 3fps with or without lockpixels, the only way i can think of to do it is to make a large plain from loads of polys and then texture it repeatedly with a grid texture and then tweak the vertex positions inside a memblock to deform the grid, that should be fast enough, but seriously complicated.



Windows: 32 bit extension/graphical shell for a 16bit patch to an 8bit OS originally coded for a 4bit CPU, written by a 2bit company that can't stand 1bit of competition, now available in 64bits.
Grog Grueslayer
Valued Member
20
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 3rd Jan 2006 07:55
Can we see a screenshot of the lines?


Kohaku
21
Years of Service
User Offline
Joined: 3rd May 2004
Location: The not very United Kingdom
Posted: 3rd Jan 2006 08:35
I too would like to see the purdy lines.


You are not alone.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Jan 2006 21:39 Edited at: 4th Jan 2006 00:04
Quote: "I too would like to see the purdy lines.
"


So would I. An 80x60 grid has 4800 points. What is connected to what exactly? Do you mean a simple rectangular lattice which would have 79x59 (=4661) lines, which is then distorted somehow?

I'd be tempted to draw a single image, copy it to a matrix and then manipulate the matrix coords as in one of the DBP examples (it's a while since I looked at it but I think it's relevant - will have a look after I've had supper!).

And I get about 3 fps as well with your original idea.

[Edit: Oops, it's not 79x59 is it?!]
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Jan 2006 00:02
@Hatsu

Is this the sort of thing you had in mind? Just run the code, wait a few secs for the image to be prepared, then move the mouse around. You won't see the mouse - but you'll be able to guess where it is.



This runs with an fps of about 66 on my machine.
Hatsu
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location:
Posted: 9th Jan 2006 21:26
Green Gandalf:

That's really good looking, but not what I'm looking for. However I think I may use that idea for a future game. The problem with it however is that it relies on depth which then relies on the perspective. As you can see from the pic below I'm looking for the points to move in the height and width direction.


bosskeith
19
Years of Service
User Offline
Joined: 5th Dec 2005
Location:
Posted: 26th Jan 2006 14:57
hmm i wonder what the fps would be with making 10,000 triangle objects in said scenario

Ink all over the screen...and dang it! Signature still does not show.
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 26th Jan 2006 15:14
geometary wars? i think that making a grid like object than displaying with wireframe would be faster but im not sure,

you could also try the d3d plugin thing, that adds lots of 2d commands im sure 2d lines are in there.

Halowed are the ori.
re faze
20
Years of Service
User Offline
Joined: 24th Sep 2004
Location: The shores of hell.
Posted: 26th Jan 2006 16:45
I believe lock pixels must be done in conjunction with the pixel manipulation routines (get pixels pointer) etc and you must manipulate the memory which IS faster, but line and dot should NOT be faster.

bosskeith
19
Years of Service
User Offline
Joined: 5th Dec 2005
Location:
Posted: 26th Jan 2006 16:52
we do not see your code but is all your math precalculated and stored in an array? id use i.e....dim premathed#(360,2)...where 360 is the angle and 1 would be sin(angle) and 2 would be cos(angle) ? then it would just be a matter of doing simple multiplication against your array. Doing sin/cos 50,000 times is going to effect your speed too.

normaly I would not suggest this method because of fractional angles but on the scale you are working fractional angles will have no visual difference from whole number angles.

Ink all over the screen...and dang it! Signature still does not show.

Login to post a reply

Server time is: 2025-06-10 05:25:08
Your offset time is: 2025-06-10 05:25:08