How do I do 2D graphics in Direct3D?

I amwritting a map maker and all I need is to view, zoom in and out, and highlight the square the user is pointing at. GDI+ has proven WAY too slow for this so I'd like to use DirectX.

I can't seem to find a sample or tutorial that's not about 3D. I just want to have a buffer of bytes[] and an offset. I remember being able to lock the screen device, manipulate the buffer, then unlock and it would update the screen. Are you not able to draw 2D surfaces anymore?

Any help would be appreciated.

Tom P.
[600 byte] By [padillah] at [2007-12-23]
# 1
Managed or C++?
CirdanCelebrindal at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...
# 2

Of course, I'm sorry.

Managed (C#). Visual Studio 2005.

Thanks.

Tom P.

padillah at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...
# 3
Do you have an array of bytes, where each byte represents a tile in a 2D tile map?

If so, pack all the tiles into one large texture, and then generate vertices for each square. Then move the camera up/down/left/right/in/out to do the operations you need. Use an Ortho mode for the camera to make it look and draw 2D.

You will want to generate vertices with position and texture coordinate. The texture coordinate should be the coordinate of your tile within the texture, divided by texture height/width (i e, so the right edge is 1.0). The X and Y coordinates can be just the tile coordinate, and the tile coordinate+1. Generate six vertices around each tile, so that you get two triangles, then draw using DrawPrimitives() -- you don't need an index buffer.

If your array of bytes is an actual image, then you lock a texture, poke the data into there, unlock the texture, and draw a single square (two triangles) with the texture on it. It's probably best to put the texture in MANAGED pool.

JonWatte at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...
# 4
Hmm, so you can't get the screen buffer anymore? That's disappointing.

I'll look into the texture example you gave above.

Thanks,

Tom P.

padillah at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...
# 5
See the "Simple 2D" sample in the DirectX SDK
DavidWeller at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...