On Thursday 05 July 2012 17:12:04 Josiah Bryan wrote: > Hello, All! > > I have a particular need to fill a triangle (heck, I'll take a poly > if I could get it, but triangles are simpler to code) with a > different color at each vertex. However, since I can't use OpenGL > on my target device, I must use vanilla Qt. After much googling, > I found a routine in delphi ( > http://www.swissdelphicenter.ch/en/showcode.php?id=1780) that I > translated to Qt/C++ (see attached file - MainWindow.cpp - should > compile and run just fine as is, just throw in a folder, qmake > -project && qmake && make then run it.) > > A sample of what the rendered triangle looks like is also attached > - "sample.jpg" > > The new routine, fillTriColor(), works fine quality-wise - but > performance is abysmal at best - almost 4 sec for 1K triangles on > a dual-core 3 GHz processor! Crikey. I also tried adapting the > routine to use a QLinearGradient to fill each scanline (instead of > iterating over each column and filling the pixels directly - code > is present in MainWindowp.cpp but commented out) - but that > ballooned the time it took for 1K triangles to almost *7 seconds* > - crikey! > > So, my Qt friends, is there a better way to fill a triangle with a > color specified for each vertex, interpolated across the triangle? > Some method that takes *less* than 4 milliseconds *per triangle*? > Did I just miss something in the Qt gradient routines that would > do this quite easily? Any ideas? > > Thanks so much! > -Josiah
Here http://paste.kde.org/513062/ is some example code to fill a four- corner gradient quad, based on the idea described here http://kdepepo.wordpress.com/2010/05/03/accelerating-color-gradients/ Unfortunately, due to the perspective transform it won't work for triangles... -- Christoph Feck http://kdepepo.wordpress.com/ KDE Quality Team _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest