Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. fast line drawing

fast line drawing

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsgame-devc++performancequestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TV
    wrote on last edited by
    #1

    Hello, I am writing a program that draws a lot of lines (up to about 30000 lines/seconds) and some text (it is a kind of chart). In order to do this, I am using GDI. I draw everything in a backbuffer and I use BitBlt to copy it to the front buffer (which is the device context of a CDialog on a dialog based VC++ 6 project). The result is that my program is very slow, use a lot of cpu time and slow down when I drag the mouse over it! Since i want to increase the speed of my code, I would like to use DirectX, OpenGL or something else. Does anybody know wich one would be the fastest to draw a lot of lines and some text with double buffering, and what would be the approximative gain of speed? Thanks for your attention (and sorry for my bad english!). TV

    A C 2 Replies Last reply
    0
    • T TV

      Hello, I am writing a program that draws a lot of lines (up to about 30000 lines/seconds) and some text (it is a kind of chart). In order to do this, I am using GDI. I draw everything in a backbuffer and I use BitBlt to copy it to the front buffer (which is the device context of a CDialog on a dialog based VC++ 6 project). The result is that my program is very slow, use a lot of cpu time and slow down when I drag the mouse over it! Since i want to increase the speed of my code, I would like to use DirectX, OpenGL or something else. Does anybody know wich one would be the fastest to draw a lot of lines and some text with double buffering, and what would be the approximative gain of speed? Thanks for your attention (and sorry for my bad english!). TV

      A Offline
      A Offline
      Anders Molin
      wrote on last edited by
      #2

      It sounds like you draw in the backbuffer and blit it to your frontbuffer, as you call it, every time WM_PAINT is called. If the window is not resized or scrolled, you could just blit your backbuffer to your frontbuffer, without doing all the drawing, because nothing have changed in the view... I hope you understand what I mean, I might have been drinking too much redvine to explain propely :-O BTW, if all the lines you are drawing only are horizontal or vertical, it's way faster to bitblt a small bitmap as the line, than using LineTo()... - Anders Money talks, but all mine ever says is "Goodbye!"

      T 1 Reply Last reply
      0
      • A Anders Molin

        It sounds like you draw in the backbuffer and blit it to your frontbuffer, as you call it, every time WM_PAINT is called. If the window is not resized or scrolled, you could just blit your backbuffer to your frontbuffer, without doing all the drawing, because nothing have changed in the view... I hope you understand what I mean, I might have been drinking too much redvine to explain propely :-O BTW, if all the lines you are drawing only are horizontal or vertical, it's way faster to bitblt a small bitmap as the line, than using LineTo()... - Anders Money talks, but all mine ever says is "Goodbye!"

        T Offline
        T Offline
        TV
        wrote on last edited by
        #3

        Hello, Actually I am using a timer to redraw every 20 milliseconds my drawing because I am aquiring point from some sensors. I agree with your remark about vertical or horizontal lines, but it is rarely (never...) the case, I have always non-horizontal nor vertical lines.

        1 Reply Last reply
        0
        • T TV

          Hello, I am writing a program that draws a lot of lines (up to about 30000 lines/seconds) and some text (it is a kind of chart). In order to do this, I am using GDI. I draw everything in a backbuffer and I use BitBlt to copy it to the front buffer (which is the device context of a CDialog on a dialog based VC++ 6 project). The result is that my program is very slow, use a lot of cpu time and slow down when I drag the mouse over it! Since i want to increase the speed of my code, I would like to use DirectX, OpenGL or something else. Does anybody know wich one would be the fastest to draw a lot of lines and some text with double buffering, and what would be the approximative gain of speed? Thanks for your attention (and sorry for my bad english!). TV

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          An earlier version of DX will give you DirectDraw, a 2D API which will be much easier to use that OpenGL. Christian NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma Anonymous wrote: OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window. I think you are a good candidate for Visual Basic. - Nemanja Trifunovic

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups