Original Post
Now I haven''t actually attempted to do this, but it seemed like a good idea to me when I thought of it yesterday. If I am WAY off, someone please let me know.
Now, it''s constantly said that writing to video memory is slow, considerably slower than system ram. Also, DirectDraw doesn''t grant you any hardware help with it either. From what I can tell, to draw a single pixel in DDraw, you do something along these lines:
)
-> Briar LoDeran <-
// you have the target surface defined and created prior... LPDIRECTDRAWSURFACE Surface = NULL; . . . // now for speed sake, you might make this global... DDSURFACEDESC DDsd; ZeroMemory(&DDsd, 0,sizeof(DDSURFACEDESC)); DDsd.dwSize = sizeof(DDSURFACEDESC); // lock the surface, get a buffer pointer... Surface->Lock(NULL, &DDsd, DDLOCK_SURFACEMEMORYPTR / DDLOCK_WAIT,NULL); int Pitch = DDsd.lPitch; // 32-bit color, so UINT... *UINT VideoBuffer = (UINT *) DDsd.lpSurface; // write pixel to memory // parems instead of brackets because of forum ... VideoBuffer(y * Pitch + x) = color; // unlock Surface->Unlock(NULL);So, my idea was to use the blitter. This would give you access to hardware acceleration, right? So, would the following be faster?
RECT rect; rect.left = x; rect.right = x; rect.top = y; rect.bottom = y; DDBLTFX ddbltfx; ZeroMemory(&ddbltfx, sizeof(DDBLTFX)); ddbltfx.dwSize = sizeof(DDBLTFX); ddbltfx.dwFillColor = color; Surface->Blt(▭, NULL, NULL, DDBLT_COLORFILL / DDBLT_WAIT, &ddbltfx);Now, in each case, you could make things global for speed sake. Perhaps you would have to do something like this to get the desired pixel:
rect.left = x; rect.right = x + 1; rect.top = y; rect.bottom = y + 1;Now, is this crazy? slow? Would this really have any speed increase over the first method? Just wondering...all comments welcome! (Also, I wrote this from memory, so there are more than likely a few bugs...