View Single Post
Old 26th July 2015, 14:57   #12  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
Quote:
Originally Posted by davidhorman View Post
I did stop. I did think. What I thought was "what methods do I have at my disposal that will do exactly what I want?" and the answer I came up was GDI+. I didn't have to download or compile anything extra.
No. Much like an electrical current (which doesn't stop and think either), you chose the path of least resistance.

Quote:
Originally Posted by davidhorman View Post
Why not? GDI+ doesn't only draw to the screen. I create a Bitmap object and pass the AviSynth write pointer directly to it for it to use as its pixel data. The GDI+ call writes directly to the RGB32 clip. I get over 1000 frames per second for a 50-sided polygon at SD resolution (that's faster than an SD blankclip call), and 190fps at HD resolution (vs 210fps for an HD blankclip). That's for an anti-aliased and spline-smoothed polygon, by the way, and I haven't even started optimising yet.

I started out using a naive scanline polygon algorithm I'd (independently) came up with many years ago. When that got a bit tedious and the limitations became obvious, I stripped the code back to the bare essentials and from there the additional code to support and implement the GDI+ method amounts to about 15 lines, if that.
You haven't seen the limitations of GDI+ because you've barely even started coding yet. If I were to ask myself "when is GDI+ the appropriate tool to use", the only real answer would be some toy Win32 GUI app that is only ever going to run on Windows, will never need to draw anything complex and doesn't have to worry about performance.

GDI+ isn't hardware accelerated, it's limited to Windows only and it's actual drawing capabilities are pretty limited by today's standards. For your current needs - basically just a proof-of-concept prototype - that's all fine. The reason I'm telling you to stop and think is that you need to consider the future implications of choosing GDI+ now. If you, two years from now, decide that you want to port your by that point quite mature plugin to VapourSynth and introduce cross-platform compatibility, you'd have to redesign the entire thing from ground up. Same thing if you run into performance issues.

I don't know what exactly you want your plugin to be able to do nor how you like to code things but please consider alternative rendering libraries such as SFML, Cairo, Skia or even Direct2D if you insist on being platform-locked to Windows. Many of these use OpenGL, which you can also use directly yourself if you want, but it's probably a bit too low level for your needs.

Last edited by TheFluff; 26th July 2015 at 15:06.
TheFluff is offline   Reply With Quote