Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Direct2D drawing points

1,188 views
Skip to first unread message

listechtony

unread,
Oct 1, 2009, 7:36:01 PM10/1/09
to
Hi,

I have a question on Direct 2d rendering, which I am attending to
familiarize myself with. It seems there are plenty of examples of how to draw
lines and shapes, but what if I also want to draw simple points, i.e a one
pixel dot. Direct 3d has POINTLIST primitives, but what is the equivalent in
Direct 2d?

Regards

Tony

Richard [Microsoft Direct3D MVP]

unread,
Oct 2, 2009, 11:10:27 AM10/2/09
to
[Please do not mail me a copy of your followup]

=?Utf-8?B?bGlzdGVjaHRvbnk=?= <liste...@discussions.microsoft.com> spake the secret code
<F14889A6-F006-4494...@microsoft.com> thusly:

Did you try a line with two coincident vertices?
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://legalizeadulthood.wordpress.com/the-direct3d-graphics-pipeline/>

Legalize Adulthood! <http://legalizeadulthood.wordpress.com>

listechtony

unread,
Oct 4, 2009, 5:18:01 PM10/4/09
to

Yes, but got nothing drawn. Then I tried it one pixel different and got a
point a pixel in size, so that would work. Is it the most efficient way
though, drawing one pixel lines in the absence of a DrawPoint command?

Richard [Microsoft Direct3D MVP]

unread,
Oct 6, 2009, 10:38:44 PM10/6/09
to
[Please do not mail me a copy of your followup]

=?Utf-8?B?bGlzdGVjaHRvbnk=?= <liste...@discussions.microsoft.com> spake the secret code

<8157099E-21C9-4696...@microsoft.com> thusly:

>Yes, but got nothing drawn. Then I tried it one pixel different and got a
>point a pixel in size, so that would work. Is it the most efficient way
>though, drawing one pixel lines in the absence of a DrawPoint command?

Direct3D has a point primitive; if you have large batches of points to
draw you can use D3D interop and draw point primitives.

Other D2D alternatives are to draw a bitmap with a single set pixel,
or draw a rectangle whose corners are 1/2 a pixel apart diagonally.

However, I don't think either of those latter two alternatives are
going to be better than drawing a line whose endpoints are separated
by more than 1/2 a pixel. The bitmap one might have the
characteristics of a point sprite, it depends on how they implemented
that.

listechtony

unread,
Oct 18, 2009, 8:24:01 PM10/18/09
to

Thanks Richard,

I have been experimenting with one pixel lines, creating geometries with
transformed coordinates and adding one pixel to the start coordinate to
create a one pixel line. The problem with this is that when I again transform
by zooming in on the point cloud, say scaling by 2, then my points become 2
pixels wide, then 4, etc and suddenly they are large blobs on the screen.
What I want is to be able to zoom and pan (i.e.scale and translate) without
modifying the size of the points i.e always 1 pixel, yet of course the points
themselves will be transformed accordingly. How is this possible using Direct
2d?

"Richard [Microsoft Direct3D MVP]" wrote:

Richard [Microsoft Direct3D MVP]

unread,
Oct 18, 2009, 11:59:41 PM10/18/09
to

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

=?Utf-8?B?bGlzdGVjaHRvbnk=?= <liste...@discussions.microsoft.com> spake the secret code

<99442135-EBB9-46F8...@microsoft.com> thusly:

>I have been experimenting with one pixel lines, creating geometries with
>transformed coordinates and adding one pixel to the start coordinate to
>create a one pixel line. The problem with this is that when I again transform
>by zooming in on the point cloud, say scaling by 2, then my points become 2
>pixels wide, then 4, etc and suddenly they are large blobs on the screen.
>What I want is to be able to zoom and pan (i.e.scale and translate) without
>modifying the size of the points i.e always 1 pixel, yet of course the points
>themselves will be transformed accordingly. How is this possible using Direct
>2d?

I don't think you'll be able to do that without constantly adjusting
your geometry or using another rendering system like GDI or Direct3D.

The two rendering models are not consistent. On the one hand you want
geometry manipulated by the current transform, but on the other hand
you don't want the geometry manipulated by the current transform.

I'm not saying its an unreasonable request, but its not consistent
with Direct2D's idea of a line.

listechtony

unread,
Oct 21, 2009, 1:58:17 AM10/21/09
to
Yes, Richard, I see what you mean, and unless a concept of a point was
introduced into Direct 2d, Direct 3d is probably the better approach.

However, to extend the requirement further, sometimes I wish to display
points as little crosses, i.e. 2 little lines crossing, which also don't
change size when zooming in, rather than just as pixels. So at some stage, I
am going to need to edit the rendered geometry, be it Direct3d primitives or
Direct 2d geometry, and write to the screen crosses (say 5 pixel crosses) at
the position of the transformed coordinates. I expect that that is certainly
possible since I would be able to write some code that is performed at that
point in the pipeline for Direct3d. Obviously though, I will get a
performance hit.

What API should I use, do you think to achieve this, Direct3d? And how could
I get the best performance out of this? Is multi-threading the render so that
the basic transformation is done, then gradually point crosses are written,
feasible? (A little like say Google Earth, which seems to update the display,
but still not make the user wait).

Tony

"Richard [Microsoft Direct3D MVP]" wrote:

> .
>

Richard [Microsoft Direct3D MVP]

unread,
Oct 22, 2009, 12:10:28 AM10/22/09
to
[Please do not mail me a copy of your followup]

=?Utf-8?B?bGlzdGVjaHRvbnk=?= <liste...@discussions.microsoft.com> spake the secret code

<F950EB8F-831B-4E27...@microsoft.com> thusly:

>However, to extend the requirement further, sometimes I wish to display
>points as little crosses, i.e. 2 little lines crossing, which also don't

>change size when zooming in, rather than just as pixels. [...]

It sounds like you're doing a CAD or GIS like rendering. In those
domains these things are called "markers" and drawing them as a point
sprite positioned appropriately is probably going to be the easiest
way to do that. Put the image of the cross or whatever symbol you
want to draw into the texture map and draw a quadrilateral as two
triangles (or as a single point in D3D with point sprites enabled).

>What API should I use, do you think to achieve this, Direct3d? And how could
>I get the best performance out of this? Is multi-threading the render so that
>the basic transformation is done, then gradually point crosses are written,
>feasible? (A little like say Google Earth, which seems to update the display,
>but still not make the user wait).

With some care its easy to draw many thousands of point sprites at
interactive rates. They are commonly used in games for explosion
effects.

listechtony

unread,
Oct 22, 2009, 6:20:01 PM10/22/09
to
You are right, Richard, it is a CAD application. Would you recommend Direct3d
or Direct 2d in this case, assuming point spriting is the way to go here. We
also need to draw lines, often with styles (e.g. with series of dots and
dashes, railway line symbols, etc) and we will need to draw images and
triangles too. All this in 2d though, there is no z component to worry about,
nor do we need to worry unduly about texturing meshes, lighting, shading,
etc. Performance is the key however, we need to be able to draw millions of
points at interactive rates.

"Richard [Microsoft Direct3D MVP]" wrote:

> .
>

Richard [Microsoft Direct3D MVP]

unread,
Oct 30, 2009, 6:40:13 PM10/30/09
to
[Please do not mail me a copy of your followup]

=?Utf-8?B?bGlzdGVjaHRvbnk=?= <liste...@discussions.microsoft.com> spake the secret code

<F800F0E5-5419-413A...@microsoft.com> thusly:

>You are right, Richard, it is a CAD application. Would you recommend Direct3d
>or Direct 2d in this case, assuming point spriting is the way to go here. We
>also need to draw lines, often with styles (e.g. with series of dots and
>dashes, railway line symbols, etc) and we will need to draw images and
>triangles too. All this in 2d though, there is no z component to worry about,
>nor do we need to worry unduly about texturing meshes, lighting, shading,
>etc. Performance is the key however, we need to be able to draw millions of
>points at interactive rates.

Essentially, you can think of D2D as a layer on top of D3D. It uses
D3D resources to get its job done (AFAIK, there are no D2D entry
points into the driver).

So, anything that D2D does you can do yourself in D3D. You may find
that D2D simplifies things for you, because it is managing textures,
shaders, etc. to achieve the desired results.

You can interoperate between D3D and D2D fairly easily. So you could
use D2D with a rendering target that renders directly into your D3D
back buffer (or some other surface, like a level from a texture) and
do any D3D stuff that you need to do natively in D3D.

For instance, D2D already has pretty fance ways of drawing lines that
it supports. You could duplicate that in D3D yourself, or you could
just use D2D's support as-is using an appropriate render target for
combining the results on the device.

0 new messages