Archived

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

october121

DirectDraw Direct Memory Access

Recommended Posts

Guest Anonymous Poster   
Guest Anonymous Poster
create the surface in system memory, you can read from it fast but don''t try blitting with the surface. it''s SLOW.

Share this post


Link to post
Share on other sites
october121    122
ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
ddsd.dwSize = sizeof(DDSURFACEDESC2);

hRet = dds->Lock(NULL, &ddsd, DDLOCK_NOSYSLOCK | DDLOCK_WAIT, NULL);
if (hRet != DD_OK)
{
ErrStr = ErrLock;
return FALSE;
}

surf = (BYTE *)ddsd.lpSurface;
pitch = ddsd.lPitch;

for (i=0;i<(int)(ddsd.dwWidth);i+=4)
{
for (j=1;j<(int)(ddsd.dwHeight);j++)
{

//actual code removed to save space

}
}

dds->Unlock(NULL);

Share this post


Link to post
Share on other sites
mr_jrt    134
If you''re doing that each frame, the nested loops are gonna kill your frame rate.

(Although it depends on what the code is between them, but it gets executed 76,800 times each frame for a 640x480 surface)



Waassaap!!

Share this post


Link to post
Share on other sites
october121    122
Alright...that''s what I thought. I wasn''t sure how much of the problem was that and how much was directX...because even in 320x240 it runs slow, and it was fine when I implemented the same code in dos. so I guess it''s on to optimizing...heh. thanks all.

Share this post


Link to post
Share on other sites
bogdanontanu    122
Hi

Remember: u will get almost 90% of the speed of dos if u make ur code the best..(micro$oft doc writes it black on white)

So i thing u have to think about using ASM (like me) if u wanna have decent speed... and dont use the video cards accelerated 3D features...

Bogdan

Share this post


Link to post
Share on other sites