• Create Account

# Direct2D/Direct3D (10) - How do I plot a single pixel on a texture2D?

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

5 replies to this topic

### #1axefrog  Members   -  Reputation: 177

Like
0Likes
Like

Posted 10 October 2013 - 02:23 PM

With reference to the "hello world" code I've written here:

https://gist.github.com/axefrog/6918511#file-hello-world-sharpdx-2-cs

I want to set individual pixels on my 2D surface and I'm not sure that drawing a short line, the way I'm doing it in my sample code, is the best way to do it. My goal is to have a simple, fast 2D environment in which to set individual pixels as part of a series of basic exercise I'm working through. I've read somewhere that using a shader might be the way to go, but I don't know anything about shaders yet, and am not sure if that's overkill anyway.

What should I change in my code to provide me with a simple interface for setting pixels?

I'm blogging about my journey to learn 3D graphics and game programming: http://nathanridley.com

### #2L. Spiro  Crossbones+   -  Reputation: 7598

Like
0Likes
Like

Posted 10 October 2013 - 06:16 PM

You are required to use shaders in Direct3D 10, so you may as well get started studying them.

And to draw a single dot you need a vertex buffer with vertex per dot you want to draw.  If you are worried about performance you will batch as many dots into the vertex buffer as you can before actually rendering anything.  The shader simply outputs whatever color is assigned to the dot (the per-dot color would be another attribute of the vertex buffer).  Draw using a point primitive type.

Drawing lines is not to be done dot-by-dot.  For that you use another vertex buffer where the vertices represent the endpoints of the line and draw using a line primitive type.

L. Spiro

Edited by L. Spiro, 10 October 2013 - 06:17 PM.

It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

### #3Erik Rufelt  Crossbones+   -  Reputation: 2442

Like
1Likes
Like

Posted 10 October 2013 - 07:16 PM

My goal is to have a simple, fast 2D environment in which to set individual pixels as part of a series of basic exercise I'm working through.

What's the point of this?

If the exercise in itself is about implementing things by setting individual pixels then it's probably better to skip DirectX and use something that is made for that type of drawing.

### #4axefrog  Members   -  Reputation: 177

Like
0Likes
Like

Posted 11 October 2013 - 02:13 AM

You are required to use shaders in Direct3D 10, so you may as well get started studying them.

And to draw a single dot you need a vertex buffer with vertex per dot you want to draw.  If you are worried about performance you will batch as many dots into the vertex buffer as you can before actually rendering anything.  The shader simply outputs whatever color is assigned to the dot (the per-dot color would be another attribute of the vertex buffer).  Draw using a point primitive type.

Drawing lines is not to be done dot-by-dot.  For that you use another vertex buffer where the vertices represent the endpoints of the line and draw using a line primitive type.

L. Spiro

Thanks for the tip. Any particular reading material you recommend? I'll just hunt for articles of course, but I'm open to anything that stands out from the rest.

I'm blogging about my journey to learn 3D graphics and game programming: http://nathanridley.com

### #5L. Spiro  Crossbones+   -  Reputation: 7598

Like
0Likes
Like

Posted 11 October 2013 - 01:04 PM

http://www.gamedev.net/topic/557473-drawing-simple-lines-in-directx10/

L. Spiro

It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

### #6axefrog  Members   -  Reputation: 177

Like
0Likes
Like

Posted 11 October 2013 - 03:22 PM

Thanks!

I'm blogging about my journey to learn 3D graphics and game programming: http://nathanridley.com

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS