home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.ms-windows.programmer.misc
- From: chris@chrism.demon.co.uk (Chris Marriott)
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!elroy.jpl.nasa.gov!ames!agate!doc.ic.ac.uk!pipex!demon!chrism.demon.co.uk!chris
- Subject: Re: Drawing many different objects
- Distribution: world
- References: <TAC.93Jan26103859@rena.inesc.pt>
- Organization: None
- Reply-To: chris@chrism.demon.co.uk
- X-Mailer: Simple NEWS 1.90 (ka9q DIS 1.19)
- Lines: 71
- Date: Tue, 26 Jan 1993 21:28:19 +0000
- Message-ID: <728083699snz@chrism.demon.co.uk>
- Sender: usenet@demon.co.uk
-
- 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 |
- --------------------------------------------------------------------------
-
-