Archived

This topic is now archived and is closed to further replies.

how to draw 2d graphics with d3d9

This topic is 4988 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

how to draw some 2d graphics with directx9 such as lines,circles,pixels? Just like 3dmax''s viewport can show 2d and 3d objects together. another question is wether the "device" in d3d and ddraw are the same?Can i use some ddraw fuctions in d3d device? sorry for my pool english Thank you

Share this post


Link to post
Share on other sites
Graphics are usually primitives rendered via Direct3D. A primitive is, in basic, a list of vertices that may form a line or a polygon. If I wanted to draw a ''sprite'' I would render a 2d primitive with four vertices that form a quad textured with whatever image represents the sprite. If I wanted to draw a line then I would define two vertices and then render them as a ''line list'' or ''line strip''. When rendering a primitive, you specify which vertices the primitive consists of, how to render the primitive (line list - wire frame, triangle strip - solidly coloured, point list etc) and a texture to map onto the primitive should you wish it. Head over to Drunken Hyena (or perhaps the articles section here or GameDev.net) for some simple examples.
Rendering circles is a little bit more work, as there is no built in support for the drawing of curves. To get around this you can render a sequence of lines in a ring (or triangles for solid-circles), or simply render an image of a circle (textured quad).
To answer your final question - no, DirectDraw is not part of the Direct3D device. However, I believe that it is possible to combine both Direct3D and DirectDraw (specifically with previous versions of DirectX), however this is normally a bad way to do things.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:


Microsoft DirectX 9.0

IDirectDrawSurface::Lock

The Lock method obtains a valid pointer to the surface memory. DirectDraw relies on the application calling Unlock. It is illegal behavior to Blt from a region of a surface that is locked.




look it up ... you could use the pixel setting functions to reimplement the Bresenham algorithm if you wanted. It can be done using a textured quad comprised of 2 triangles filling the screen. The surface would probably be 32 bit for an optimal image (RGBA) so you would need to aquire 32 bit pointers to the buffer

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Anonymous Poster
quote:


Microsoft DirectX 9.0

IDirectDrawSurface::Lock

The Lock method obtains a valid pointer to the surface memory. DirectDraw relies on the application calling Unlock. It is illegal behavior to Blt from a region of a surface that is locked.




look it up ... you could use the pixel setting functions to reimplement the Bresenham algorithm if you wanted. It can be done using a textured quad comprised of 2 triangles filling the screen. The surface would probably be 32 bit for an optimal image (RGBA) so you would need to aquire 32 bit pointers to the buffer




easier and better to use the backbuffer directly ...

quote:

... this technique allows direct access to video memory ...

Share this post


Link to post
Share on other sites