[Interest] Filling a 3-Color Triangle - A Better Way?

Josiah Bryan josiahbryan at gmail.com
Thu Jul 5 19:01:19 CEST 2012


On Thu, Jul 5, 2012 at 11:20 AM, Ian Thomson <Ian.Thomson at iongeo.com> wrote:

> On 05/07/12 16:12, Josiah Bryan wrote:
> > 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?
>
> You might want to draw your triangles on to a QImage, using
> QImage::scanLine to manipulate the pixels directly, and then put the
> QImage on to the QWidget at the end. I would imagine this would be
> faster than QPainter::fillRect.
>
>
Wow - that was faster.  379ms for 1K triangles. Much much improved - so
much so that I don't think I'll need to optimize further for now. (Revised
code attached incase anyone wants to use it.)

Thanks for your tip - I *should* have thought of that myself, don't know
why I just made it more complex to begin with. Anyways, thanks!


-- 
Josiah Bryan
765-215-0511
josiahbryan at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120705/cd3ddfdc/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MainWindow2.cpp
Type: text/x-c++src
Size: 10265 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120705/cd3ddfdc/attachment.cpp>


More information about the Interest mailing list