How to draw surface to screen?

Started by
2 comments, last by MaulingMonkey 14 years, 10 months ago
I want to load 25 bitmap files into memory. Twenty-five bitmap files have 800x600 resolution. I define LPD3DXRENDERTOSURFACE surface and I use D3DXCreateRenderToSurface function to create surface object. I can't find "load bitmap into memory" function and "draw" function. One bitmap is filled in one frame. One frame is copied into backbuffer before it displays to the screen. First bitmap, second bitmap, third bitmap, etc can be copied from main memory to video memory directly, and then "draw" function can display one frame each 15-30 seconds. I am new to Direct3D. I am not familiar to 3D. I want to focus how to draw 2D to the screen. Can you please write example code for me? I may not need to use "load bitmap into memory" function. Where can I find "copy bitmap from memory to surface" function? It can point to pixel buffer. Thanks for your assistance.
Advertisement
You can use IDirect3DSurface9::LockRect and manually copy your bitmap data directly using the pointer in the output D3DLOCKED_RECT structure, then unlock.
Hi, would you please be kind to write sample code? You can show an example how pixel buffer is copied into video memory using Surface9's LockRect and displays surface to the screen. DirectX 10 does not have the feature. What is another option? Thanks...
Unfortunately, I haven't used D3D10, and all my D3D9 code is actually SlimDX code (managed wrapper over D3D9) so I doubt it'd be helpful here if you really do need a sample. It might be worth noting, however, that I'm using textures directly for all my 2d images instead of mucking about with intermediate surfaces -- the only time surfaces and RenderToSurface comes up in my code is when I want to draw a bunch of textures to a single texture so I can alpha-blend them as a single group rather than each individually, and when I want to load from already-in-memory System.Drawing.Bitmap-s rather than directly from files. You can probably just use D3DXCreateTextureFromFile and sidestep surfaces entirely

And it looks like in both cases, with D3D10, I would end up using ID3D10Texture2D::Map and/or D3DX10CreateTextureFromFile instead.

This topic is closed to new replies.

Advertisement