Thread View: comp.os.ms-windows.programmer.misc
2 messages
2 total messages
Started by Telmo A. Carmo
Tue, 26 Jan 1993 10:38
Drawing many different objects
Author: Telmo A. Carmo
Date: Tue, 26 Jan 1993 10:38
Date: Tue, 26 Jan 1993 10:38
34 lines
1690 bytes
1690 bytes
Hello I would like some advice on the following problem. I need to draw may graphical objects, which use different pens, brushes, fonts and bitmaps(used for custom brush patterns). The objects can be created dynamically, so I don't now at start how many pen/brushes/*, I will need. Should I, Each time I need to draw, use the Paint DC or the dc from GetDC(hWnd) and create the pen/brush/* selected it to the dc, draw, and then deselect it? What are the penalties of using allways GetDC() (instead of the Paint DC) even when processing PAINT events? Would it be faster (since I need to draw many graphical objects) to draw first on a bitmap and then BitBlt it to the window? Should I have lists of pre-created pens/brushes/* and each time I need to perform a graphic operation try to find on those lists the best matching pen/brush/* instead of creating it? Thanks for any info. Telmo Carmo - tac@inesc.pt -- ============================================================================= Telmo Carmo -- tac@inesc.pt | 'Old programmers never die, Tel: +351-1-3100085 FAX: 351-1-525843 | they just branch to another address' ==============================================================================
Re: Drawing many different objects
Author: Chris Marriott
Date: Tue, 26 Jan 1993 21:28
Date: Tue, 26 Jan 1993 21:28
71 lines
3364 bytes
3364 bytes
In article <TAC.93Jan26103859@rena.inesc.pt> tac@rena.inesc.pt writes: > > >Hello > >I would like some advice on the following problem. > >I need to draw may graphical objects, which use different >pens, brushes, fonts and bitmaps(used for custom brush patterns). > >The objects can be created dynamically, so I don't now at start how many >pen/brushes/*, I will need. > >Should I, Each time I need to draw, use the Paint DC or the dc from GetDC(hWnd) >and create the pen/brush/* selected it to the dc, draw, and then deselect it? > >What are the penalties of using allways GetDC() (instead of the Paint DC) >even when processing PAINT events? > It's not a question of *penalties* - it's a question of what works! BeginPaint/EndPaint doesn't only give you the DC; more importantly it validates the invalid region and clips to it. If you respond to WM_PAINT using GetDC your invalid region will *never* get validated, and you'll get an endless stream of WM_PAINT messages! >Would it be faster (since I need to draw many graphical objects) to draw >first on a bitmap and then BitBlt it to the window? > If you have a static complex scene then yes - draw it once to a bitmap or metafile, then blit/play it back on receipt of WM_PAINT. If you're only going to be drawing it once, then it'll be faster if you paint directly to the screen. >Should I have lists of pre-created pens/brushes/* and each time I need to >perform a graphic operation try to find on those lists the best matching >pen/brush/* instead of creating it? > That depends how many you're talking about. Creating a few hundred pens when you draw is insignificant; creating half a million takes a long time. If you really have a *lot* a creating/deleting to do (>100,000), create the pens once and store them in an array or something. If you have less, create and destroy them dynamically. > Thanks for any info. > >Telmo Carmo - tac@inesc.pt > Best wishes, Chris >-- >============================================================================= >Telmo Carmo -- tac@inesc.pt | 'Old programmers never die, >Tel: +351-1-3100085 FAX: 351-1-525843 | they just branch to another address' >============================================================================== > -- -------------------------------------------------------------------------- | Chris Marriott | chris@chrism.demon.co.uk | | Warrington, UK | BIX: cmarriott | | | CIX: cmarriott | | Save the whales. Collect the whole set. | CompuServe: 100113,1140 | --------------------------------------------------------------------------
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads