I've been working on a Mandelbrot grapher in C# with xna, and I have gotten all of the calculations to work properly. However, the program runs very slowly, not because of the calculations, but because I was using a 1x1 pixel texture repeated 250,000 times in order to draw it. Does anyone know what some of the better ways to draw single pixels, and how to use them? Your help is greatly appreciated.
Modify a Texture2D (That is the size of the screen) Pixel by pixel, then render the Texture2D to screen?
SetData can be used to modify a Texture2D.
[url]http://forums.xna.com/forums/p/7492/39527.aspx[/url]
Post #2 has an Example of its use.
There may be other ways too, but this is a way I used to generate stuff per pixel.
Wait, how do I turn a color into an integer?
Finding this difficult without an XNA install infront of me, but I believe it is a template and it has an overload with one argument (an array of the type specified)
Texture2D.Setdata<color>(color[]);
You might need to dig around a bit, this is off memory.
Yeah, that was it.
That only sped it up slightly, I was kind of hoping for something that would be quick enough to scroll and zoom using key controls, but I don't know if it could ever be fast enough for that.
If XNA isn't a requirement you could just use WinForms and LockBits for fast 2D manipulation.
Are you recalculating the whole set each frame?
[QUOTE=SamPerson123;21417501]Yeah, that was it.
That only sped it up slightly, I was kind of hoping for something that would be quick enough to scroll and zoom using key controls, but I don't know if it could ever be fast enough for that.[/QUOTE]
If you can't get it fast enough, you could use the texture2D as a "Preview" as sorts that is is scaled to zoom, then when zooming has stopped, the set is recalculated and the texture is rebuilt? - It would be as fast as XNA is able to chuck one sprite onto the screen until zooming has stopped.
Just a thought, Don't know if it would apply yo your situation.
[QUOTE=Tezza1234;21417673]If you can't get it fast enough, you could use the texture2D as a "Preview" as sorts that is is scaled to zoom, then when zooming has stopped, the set is recalculated and the texture is rebuilt? - It would be as fast as XNA is able to chuck one sprite onto the screen until zooming has stopped.
Just a thought, Don't know if it would apply yo your situation.[/QUOTE]
Yeah, I think I'll just do that. I wouldn't be able to do that if you hadn't told me about setdata, so thanks for everything. :unsmith:
[img]http://www.facepunch.com/ads/navbar/search.png[/img]?
I already asked this. You had to make a Texture2D and SetData.
[editline]10:17PM[/editline]
Part of the Mandlebrot Bandwagon.
Sorry, you need to Log In to post a reply to this thread.