locked
How do i put a single pixel on my window?

    Question

  • hi iam recently just learnt how to make the direct x window (direct x 11 is what iam learning ) and i am past the window stuff so now i want to make a small 2d game buy using ordinary individual pixels.

    so is there like a function i have to create e.g PutPixel(400,300,355,355,255); ya know what i mean or is there something already in one of the headers i can put????????? seriosly?????

    please email me for answers(btw only reply if you actualy know the answer

    Friday, April 4, 2014 10:03 AM

Answers

  • For 2d use Direct2d. There isn't an explicit DrawPixel, but you can draw very small ellipses or rectangles with ID2D1RenderTarget . If you need to do a lot of this you can edit a pixel buffer in memory and then copy it into your bitmap to display.

    Typically 2d games use sprites rather than manipulating individual pixels.

    --Rob

    Friday, April 4, 2014 2:51 PM
    Moderator
  • Direct2D is a 'vector' drawing API built on top of Direct3D 11. It has the traditional pixel, line, rectangle, brush-filled shapes, etc. you would see.

    That said, putting individual pixels is actually not an efficient use of modern graphics hardware. The cost to render a full textured triangle is the same as the cost to draw a single point.

    2D games typically make use of sprites as Rob notes, and you may find DirectXTK's SpriteBatch useful.

    Friday, April 4, 2014 4:33 PM

All replies

  • For 2d use Direct2d. There isn't an explicit DrawPixel, but you can draw very small ellipses or rectangles with ID2D1RenderTarget . If you need to do a lot of this you can edit a pixel buffer in memory and then copy it into your bitmap to display.

    Typically 2d games use sprites rather than manipulating individual pixels.

    --Rob

    Friday, April 4, 2014 2:51 PM
    Moderator
  • Direct2D is a 'vector' drawing API built on top of Direct3D 11. It has the traditional pixel, line, rectangle, brush-filled shapes, etc. you would see.

    That said, putting individual pixels is actually not an efficient use of modern graphics hardware. The cost to render a full textured triangle is the same as the cost to draw a single point.

    2D games typically make use of sprites as Rob notes, and you may find DirectXTK's SpriteBatch useful.

    Friday, April 4, 2014 4:33 PM