Hold on ! Stop the boat!

Started by
6 comments, last by BlackEye 20 years, 5 months ago
Hold on ! I have been working on a game using DirectX8 for months now, its getting close to completion now. I use sprites and rotate, transform and all the trimmings. BUT somewhere i have missed something! HOW THE HELL DO I JUST DRAW A SINGLE PIXEL !! I mean using Direct X or not!? errrr I dont know! Im sure you guys do. So whats the easiest way to just draw a pixel of a set colour somewhere on screen? Using DX or GDI Im scared i have overlooked this! Whar else have i missed, even D3D tutorials start with triangles!?
Advertisement
DirectX:

Drawing a pixel somewhere on the screen requires you to access directly the surface memory of the back buffer, which in turn requires data transfers from and to the graphics card. Such operations will (usually) lose you all the benefits of accelerated 3d, and as such it''s not advisable.

A way to get around this is to draw a pointlist in transformed mode, where each vertex has it''s own position and color. This should result in pixels being written to the screen, approximately where you want them.

GDI:

Don''t know.
you could draw a 1x1 sprite, or have drawprimitive just do 1 vertex.
GDI: SetPixel(...), but this will slow down your dx...


T2k
yeah, thanks i just saw the Setpixel function in my old lamothe book! And the brushes and pens GDI bit. Phew feel better now. Doesnt work to well with My DX app though, the pixels flicker?
yeah, thanks i just saw the Setpixel function in my old lamothe book! And the brushes and pens GDI bit. Phew feel better now. Doesnt work to well with My DX app though, the pixels flicker?
Have you ever heard of the POINT primitive?
You can use tansformed vertices and a POINT_LIST to draw 1 or more pixels.

--
You''re Welcome,
Rick Wong
- sitting in his chair doing the most time-consuming thing..
And if you really need pure 2d functionality:


  1. Create a texture of desired size.

  2. Lock it; you''ll get a raw data pointer in which you can draw.

  3. Draw 2d stuff using any algorithm you like. Note that you have to implement the whole drawing yourself.

  4. Unlock the texture.

  5. Either blit or render the texture to the backbuffer. Rendering is faster in almost all cases (except for very small blits).



Note that in dx9, you can get a DC for your Direct3D surfaces, so that you can use Windows'' drawing functions. (I know you''re using 8 for now )

kind rgds,
-Nik

Niko Suni

This topic is closed to new replies.

Advertisement