home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / mswindo / programm / misc / 5443 < prev    next >
Encoding:
Text File  |  1993-01-28  |  3.2 KB  |  86 lines

  1. Newsgroups: comp.os.ms-windows.programmer.misc
  2. From: chris@chrism.demon.co.uk (Chris Marriott)
  3. 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
  4. Subject: Re: Drawing many different objects 
  5. Distribution: world
  6. References: <TAC.93Jan26103859@rena.inesc.pt>
  7. Organization: None
  8. Reply-To: chris@chrism.demon.co.uk
  9. X-Mailer: Simple NEWS 1.90 (ka9q DIS 1.19)
  10. Lines: 71
  11. Date: Tue, 26 Jan 1993 21:28:19 +0000
  12. Message-ID: <728083699snz@chrism.demon.co.uk>
  13. Sender: usenet@demon.co.uk
  14.  
  15. In article <TAC.93Jan26103859@rena.inesc.pt> tac@rena.inesc.pt writes:
  16.  
  17. >
  18. >
  19. >Hello
  20. >
  21. >I would like some advice on the following problem.
  22. >
  23. >I need to draw may graphical objects, which use different 
  24. >pens, brushes, fonts and bitmaps(used for custom brush patterns).
  25. >
  26. >The objects can be created dynamically, so I don't now at start how many
  27. >pen/brushes/*,  I will need.
  28. >
  29. >Should I, Each time I need to draw, use the Paint DC or the dc from GetDC(hWnd)
  30. >and create the pen/brush/* selected it to the dc, draw, and then deselect it?
  31. >
  32. >What are the penalties of using allways GetDC() (instead of the Paint DC)
  33. >even when processing PAINT events?
  34. >
  35.  
  36. It's not a question of *penalties* - it's a question of what works!
  37. BeginPaint/EndPaint doesn't only give you the DC; more importantly it
  38. validates the invalid region and clips to it.  If you respond to WM_PAINT
  39. using GetDC your invalid region will *never* get validated, and you'll
  40. get an endless stream of WM_PAINT messages!
  41.  
  42. >Would it be faster (since I need to draw many graphical objects) to draw
  43. >first on a bitmap and then BitBlt it to the window?
  44. >
  45.  
  46. If you have a static complex scene then yes - draw it once to a bitmap or
  47. metafile, then blit/play it back on receipt of WM_PAINT.
  48.  
  49. If you're only going to be drawing it once, then it'll be faster if you 
  50. paint directly to the screen.
  51.  
  52. >Should I have lists of pre-created pens/brushes/* and each time I need to
  53. >perform a graphic operation try to find on those lists the best matching
  54. >pen/brush/* instead of creating it?
  55. >
  56.  
  57. That depends how many you're talking about.  Creating a few hundred pens
  58. when you draw is insignificant; creating half a million takes a long time.
  59. If you really have a *lot* a creating/deleting to do (>100,000), create
  60. the pens once and store them in an array or something.  If you have less,
  61. create and destroy them dynamically.
  62.  
  63. >        Thanks for any info.
  64. >
  65. >Telmo Carmo - tac@inesc.pt
  66. >
  67.  
  68. Best wishes,
  69.  
  70. Chris
  71. >--
  72. >=============================================================================
  73. >Telmo Carmo -- tac@inesc.pt           | 'Old programmers never die,
  74. >Tel: +351-1-3100085 FAX: 351-1-525843 |  they just branch to another address'
  75. >==============================================================================
  76. >
  77.  
  78. -- 
  79. --------------------------------------------------------------------------
  80. | Chris Marriott                           | chris@chrism.demon.co.uk    |
  81. | Warrington, UK                           | BIX: cmarriott              |
  82. |                                          | CIX: cmarriott              |
  83. | Save the whales.  Collect the whole set. | CompuServe: 100113,1140     |
  84. --------------------------------------------------------------------------
  85.  
  86.