|
-
Oct 12th, 2001, 12:51 PM
#1
Thread Starter
Member
Increasing framerate
I have created a "Solar Simulator" which very accurately calculates orbits and gravitational forces. I use the PictureBox.Circle command to draw the "planets" on the backbuffer and then I set the output picturebox's picture equal to the backbuffer's image.
The reason I am doing it this way is to eliminate screen flicker, but I am running into some serious framerate issues. Doing the calculations with double precision variables takes almost no time at all. 3/4's of the time is spent drawing the spheres and flipping the screen buffer.
I am almost positive that there is a faster way to do this. Any suggestions?
-
Oct 12th, 2001, 01:07 PM
#2
Addicted Member
Use the API
Use the API instead of using VB's built in functions, they are notoriously slow. You can use bitblt to copy from 2 different places and the elipse api punction to draw circles.
If you want to use DC's and such to store you gfx in memory just go look around or ask on the forums for a bitblt demo using DC's. You're bound to get one 
Hope this helps.
Drewski
I see said the blind man as he spat into the wind.
It all comes back to me now!
A.D.T.'s VB
-
Oct 12th, 2001, 01:32 PM
#3
Addicted Member
posting ??
hy, could you post your prog .. seems to be interesting ..
cya
Old enough to know better,
but young enough to don't give a ****!
-
Oct 12th, 2001, 01:46 PM
#4
If you really go an think about it, Circle, Line, etc, are just wrappers on API functions already. Use circle for your circles, and then use PaintPicture to flip. It's BitBlt for Picture boxes. It that doesnt speed things up, then go to API (they take almost the same parameters anyway).
Z.
-
Oct 12th, 2001, 02:13 PM
#5
Frenzied Member
-
Oct 12th, 2001, 02:52 PM
#6
Good Ol' Platypus
Here's a tutorial on Bitblt for those who are bitblock-challenged =)
http://vbden.tripod.com/articles/invmask.htm
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Oct 12th, 2001, 03:23 PM
#7
Thread Starter
Member
I implemented your suggestions, but it didn't speed up noticibly... Considering that on average I do 100 iterations of the gravitational formula per frame and most frames don't even have much movement, I guess I'm not all that surprised.
About posting it, I most definitely will... Right now it is horribly coded and there are a couple bugs... Maybe in a few hours?
-
Oct 12th, 2001, 04:21 PM
#8
Thread Starter
Member
Keep in mind that I am very new to VB. There are a couple mistakes in how I apply some of the mathmatical formulas, but this should simulate orbits of planets around a sun many many many times more accurately than anything I have seen.
I plan on completely rewriting most of the code, but I would still love to hear your comments.
-
Oct 14th, 2001, 02:06 PM
#9
Planets
Just D/L - not bad!
Speed issues:
Remember to clear just the graphics that have moved -
(rather than object.cls)
Drawing directly onto the form and not bothering with pictureboxes may help to. You can still control refreshes
for smooth graphics using just a form.
stuff like object.fillcolor / .circle is slow to - use the api equivalent.
HTH
Cheers
J.
-
Oct 14th, 2001, 10:05 PM
#10
Thread Starter
Member
Thanks for the suggestions I will implement them as soon as I get to work.
-
Oct 15th, 2001, 12:05 AM
#11
Addicted Member
Use one picturebox.
AutoRedraw = True, Visible = True.
Draw your graphics, and then use PictureBox.Refresh to update it.
VB has built in double-buffering, ain't it nifty? Picture-swapping and picture manipulation always result in bad framerates.
"1 4m 4 1337 #4xz0r!'
Janus
-
Oct 15th, 2001, 07:26 AM
#12
Good Ol' Platypus
Also for your gravity formula you may want to implement a look-up table, if it is very slow.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Oct 15th, 2001, 01:12 PM
#13
Addicted Member
and actually...
Object.FillColor/FillStyle/Circle/Line/etc. Simply call the API methods with the correct properties, saving you a LOT of work. Use 'em if they are simpler, they're not THAT much slower.
"1 4m 4 1337 #4xz0r!'
Janus
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|