-
January 25th, 2017, 04:48 PM
#1
Performance issue when drawing on MFC
Hello all & Thanks for reading this,
-I would have a question on you:
-I have created a small application on MFC/C++ that draw different geometric shapes on screen using the mouse (like Paint). These shapes can be moved and rotated,
so, I had to keep all these created shapes in a vector and draw all of them in OnDraw().
-My problem is, when I create many shapes (more than 50-60) and I try to move/rotate one of the shapes, these movements/rotations become very-very slow.
-Could you give me some tips in order to make my application faster when moving/rotating those shapes?
Code:
OnDraw(CDC* pDC)
{
for (int i = 0; i < numberObjects; i++)
objects[i]->DrawShape(pDC);
}
Many thanks!
-
January 26th, 2017, 01:34 PM
#2
Re: Performance issue when drawing on MFC
Do you use MFC classes like CPen and CBrush, or what technique do you use for drawing? Can you share any more code?
For example, it's bad for performance if every object creates and destroys a local CPen on every call to DrawShape.
-
January 26th, 2017, 04:53 PM
#3
Re: Performance issue when drawing on MFC
Hi @TubularX,
Every "DrawShape" has a body like this: http://forums.codeguru.com/showthrea...99#post2209599 (this is also my thread).
I can't remove parts of my code because I already tried to not complicate my code too much. I will try to redraw only those shapes that are moving/rotating using InvalidateRect and UpdateData, this way, all those shapes that are not affected will not be drawn again, and maybe this way all drawing process will be faster. I hope...
Thanks!
-
January 27th, 2017, 01:49 AM
#4
Re: Performance issue when drawing on MFC
Originally Posted by Isaak
...
I can't remove parts of my code because I already tried to not complicate my code too much. I will try to redraw only those shapes that are moving/rotating using InvalidateRect and UpdateData, this way,
But why UpdateData?
Or you meant UpdateWindow?
Victor Nijegorodov
-
February 2nd, 2017, 11:28 AM
#5
Wpt
To analyze the problem:
I would suggest you to use Windows Performance Tool Kit. You will able to do memory & processing analysis with it. Is it high memory usage or/and particular function consuming cpu cycles?
Lynda course Windows Performance Tool Kit & Memory Leak will able to give you quick over view on how to use this tool. Check with your public library it might be free to access to this site.
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
|