Re: Drawing 2d graphs using Direct3d

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Rich [Microsoft Direct3D MVP] (legalize+jeeves_at_mail.xmission.com)
Date: 04/01/04


Date: Thu, 01 Apr 2004 09:14:57 -0800


[Please do not mail me a copy of your followup]

"=?Utf-8?B?c2ZyaWVuZA==?=" <anonymous@discussions.microsoft.com> spake the secret code
<D30C3B69-01DB-4E1B-96D1-E4C83115D1CD@microsoft.com> thusly:

>I don't know Direct3d, just order Tom Millers book. Can anyone give me
>any suggestions on how I would go about doing this in Direct3d , should
>I be using Vertex's to draw the waveforms or is there a better method ?

I would use a circular buffer of vertices to draw this:

                        +--------------------+
        +===============|====================|===============+
        H | | H
        +===============|====================|===============+
                        +--------------------+

The inner rectangle is what's currently being shown on the "strip
chart" and the wider rectangle is what's being held in the vertex
buffer. You write new vertices on the end of the buffer and adjust
the strip chart to display the old stuff plus the newly added
vertices. This way you're not resending the entire strip chart to the
card every time you update. When you get to the end of the buffer,
you have two choices, either resend all the visible data to the
beginning of the buffer or break the draw up into two chunks: one at
the end of the buffer and one at the beginning of the buffer.

>Is there a fast way to perform a scroll, or do I just redraw the lines
>each time ?

In 3D you redraw the whole scene every time. That doesn't mean you
can't cache rendered chunks of the scene for quick redraw (think
memory DC in GDI terms), but generally you just redraw the whole scene
and don't think of caching schemes until things get slow.

-- 
"The Direct3D Graphics Pipeline"-- code samples, sample chapter, FAQ:
          <http://www.xmission.com/~legalize/book/>
	    Pilgrimage: Utah's annual demoparty
               <http://pilgrimage.scene.org>


Relevant Pages

  • Re: [OT, maybe] C library for doing graphics
    ... complete buffer API. ... draw an arbitrary straight line in a given colour; ... draw a rectangle ... load a bitmap image; ...
    (comp.lang.c)
  • Alpha Channel from mask
    ... When Flash draws itself into my buffer, it takes the pixels in my buffer ... i tried to draw Flash twice by changing the background color of the ... set background of movie BLACK and draw in buffer SourceBuffer. ...
    (microsoft.public.win32.programmer.gdi)
  • Re: XOR in OPENGL
    ... functions for draw lines with press, ... front and the back buffer. ... For the XOR rubberband method to work, ...
    (comp.graphics.api.opengl)
  • Re: GDI, DirectX and Vista
    ... because my scenes are rendered as static images rather than frames, ... rendering the scene each time would flicker badly. ... Say I had a back buffer that I had already presented and I had another DX surface that I had drawn to ... ... I imagine that if I blt that surface to the backbuffer, it would then be corrupted with my drawing and the only way to get the original would be to draw the primitives again. ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Using glReadPixels to read the depth buffer
    ... assignment to figure out how to draw a subset of the geometry while it ... fragments are not drawn even if they were able to draw before. ... //that means I can reuse the back buffer as savings.... ... //Set up stenciling to write the value 1 into the stencil buffer ...
    (comp.graphics.api.opengl)