   Writing 2D Data to the back buffer in Direct3D9
  I am trying to write 2D data from a bitmap. The bitmap bmp has an array of integers storing the pixels in ARGB format. The backbuffer format is X8R8G8B8 so I don't think I'll have a problem. I have the following code:device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &surface);if (bmp.bitmap != null){D3DSURFACE_DESC desc;surface->GetDesc(&desc);if ((position.x + bmp.width > desc.Width) || (position.x < 0) || (bmp.width <= 0))return;if ((position.y + bmp.height > desc.Height) || (position.y < 0) || (bmp.height <= 0))return;D3DLOCKED_RECT rect;surface->LockRect(&rect, NULL, NULL);int *temp = (int *)rect.pBits;for (int y=0;(unsigned int)y<desc.Width;y++){for (int x=0;(unsigned int)x<desc.Height;x++){if (desc.Format == D3DFMT_X8R8G8B8)*temp = bmp.bitmap[x];temp++;}temp += rect.Pitch;}surface->UnlockRect();}Will this work? If it doesn't, can you link to a page that tells how to do what I'm trying to do? Any help will be greatly appreciated.~David   
  When using Direct3D, there is a much easier and more efficient way to draw a texture to the backbuffer.  Since D3D is a 3D API, everything must be drawn in terms of triangles (simply put).  What you can do is render a textured quad (made up of two triangles).  Fortunately, D3DX has a nice interface for doing this - ID3DXSprite.Basically, all you need to do is:(a) Load the texture using D3DXCreateTextureFromFile()(b) Create a single ID3DXSprite interface - you should use one sprite interface for all the textures you have to draw(c) When you want to begin drawing sprites, call ID3DXSprite::Begin()(d) To draw a texture, call ID3DXSprite::Draw()(e) When done drawing sprites, call ID3DXSprite::End()Here is a little tutorial I found on it   ;  That's very interesting, thank you :)That should fix my problem, though I have a question. What is the C++ equivalent of memcpy? I see he used it here:g_pVertexBuffer->Lock( 0, sizeof(g_quadVertices), (void**)&pVertices, 0 );memcpy( pVertices, g_quadVertices, sizeof(g_quadVertices) );g_pVertexBuffer->Unlock();;Quote:Original post by zeldafreakThat should fix my problem, though I have a question. What is the C++ equivalent of memcpy? I see he used it here:g_pVertexBuffer->Lock( 0, sizeof(g_quadVertices), (void**)&pVertices, 0 );memcpy( pVertices, g_quadVertices, sizeof(g_quadVertices) );g_pVertexBuffer->Unlock();memcpy() is still used in C++ extensively.That code looks right to me...except for the sizeof() part.  g_quadVertices is a int pointer, so the sizeof() operator will always return 4.  What you want to do is numVertices * sizeof( VertexStruct ).   